File tree 3 files changed +14
-1
lines changed
3 files changed +14
-1
lines changed Original file line number Diff line number Diff line change @@ -66,6 +66,11 @@ pub enum PerfEventScope {
66
66
/// process id
67
67
pid : u32 ,
68
68
} ,
69
+ /// one process, any cpu, including child processes
70
+ OneProcessIncludingChildren {
71
+ /// process id
72
+ pid : u32 ,
73
+ } ,
69
74
/// one process, one cpu
70
75
OneProcessOneCpu {
71
76
/// cpu id
@@ -157,6 +162,7 @@ impl PerfEvent {
157
162
PerfEventScope :: OneProcessAnyCpu { pid } => ( pid as i32 , -1 ) ,
158
163
PerfEventScope :: OneProcessOneCpu { cpu, pid } => ( pid as i32 , cpu as i32 ) ,
159
164
PerfEventScope :: AllProcessesOneCpu { cpu } => ( -1 , cpu as i32 ) ,
165
+ PerfEventScope :: OneProcessIncludingChildren { pid } => ( pid as i32 , -1 ) ,
160
166
} ;
161
167
let fd = perf_event_open (
162
168
perf_type as u32 ,
@@ -167,6 +173,7 @@ impl PerfEvent {
167
173
sample_frequency,
168
174
false ,
169
175
0 ,
176
+ matches ! ( scope, PerfEventScope :: OneProcessIncludingChildren { .. } ) ,
170
177
)
171
178
. map_err ( |( _code, io_error) | SyscallError {
172
179
call : "perf_event_open" ,
Original file line number Diff line number Diff line change @@ -25,14 +25,15 @@ pub(crate) fn perf_event_open(
25
25
sample_frequency : Option < u64 > ,
26
26
wakeup : bool ,
27
27
flags : u32 ,
28
+ inherit : bool ,
28
29
) -> SysResult < OwnedFd > {
29
30
let mut attr = unsafe { mem:: zeroed :: < perf_event_attr > ( ) } ;
30
31
31
32
attr. config = config;
32
33
attr. size = mem:: size_of :: < perf_event_attr > ( ) as u32 ;
33
34
attr. type_ = perf_type;
34
35
attr. sample_type = PERF_SAMPLE_RAW as u64 ;
35
- // attr.inherits = if pid > 0 { 1 } else { 0 };
36
+ attr. set_inherit ( if inherit { 1 } else { 0 } ) ;
36
37
attr. __bindgen_anon_2 . wakeup_events = u32:: from ( wakeup) ;
37
38
38
39
if let Some ( frequency) = sample_frequency {
@@ -55,6 +56,7 @@ pub(crate) fn perf_event_open_bpf(cpu: c_int) -> SysResult<OwnedFd> {
55
56
None ,
56
57
true ,
57
58
PERF_FLAG_FD_CLOEXEC ,
59
+ false ,
58
60
)
59
61
}
60
62
Original file line number Diff line number Diff line change @@ -3989,6 +3989,8 @@ pub aya::programs::perf_event::PerfEventScope::CallingProcessOneCpu
3989
3989
pub aya::programs::perf_event::PerfEventScope::CallingProcessOneCpu::cpu: u32
3990
3990
pub aya::programs::perf_event::PerfEventScope::OneProcessAnyCpu
3991
3991
pub aya::programs::perf_event::PerfEventScope::OneProcessAnyCpu::pid: u32
3992
+ pub aya::programs::perf_event::PerfEventScope::OneProcessIncludingChildren
3993
+ pub aya::programs::perf_event::PerfEventScope::OneProcessIncludingChildren::pid: u32
3992
3994
pub aya::programs::perf_event::PerfEventScope::OneProcessOneCpu
3993
3995
pub aya::programs::perf_event::PerfEventScope::OneProcessOneCpu::cpu: u32
3994
3996
pub aya::programs::perf_event::PerfEventScope::OneProcessOneCpu::pid: u32
@@ -5214,6 +5216,8 @@ pub aya::programs::PerfEventScope::CallingProcessOneCpu
5214
5216
pub aya::programs::PerfEventScope::CallingProcessOneCpu::cpu: u32
5215
5217
pub aya::programs::PerfEventScope::OneProcessAnyCpu
5216
5218
pub aya::programs::PerfEventScope::OneProcessAnyCpu::pid: u32
5219
+ pub aya::programs::PerfEventScope::OneProcessIncludingChildren
5220
+ pub aya::programs::PerfEventScope::OneProcessIncludingChildren::pid: u32
5217
5221
pub aya::programs::PerfEventScope::OneProcessOneCpu
5218
5222
pub aya::programs::PerfEventScope::OneProcessOneCpu::cpu: u32
5219
5223
pub aya::programs::PerfEventScope::OneProcessOneCpu::pid: u32
You can’t perform that action at this time.
0 commit comments