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;
12use crate :: bindings:: uapi:: linux:: bpf:: {
23 bpf_map_type, BPF_PROG_TYPE_TRACEPOINT ,
34} ;
5+ use crate :: ffi;
6+ use crate :: map:: RexPerfEventArray ;
47use crate :: prog_type:: rex_prog;
58use crate :: task_struct:: TaskStruct ;
9+ use crate :: utils:: { to_result, NoRef , PerfEventMaskedCPU , PerfEventStreamer } ;
610use crate :: Result ;
711
812use super :: {
@@ -65,3 +69,26 @@ impl<C: TracepointContext + 'static> rex_prog for tracepoint<C> {
6569 ( ( self . prog ) ( self , newctx) ) . unwrap_or_else ( |e| e) as u32
6670 }
6771}
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