public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Arnaldo Carvalho de Melo <acme@kernel.org>
To: Changbin Du <changbin.du@gmail.com>
Cc: Jiri Olsa <jolsa@redhat.com>,
	Peter Zijlstra <peterz@infradead.org>,
	Ingo Molnar <mingo@redhat.com>,
	Namhyung Kim <namhyung@kernel.org>,
	Steven Rostedt <rostedt@goodmis.org>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v8 13/18] perf ftrace: add support for trace option tracing_thresh
Date: Fri, 14 Aug 2020 09:33:10 -0300	[thread overview]
Message-ID: <20200814123310.GC13995@kernel.org> (raw)
In-Reply-To: <20200808023141.14227-14-changbin.du@gmail.com>

Em Sat, Aug 08, 2020 at 10:31:36AM +0800, Changbin Du escreveu:
> This adds an option '--graph-opts thresh' to setup trace duration
> threshold for funcgraph tracer.

Applied, please consider making --duration an alias for this, as this is
also available in 'perf trace':

[root@quaco ~]# perf trace --duration 500 --max-events=5
   369.860 gnome-shell/2084 poll(ufds: 0x559577983080, nfds: 21, timeout_msecs: 7194) = 1
   493.654 pool-geoclue/386046 futex(uaddr: 0x56024843b610, op: WAIT|PRIVATE_FLAG, val: 1201, utime: 0x7f32bd7f9cc0) = -1 ETIMEDOUT (Connection timed out)
    71.604 WebRTC_Worker/111634 futex(uaddr: 0x7fb4c364d608, op: WAIT_BITSET|PRIVATE_FLAG, val: 0, utime: 0x7fb4c364d410, val3: MATCH_ANY) = -1 ETIMEDOUT (Connection timed out)
   601.645 pool-gsd-smart/2469 clock_nanosleep(which_clock: 0, flags: 0, rqtp: 0x7fb82cbd1cf0, rmtp: 0x7fb82cbd1d00) = 0
   623.823 chromium-brows/92363 futex(uaddr: 0x7ffcfd064e38, op: WAIT_BITSET|PRIVATE_FLAG, val: 0, utime: 0x7ffcfd064c40, val3: MATCH_ANY) = -1 ETIMEDOUT (Connection timed out)
[root@quaco ~]#

  $ perf trace -h duration

        --duration <float>
                          show only events with duration > N.M ms

  $

This way one would be able to do:

  # perf trace --duration N.M

To see at syscall level, then add 'f':

  # perf ftrace --duration N.M

To see at kernel function level. Switching from one perf tool to another
with such ease is the main objective here, I'd say :-)

- Arnaldo
 
> $ sudo ./perf ftrace -G '*' --graph-opts thresh=100
>  3) ! 184.060 us  |    } /* schedule */
>  3) ! 185.600 us  |  } /* exit_to_usermode_loop */
>  2) ! 225.989 us  |    } /* schedule_idle */
>  2) # 4140.051 us |  } /* do_idle */
> 
> Signed-off-by: Changbin Du <changbin.du@gmail.com>
> ---
>  tools/perf/Documentation/perf-ftrace.txt |  1 +
>  tools/perf/builtin-ftrace.c              | 26 +++++++++++++++++++++++-
>  2 files changed, 26 insertions(+), 1 deletion(-)
> 
> diff --git a/tools/perf/Documentation/perf-ftrace.txt b/tools/perf/Documentation/perf-ftrace.txt
> index a2056aaf2ece..6fa927e5971b 100644
> --- a/tools/perf/Documentation/perf-ftrace.txt
> +++ b/tools/perf/Documentation/perf-ftrace.txt
> @@ -107,6 +107,7 @@ OPTIONS
>  	  nosleep-time - Measure on-CPU time only for function_graph tracer.
>  	  noirqs       - Ignore functions that happen inside interrupt.
>  	  verbose      - Show process names, PIDs, timestamps, etc.
> +	  thresh=<n>   - Setup trace duration threshold in microseconds.
>  
>  SEE ALSO
>  --------
> diff --git a/tools/perf/builtin-ftrace.c b/tools/perf/builtin-ftrace.c
> index 8ee5287bd84a..ca61f8b8bbf6 100644
> --- a/tools/perf/builtin-ftrace.c
> +++ b/tools/perf/builtin-ftrace.c
> @@ -48,6 +48,7 @@ struct perf_ftrace {
>  	int			graph_nosleep_time;
>  	int			graph_noirqs;
>  	int			graph_verbose;
> +	int			graph_thresh;
>  };
>  
>  struct filter_entry {
> @@ -234,6 +235,9 @@ static int reset_tracing_files(struct perf_ftrace *ftrace __maybe_unused)
>  	if (write_tracing_file("max_graph_depth", "0") < 0)
>  		return -1;
>  
> +	if (write_tracing_file("tracing_thresh", "0") < 0)
> +		return -1;
> +
>  	reset_tracing_filters();
>  	reset_tracing_options(ftrace);
>  	return 0;
> @@ -446,6 +450,20 @@ static int set_tracing_funcgraph_verbose(struct perf_ftrace *ftrace)
>  	return 0;
>  }
>  
> +static int set_tracing_thresh(struct perf_ftrace *ftrace)
> +{
> +	int ret;
> +
> +	if (ftrace->graph_thresh == 0)
> +		return 0;
> +
> +	ret = write_tracing_file_int("tracing_thresh", ftrace->graph_thresh);
> +	if (ret < 0)
> +		return ret;
> +
> +	return 0;
> +}
> +
>  static int __cmd_ftrace(struct perf_ftrace *ftrace, int argc, const char **argv)
>  {
>  	char *trace_file;
> @@ -545,6 +563,11 @@ static int __cmd_ftrace(struct perf_ftrace *ftrace, int argc, const char **argv)
>  		goto out_reset;
>  	}
>  
> +	if (set_tracing_thresh(ftrace) < 0) {
> +		pr_err("failed to set tracing thresh\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;
> @@ -727,6 +750,7 @@ static int parse_graph_tracer_opts(const struct option *opt,
>  		{ .name = "nosleep-time",	.value_ptr = &ftrace->graph_nosleep_time },
>  		{ .name = "noirqs",		.value_ptr = &ftrace->graph_noirqs },
>  		{ .name = "verbose",		.value_ptr = &ftrace->graph_verbose },
> +		{ .name = "thresh",		.value_ptr = &ftrace->graph_thresh },
>  		{ .name = NULL, }
>  	};
>  
> @@ -798,7 +822,7 @@ int cmd_ftrace(int argc, const char **argv)
>  	OPT_INTEGER('D', "graph-depth", &ftrace.graph_depth,
>  		    "Max depth for function graph tracer"),
>  	OPT_CALLBACK(0, "graph-opts", &ftrace, "options",
> -		     "graph tracer options, available options: nosleep-time,noirqs,verbose",
> +		     "graph tracer options, available options: nosleep-time,noirqs,verbose,thresh=<n>",
>  		     parse_graph_tracer_opts),
>  	OPT_CALLBACK('m', "buffer-size", &ftrace.percpu_buffer_size, "size",
>  		     "size of per cpu buffer", parse_buffer_size),
> -- 
> 2.25.1
> 

-- 

- Arnaldo

  reply	other threads:[~2020-08-14 12:33 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-08  2:31 [PATCH v8 00/18] [PATCH v7 00/18] perf: ftrace enhancement Changbin Du
2020-08-08  2:31 ` [PATCH v8 01/18] perf ftrace: select function/function_graph tracer automatically Changbin Du
2020-08-08  2:31 ` [PATCH v8 02/18] perf ftrace: add option '-F/--funcs' to list available functions Changbin Du
2020-08-14 11:35   ` Arnaldo Carvalho de Melo
2020-08-20 15:18     ` Changbin Du
2020-08-08  2:31 ` [PATCH v8 03/18] perf ftrace: factor out function write_tracing_file_int() Changbin Du
2020-08-08  2:31 ` [PATCH v8 04/18] perf ftrace: add option '-m/--buffer-size' to set per-cpu buffer size Changbin Du
2020-08-14 11:53   ` Arnaldo Carvalho de Melo
2020-08-14 12:12     ` Arnaldo Carvalho de Melo
2020-08-14 12:58       ` Arnaldo Carvalho de Melo
2020-08-08  2:31 ` [PATCH v8 05/18] perf ftrace: show trace column header Changbin Du
2020-08-14 11:56   ` Arnaldo Carvalho de Melo
2020-08-14 11:57     ` Arnaldo Carvalho de Melo
2020-08-08  2:31 ` [PATCH v8 06/18] perf ftrace: add option '--inherit' to trace children processes Changbin Du
2020-08-14 12:12   ` Arnaldo Carvalho de Melo
2020-08-08  2:31 ` [PATCH v8 07/18] perf: util: add general function to parse sublevel options Changbin Du
2020-08-08  2:31 ` [PATCH v8 08/18] perf ftrace: add support for tracing option 'func_stack_trace' Changbin Du
2020-08-14 12:24   ` Arnaldo Carvalho de Melo
2020-08-20 15:15     ` Changbin Du
2020-08-08  2:31 ` [PATCH v8 09/18] perf ftrace: add support for trace option sleep-time Changbin Du
2020-08-14 12:26   ` Arnaldo Carvalho de Melo
2020-08-08  2:31 ` [PATCH v8 10/18] perf ftrace: add support for trace option funcgraph-irqs Changbin Du
2020-08-14 12:27   ` Arnaldo Carvalho de Melo
2020-08-08  2:31 ` [PATCH v8 11/18] perf ftrace: add support for tracing option 'irq-info' Changbin Du
2020-08-14 12:28   ` Arnaldo Carvalho de Melo
2020-08-20 15:09     ` Changbin Du
2020-08-08  2:31 ` [PATCH v8 12/18] perf ftrace: add option 'verbose' to show more info for graph tracer Changbin Du
2020-08-08  2:31 ` [PATCH v8 13/18] perf ftrace: add support for trace option tracing_thresh Changbin Du
2020-08-14 12:33   ` Arnaldo Carvalho de Melo [this message]
2020-08-20 15:08     ` Changbin Du
2020-08-08  2:31 ` [PATCH v8 14/18] perf: ftrace: allow set graph depth by '--graph-opts' Changbin Du
2020-08-08  2:31 ` [PATCH v8 15/18] perf ftrace: add option -D/--delay to delay tracing Changbin Du
2020-08-08  2:31 ` [PATCH v8 16/18] perf ftrace: add option --tid to filter by thread id Changbin Du
2020-08-08  2:31 ` [PATCH v8 17/18] perf: ftrace: Add set_tracing_options() to set all trace options Changbin Du
2020-08-08  2:31 ` [PATCH v8 18/18] perf ftrace: add change log Changbin Du
2020-08-14 12:38 ` [PATCH v8 00/18] [PATCH v7 00/18] perf: ftrace enhancement Arnaldo Carvalho de Melo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200814123310.GC13995@kernel.org \
    --to=acme@kernel.org \
    --cc=changbin.du@gmail.com \
    --cc=jolsa@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=namhyung@kernel.org \
    --cc=peterz@infradead.org \
    --cc=rostedt@goodmis.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox