1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
use CString;
use RecordId;
/// Process created a new cgroup.
///
/// # Examples
///
/// Running this example may require root privileges.
///
/// ```rust, no_run
/// use perf_event_open::config::{Cpu, Opts, Proc};
/// use perf_event_open::count::Counter;
/// use perf_event_open::event::sw::Software;
///
/// let event = Software::Dummy;
/// let target = (Proc::CURRENT, Cpu::ALL);
/// let mut opts = Opts::default();
/// opts.extra_record.cgroup = true;
///
/// let counter = Counter::new(event, target, opts).unwrap();
/// let sampler = counter.sampler(5).unwrap();
///
/// counter.enable().unwrap();
/// let path = format!("/sys/fs/cgroup/{}", uuid::Uuid::new_v4());
/// std::fs::create_dir(&path).unwrap();
/// std::fs::remove_dir(&path).unwrap();
///
/// # let mut cgroup_record = false;
/// for it in sampler.iter() {
/// println!("{:-?}", it);
/// # use perf_event_open::sample::record::Record;
/// # if let Record::Cgroup(c) = &it.1 {
/// # use std::path::Path;
/// # assert_eq!(
/// # Path::new(&c.path.to_string_lossy().to_string())
/// # .file_name()
/// # .unwrap(),
/// # Path::new(&path).file_name().unwrap()
/// # );
/// # cgroup_record = true;
/// # }
/// }
/// # assert!(cgroup_record);
/// ```
///
/// Since `linux-5.7`: <https://github.com/torvalds/linux/commit/96aaab686505c449e24d76e76507290dcc30e008>
from!;
debug!;