public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] perf ftrace: Add -O option to set trace option
@ 2017-09-15 11:19 changbin.du
  2017-09-26  6:03 ` Du, Changbin
  0 siblings, 1 reply; 2+ messages in thread
From: changbin.du @ 2017-09-15 11:19 UTC (permalink / raw)
  To: peterz, mingo, acme, alexander.shishkin; +Cc: linux-kernel, Changbin Du

From: Changbin Du <changbin.du@intel.com>

There are some trace options to control what gets printed in the trace
output or manipulate the tracers. This patch add a commandline option
to set it.

Example:
perf ftrace -t function -O noprint-parent --trace-funcs "__kmalloc" -a
            Xorg-1874  [002] ....  4107.182911: __kmalloc
            Xorg-1874  [002] ....  4107.182920: __kmalloc

perf ftrace -t function -O print-parent --trace-funcs "__kmalloc" -a
            Xorg-1874  [000] ....  3924.917243: __kmalloc <-drm_atomic_state_init
            Xorg-1874  [000] ....  3924.917251: __kmalloc <-drm_atomic_state_init

Signed-off-by: Changbin Du <changbin.du@intel.com>
---
 tools/perf/builtin-ftrace.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/tools/perf/builtin-ftrace.c b/tools/perf/builtin-ftrace.c
index 25a42ac..8b473e2 100644
--- a/tools/perf/builtin-ftrace.c
+++ b/tools/perf/builtin-ftrace.c
@@ -36,6 +36,7 @@ struct perf_ftrace {
 	struct list_head	graph_funcs;
 	struct list_head	nograph_funcs;
 	int			graph_depth;
+	const char		*trace_option;
 };
 
 struct filter_entry {
@@ -261,6 +262,17 @@ static int set_tracing_depth(struct perf_ftrace *ftrace)
 	return 0;
 }
 
+static int set_tracing_option(struct perf_ftrace *ftrace)
+{
+	if (ftrace->trace_option == NULL)
+		return 0;
+
+	if (write_tracing_file("trace_options", ftrace->trace_option) < 0)
+		return -1;
+
+	return 0;
+}
+
 static int __cmd_ftrace(struct perf_ftrace *ftrace, int argc, const char **argv)
 {
 	char *trace_file;
@@ -313,6 +325,11 @@ static int __cmd_ftrace(struct perf_ftrace *ftrace, int argc, const char **argv)
 		goto out_reset;
 	}
 
+	if (set_tracing_option(ftrace) < 0) {
+		pr_err("failed to set trace option\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;
@@ -456,6 +473,8 @@ int cmd_ftrace(int argc, const char **argv)
 		     "Set nograph filter on given functions", parse_filter_func),
 	OPT_INTEGER('D', "graph-depth", &ftrace.graph_depth,
 		    "Max depth for function graph tracer"),
+	OPT_STRING('O', "trace-option", &ftrace.trace_option, "option",
+		   "Set a trace option"),
 	OPT_END()
 	};
 
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] perf ftrace: Add -O option to set trace option
  2017-09-15 11:19 [PATCH] perf ftrace: Add -O option to set trace option changbin.du
@ 2017-09-26  6:03 ` Du, Changbin
  0 siblings, 0 replies; 2+ messages in thread
From: Du, Changbin @ 2017-09-26  6:03 UTC (permalink / raw)
  To: changbin.du; +Cc: peterz, mingo, acme, alexander.shishkin, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 2646 bytes --]


Ping for review status, thanks.

On Fri, Sep 15, 2017 at 07:19:31PM +0800, changbin.du@intel.com wrote:
> From: Changbin Du <changbin.du@intel.com>
> 
> There are some trace options to control what gets printed in the trace
> output or manipulate the tracers. This patch add a commandline option
> to set it.
> 
> Example:
> perf ftrace -t function -O noprint-parent --trace-funcs "__kmalloc" -a
>             Xorg-1874  [002] ....  4107.182911: __kmalloc
>             Xorg-1874  [002] ....  4107.182920: __kmalloc
> 
> perf ftrace -t function -O print-parent --trace-funcs "__kmalloc" -a
>             Xorg-1874  [000] ....  3924.917243: __kmalloc <-drm_atomic_state_init
>             Xorg-1874  [000] ....  3924.917251: __kmalloc <-drm_atomic_state_init
> 
> Signed-off-by: Changbin Du <changbin.du@intel.com>
> ---
>  tools/perf/builtin-ftrace.c | 19 +++++++++++++++++++
>  1 file changed, 19 insertions(+)
> 
> diff --git a/tools/perf/builtin-ftrace.c b/tools/perf/builtin-ftrace.c
> index 25a42ac..8b473e2 100644
> --- a/tools/perf/builtin-ftrace.c
> +++ b/tools/perf/builtin-ftrace.c
> @@ -36,6 +36,7 @@ struct perf_ftrace {
>  	struct list_head	graph_funcs;
>  	struct list_head	nograph_funcs;
>  	int			graph_depth;
> +	const char		*trace_option;
>  };
>  
>  struct filter_entry {
> @@ -261,6 +262,17 @@ static int set_tracing_depth(struct perf_ftrace *ftrace)
>  	return 0;
>  }
>  
> +static int set_tracing_option(struct perf_ftrace *ftrace)
> +{
> +	if (ftrace->trace_option == NULL)
> +		return 0;
> +
> +	if (write_tracing_file("trace_options", ftrace->trace_option) < 0)
> +		return -1;
> +
> +	return 0;
> +}
> +
>  static int __cmd_ftrace(struct perf_ftrace *ftrace, int argc, const char **argv)
>  {
>  	char *trace_file;
> @@ -313,6 +325,11 @@ static int __cmd_ftrace(struct perf_ftrace *ftrace, int argc, const char **argv)
>  		goto out_reset;
>  	}
>  
> +	if (set_tracing_option(ftrace) < 0) {
> +		pr_err("failed to set trace option\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;
> @@ -456,6 +473,8 @@ int cmd_ftrace(int argc, const char **argv)
>  		     "Set nograph filter on given functions", parse_filter_func),
>  	OPT_INTEGER('D', "graph-depth", &ftrace.graph_depth,
>  		    "Max depth for function graph tracer"),
> +	OPT_STRING('O', "trace-option", &ftrace.trace_option, "option",
> +		   "Set a trace option"),
>  	OPT_END()
>  	};
>  
> -- 
> 2.7.4
> 

-- 
Thanks,
Changbin Du

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 473 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2017-09-26  6:10 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-09-15 11:19 [PATCH] perf ftrace: Add -O option to set trace option changbin.du
2017-09-26  6:03 ` Du, Changbin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox