File tree Expand file tree Collapse file tree 2 files changed +28
-1
lines changed Expand file tree Collapse file tree 2 files changed +28
-1
lines changed Original file line number Diff line number Diff line change @@ -214,9 +214,31 @@ pub fn debugfs_mount() -> Result<std::path::PathBuf> {
214214 mounts. into_iter ( ) . next ( ) . context ( "No debugfs mount found" )
215215}
216216
217+ pub fn tracer_available ( tracer : & str ) -> Result < bool > {
218+ let base_path = tracefs_mount ( ) . unwrap_or_else ( |_| debugfs_mount ( ) . unwrap ( ) . join ( "tracing" ) ) ;
219+ let file = match std:: fs:: File :: open ( base_path. join ( "available_tracers" ) ) {
220+ Ok ( f) => f,
221+ Err ( _) => return Ok ( false ) ,
222+ } ;
223+ let reader = std:: io:: BufReader :: new ( file) ;
224+
225+ for line in reader. lines ( ) {
226+ for tc in line. unwrap ( ) . split_whitespace ( ) {
227+ if tracer == tc {
228+ return Ok ( true ) ;
229+ }
230+ }
231+ }
232+
233+ Ok ( false )
234+ }
235+
217236pub fn tracepoint_exists ( tracepoint : & str ) -> Result < bool > {
218237 let base_path = tracefs_mount ( ) . unwrap_or_else ( |_| debugfs_mount ( ) . unwrap ( ) . join ( "tracing" ) ) ;
219- let file = std:: fs:: File :: open ( base_path. join ( "available_events" ) ) ?;
238+ let file = match std:: fs:: File :: open ( base_path. join ( "available_events" ) ) {
239+ Ok ( f) => f,
240+ Err ( _) => return Ok ( false ) ,
241+ } ;
220242 let reader = std:: io:: BufReader :: new ( file) ;
221243
222244 for line in reader. lines ( ) {
Original file line number Diff line number Diff line change @@ -455,6 +455,11 @@ impl<'a> Scheduler<'a> {
455455 ( "futex_unlock_pi" , & skel. progs. fexit_futex_unlock_pi) ,
456456 ] ;
457457
458+ if compat:: tracer_available ( "function_graph" ) ? == false {
459+ info ! ( "Ftrace is not enabled in the kernel." ) ;
460+ return Ok ( false ) ;
461+ }
462+
458463 compat:: cond_kprobes_enable ( ftraces)
459464 }
460465
You can’t perform that action at this time.
0 commit comments