Em Sun, May 10, 2020 at 11:06:21PM +0800, Changbin Du escreveu:
> This adds an option '--trace-children' to allow us trace children
> processes spawned by our target.

--inherit

- Arnaldo
 
> Signed-off-by: Changbin Du <[email protected]>
> ---
>  tools/perf/builtin-ftrace.c | 20 ++++++++++++++++++++
>  1 file changed, 20 insertions(+)
> 
> diff --git a/tools/perf/builtin-ftrace.c b/tools/perf/builtin-ftrace.c
> index ab76ba66bd9e..8fd95c109fe8 100644
> --- a/tools/perf/builtin-ftrace.c
> +++ b/tools/perf/builtin-ftrace.c
> @@ -46,6 +46,7 @@ struct perf_ftrace {
>       bool                    funcgraph_tail;
>       bool                    long_info;
>       unsigned                tracing_thresh;
> +     bool                    trace_children;
>  };
>  
>  struct filter_entry {
> @@ -200,6 +201,7 @@ static void reset_tracing_options(struct perf_ftrace 
> *ftrace __maybe_unused)
>       write_tracing_option_file("irq-info", "0");
>       write_tracing_option_file("userstacktrace", "0");
>       write_tracing_option_file("sym-userobj", "0");
> +     write_tracing_option_file("function-fork", "0");
>  }
>  
>  static int reset_tracing_files(struct perf_ftrace *ftrace __maybe_unused)
> @@ -441,6 +443,17 @@ static int set_tracing_funcgraph_tail(struct perf_ftrace 
> *ftrace)
>       return 0;
>  }
>  
> +static int set_tracing_trace_children(struct perf_ftrace *ftrace)
> +{
> +     if (!ftrace->trace_children)
> +             return 0;
> +
> +     if (write_tracing_option_file("function-fork", "1") < 0)
> +             return -1;
> +
> +     return 0;
> +}
> +
>  static int __cmd_ftrace(struct perf_ftrace *ftrace, int argc, const char 
> **argv)
>  {
>       char *trace_file;
> @@ -539,6 +552,11 @@ static int __cmd_ftrace(struct perf_ftrace *ftrace, int 
> argc, const char **argv)
>               goto out_reset;
>       }
>  
> +     if (set_tracing_trace_children(ftrace) < 0) {
> +             pr_err("failed to set tracing option function-fork\n");
> +             goto out_reset;
> +     }
> +
>       if (write_tracing_file("current_tracer", ftrace->tracer) < 0) {
>               pr_err("failed to set current_tracer to %s\n", ftrace->tracer);
>               goto out_reset;
> @@ -686,6 +704,8 @@ int cmd_ftrace(int argc, const char **argv)
>                   "Show process names, PIDs, timestamps, irq-info if 
> available"),
>       OPT_UINTEGER(0, "tracing-thresh", &ftrace.tracing_thresh,
>                    "Only show functions of which the duration is greater than 
> <n>µs"),
> +     OPT_BOOLEAN(0, "trace-children", &ftrace.trace_children,
> +                 "Trace children processes"),
>       OPT_END()
>       };
>  
> -- 
> 2.25.1
> 

-- 

- Arnaldo

Reply via email to