File tree Expand file tree Collapse file tree 1 file changed +27
-0
lines changed Expand file tree Collapse file tree 1 file changed +27
-0
lines changed Original file line number Diff line number Diff line change
1
+ use crate :: base_helper:: termination_check;
1
2
use crate :: bindings:: uapi:: linux:: bpf:: {
2
3
bpf_map_type, BPF_PROG_TYPE_TRACEPOINT ,
3
4
} ;
5
+ use crate :: ffi;
6
+ use crate :: map:: RexPerfEventArray ;
4
7
use crate :: prog_type:: rex_prog;
5
8
use crate :: task_struct:: TaskStruct ;
9
+ use crate :: utils:: { to_result, NoRef , PerfEventMaskedCPU , PerfEventStreamer } ;
6
10
use crate :: Result ;
7
11
8
12
use super :: {
@@ -65,3 +69,26 @@ impl<C: TracepointContext + 'static> rex_prog for tracepoint<C> {
65
69
( ( self . prog ) ( self , newctx) ) . unwrap_or_else ( |e| e) as u32
66
70
}
67
71
}
72
+
73
+ impl < C : TracepointContext + ' static > PerfEventStreamer for tracepoint < C > {
74
+ type Context = C ;
75
+ fn output_event < T : Copy + NoRef > (
76
+ & self ,
77
+ ctx : & Self :: Context ,
78
+ map : & ' static RexPerfEventArray < T > ,
79
+ data : & T ,
80
+ cpu : PerfEventMaskedCPU ,
81
+ ) -> Result {
82
+ let map_kptr = unsafe { core:: ptr:: read_volatile ( & map. kptr ) } ;
83
+ let ctx_ptr = ctx as * const C as * const ( ) ;
84
+ termination_check ! ( unsafe {
85
+ to_result!( ffi:: bpf_perf_event_output_tp(
86
+ ctx_ptr,
87
+ map_kptr,
88
+ cpu. masked_cpu,
89
+ data as * const T as * const ( ) ,
90
+ core:: mem:: size_of:: <T >( ) as u64
91
+ ) )
92
+ } )
93
+ }
94
+ }
You can’t perform that action at this time.
0 commit comments