lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20200614111549.57lqs5tulu4frmgr@mail.google.com>
Date:   Sun, 14 Jun 2020 19:15:49 +0800
From:   Changbin Du <changbin.du@...il.com>
To:     Arnaldo Carvalho de Melo <arnaldo.melo@...il.com>
Cc:     Changbin Du <changbin.du@...il.com>, Jiri Olsa <jolsa@...hat.com>,
        Peter Zijlstra <peterz@...radead.org>,
        Ingo Molnar <mingo@...hat.com>,
        Namhyung Kim <namhyung@...nel.org>,
        Steven Rostedt <rostedt@...dmis.org>,
        linux-kernel@...r.kernel.org
Subject: Re: [PATCH 11/19] perf ftrace: add option '-u/--userstacktrace' to
 show userspace stacktrace

On Wed, May 20, 2020 at 06:07:41PM -0300, Arnaldo Carvalho de Melo wrote:
> Em Sun, May 10, 2020 at 11:06:20PM +0800, Changbin Du escreveu:
> > This adds an option ''-u/--userstacktrace' for function tracer to display
> > userspace back trace.
> 
> Probably we should have this as a term, an option to --call-graph?
> 
> For --call-graph the way to suppress this is to ask for the event to be
> in the kernel only, i.e. something like:
> 
> 	perf record -e cycles:k --call-graph
> 
> So perhaps we should have something like:
> 
> 	perf ftrace --call-graph 
> 
> With some default, possibly a bit different than the other perf tools,
> just including the kernel, and accepting:
> 
> 	perf ftrace --call-graph
> 	perf ftrace --call-graph k
> 	perf ftrace --call-graph u
> 	perf ftrace --call-graph uk
> 
> - Arnaldo
>
I just found userstacktrace is not supported by ftrace yet. It is not
hard to add this feature in kernel and I have done it locally. So I will
drop this option before it is upstreamed.

> > Signed-off-by: Changbin Du <changbin.du@...il.com>
> > ---
> >  tools/perf/builtin-ftrace.c | 24 ++++++++++++++++++++++++
> >  1 file changed, 24 insertions(+)
> > 
> > diff --git a/tools/perf/builtin-ftrace.c b/tools/perf/builtin-ftrace.c
> > index 2ef5d1c4b23c..ab76ba66bd9e 100644
> > --- a/tools/perf/builtin-ftrace.c
> > +++ b/tools/perf/builtin-ftrace.c
> > @@ -40,6 +40,7 @@ struct perf_ftrace {
> >  	struct list_head	nograph_funcs;
> >  	int			graph_depth;
> >  	bool			func_stack_trace;
> > +	bool			userstacktrace;
> >  	bool			nosleep_time;
> >  	bool			nofuncgraph_irqs;
> >  	bool			funcgraph_tail;
> > @@ -197,6 +198,8 @@ static void reset_tracing_options(struct perf_ftrace *ftrace __maybe_unused)
> >  	write_tracing_option_file("funcgraph-proc", "0");
> >  	write_tracing_option_file("funcgraph-abstime", "0");
> >  	write_tracing_option_file("irq-info", "0");
> > +	write_tracing_option_file("userstacktrace", "0");
> > +	write_tracing_option_file("sym-userobj", "0");
> >  }
> >  
> >  static int reset_tracing_files(struct perf_ftrace *ftrace __maybe_unused)
> > @@ -287,6 +290,20 @@ static int set_tracing_func_stack_trace(struct perf_ftrace *ftrace)
> >  	return 0;
> >  }
> >  
> > +static int set_tracing_userstacktrace(struct perf_ftrace *ftrace)
> > +{
> > +	if (!ftrace->userstacktrace)
> > +		return 0;
> > +
> > +	if (write_tracing_option_file("userstacktrace", "1") < 0)
> > +		return -1;
> > +
> > +	if (write_tracing_option_file("sym-userobj", "1") < 0)
> > +		return -1;
> > +
> > +	return 0;
> > +}
> > +
> >  static int reset_tracing_cpu(void)
> >  {
> >  	struct perf_cpu_map *cpumap = perf_cpu_map__new(NULL);
> > @@ -482,6 +499,11 @@ static int __cmd_ftrace(struct perf_ftrace *ftrace, int argc, const char **argv)
> >  		goto out_reset;
> >  	}
> >  
> > +	if (set_tracing_userstacktrace(ftrace) < 0) {
> > +		pr_err("failed to set tracing option userstacktrace\n");
> > +		goto out_reset;
> > +	}
> > +
> >  	if (set_tracing_filters(ftrace) < 0) {
> >  		pr_err("failed to set tracing filters\n");
> >  		goto out_reset;
> > @@ -644,6 +666,8 @@ int cmd_ftrace(int argc, const char **argv)
> >  		     "do not trace given functions", parse_filter_func),
> >  	OPT_BOOLEAN('s', "func-stack-trace", &ftrace.func_stack_trace,
> >  		    "Show kernel stack trace for function tracer"),
> > +	OPT_BOOLEAN('u', "userstacktrace", &ftrace.userstacktrace,
> > +		    "Show stacktrace of the current user space thread"),
> >  	OPT_CALLBACK_DEFAULT('G', "graph-funcs", &ftrace.graph_funcs, "func",
> >  		     "Set graph filter on given functions (imply to use function_graph tracer)",
> >  		     parse_filter_func, "*"),
> > -- 
> > 2.25.1
> > 
> 
> -- 
> 
> - Arnaldo

-- 
Cheers,
Changbin Du

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ