@@ -41,6 +41,7 @@ struct perf_ftrace {
41
41
struct list_head nograph_funcs ;
42
42
int graph_depth ;
43
43
unsigned long percpu_buffer_size ;
44
+ bool inherit ;
44
45
};
45
46
46
47
struct filter_entry {
@@ -182,9 +183,27 @@ static int write_tracing_file_int(const char *name, int value)
182
183
return 0 ;
183
184
}
184
185
186
+ static int write_tracing_option_file (const char * name , const char * val )
187
+ {
188
+ char * file ;
189
+ int ret ;
190
+
191
+ if (asprintf (& file , "options/%s" , name ) < 0 )
192
+ return -1 ;
193
+
194
+ ret = __write_tracing_file (file , val , false);
195
+ free (file );
196
+ return ret ;
197
+ }
198
+
185
199
static int reset_tracing_cpu (void );
186
200
static void reset_tracing_filters (void );
187
201
202
+ static void reset_tracing_options (struct perf_ftrace * ftrace __maybe_unused )
203
+ {
204
+ write_tracing_option_file ("function-fork" , "0" );
205
+ }
206
+
188
207
static int reset_tracing_files (struct perf_ftrace * ftrace __maybe_unused )
189
208
{
190
209
if (write_tracing_file ("tracing_on" , "0" ) < 0 )
@@ -203,6 +222,7 @@ static int reset_tracing_files(struct perf_ftrace *ftrace __maybe_unused)
203
222
return -1 ;
204
223
205
224
reset_tracing_filters ();
225
+ reset_tracing_options (ftrace );
206
226
return 0 ;
207
227
}
208
228
@@ -341,6 +361,17 @@ static int set_tracing_percpu_buffer_size(struct perf_ftrace *ftrace)
341
361
return 0 ;
342
362
}
343
363
364
+ static int set_tracing_trace_inherit (struct perf_ftrace * ftrace )
365
+ {
366
+ if (!ftrace -> inherit )
367
+ return 0 ;
368
+
369
+ if (write_tracing_option_file ("function-fork" , "1" ) < 0 )
370
+ return -1 ;
371
+
372
+ return 0 ;
373
+ }
374
+
344
375
static int __cmd_ftrace (struct perf_ftrace * ftrace , int argc , const char * * argv )
345
376
{
346
377
char * trace_file ;
@@ -410,6 +441,11 @@ static int __cmd_ftrace(struct perf_ftrace *ftrace, int argc, const char **argv)
410
441
goto out_reset ;
411
442
}
412
443
444
+ if (set_tracing_trace_inherit (ftrace ) < 0 ) {
445
+ pr_err ("failed to set tracing option function-fork\n" );
446
+ goto out_reset ;
447
+ }
448
+
413
449
if (write_tracing_file ("current_tracer" , ftrace -> tracer ) < 0 ) {
414
450
pr_err ("failed to set current_tracer to %s\n" , ftrace -> tracer );
415
451
goto out_reset ;
@@ -618,6 +654,8 @@ int cmd_ftrace(int argc, const char **argv)
618
654
"Max depth for function graph tracer" ),
619
655
OPT_CALLBACK ('m' , "buffer-size" , & ftrace .percpu_buffer_size , "size" ,
620
656
"size of per cpu buffer" , parse_buffer_size ),
657
+ OPT_BOOLEAN (0 , "inherit" , & ftrace .inherit ,
658
+ "trace children processes" ),
621
659
OPT_END ()
622
660
};
623
661
0 commit comments