linux-perf-users.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Arnaldo Carvalho de Melo <acme@kernel.org>
To: Namhyung Kim <namhyung@kernel.org>
Cc: Jiri Olsa <jolsa@kernel.org>, Ingo Molnar <mingo@kernel.org>,
	Peter Zijlstra <peterz@infradead.org>,
	LKML <linux-kernel@vger.kernel.org>,
	Andi Kleen <ak@linux.intel.com>, Ian Rogers <irogers@google.com>,
	linux-perf-users@vger.kernel.org
Subject: Re: [PATCH] perf annotate: Add --percent-limit option
Date: Tue, 10 May 2022 14:39:14 -0300	[thread overview]
Message-ID: <YnqjQmgXebK4itXj@kernel.org> (raw)
In-Reply-To: <20220502232015.697243-1-namhyung@kernel.org>

Em Mon, May 02, 2022 at 04:20:15PM -0700, Namhyung Kim escreveu:
> Like in perf report and perf top, Add this option to limit the number
> of functions it displays based on the overhead value in percent.
> 
> This affects only stdio and stdio2 output modes.  Without this, it
> shows very long disassembly lines for every function in the data
> file.  If users don't want this behavior, they can set a value in
> percent to suppress that.

Thanks, applied.

- Arnaldo

 
> Signed-off-by: Namhyung Kim <namhyung@kernel.org>
> ---
>  tools/perf/Documentation/perf-annotate.txt |  5 +++++
>  tools/perf/builtin-annotate.c              | 24 ++++++++++++++++++++++
>  2 files changed, 29 insertions(+)
> 
> diff --git a/tools/perf/Documentation/perf-annotate.txt b/tools/perf/Documentation/perf-annotate.txt
> index 33c2521cba4a..18fcc52809fb 100644
> --- a/tools/perf/Documentation/perf-annotate.txt
> +++ b/tools/perf/Documentation/perf-annotate.txt
> @@ -147,6 +147,11 @@ include::itrace.txt[]
>  	The period/hits keywords set the base the percentage is computed
>  	on - the samples period or the number of samples (hits).
>  
> +--percent-limit::
> +	Do not show functions which have an overhead under that percent on
> +	stdio or stdio2 (Default: 0).  Note that this is about selection of
> +	functions to display, not about lines within the function.
> +
>  SEE ALSO
>  --------
>  linkperf:perf-record[1], linkperf:perf-report[1]
> diff --git a/tools/perf/builtin-annotate.c b/tools/perf/builtin-annotate.c
> index e65dc380be15..2ffe071dbcff 100644
> --- a/tools/perf/builtin-annotate.c
> +++ b/tools/perf/builtin-annotate.c
> @@ -54,6 +54,7 @@ struct perf_annotate {
>  	bool	   skip_missing;
>  	bool	   has_br_stack;
>  	bool	   group_set;
> +	float	   min_percent;
>  	const char *sym_hist_filter;
>  	const char *cpu_list;
>  	DECLARE_BITMAP(cpu_bitmap, MAX_NR_CPUS);
> @@ -324,6 +325,17 @@ static void hists__find_annotations(struct hists *hists,
>  		    (strcmp(he->ms.sym->name, ann->sym_hist_filter) != 0))
>  			goto find_next;
>  
> +		if (ann->min_percent) {
> +			float percent = 0;
> +			u64 total = hists__total_period(hists);
> +
> +			if (total)
> +				percent = 100.0 * he->stat.period / total;
> +
> +			if (percent < ann->min_percent)
> +				goto find_next;
> +		}
> +
>  		notes = symbol__annotation(he->ms.sym);
>  		if (notes->src == NULL) {
>  find_next:
> @@ -457,6 +469,16 @@ static int __cmd_annotate(struct perf_annotate *ann)
>  	return ret;
>  }
>  
> +static int parse_percent_limit(const struct option *opt, const char *str,
> +			       int unset __maybe_unused)
> +{
> +	struct perf_annotate *ann = opt->value;
> +	double pcnt = strtof(str, NULL);
> +
> +	ann->min_percent = pcnt;
> +	return 0;
> +}
> +
>  static const char * const annotate_usage[] = {
>  	"perf annotate [<options>]",
>  	NULL
> @@ -557,6 +579,8 @@ int cmd_annotate(int argc, const char **argv)
>  	OPT_CALLBACK(0, "percent-type", &annotate.opts, "local-period",
>  		     "Set percent type local/global-period/hits",
>  		     annotate_parse_percent_type),
> +	OPT_CALLBACK(0, "percent-limit", &annotate, "percent",
> +		     "Don't show entries under that percent", parse_percent_limit),
>  	OPT_CALLBACK_OPTARG(0, "itrace", &itrace_synth_opts, NULL, "opts",
>  			    "Instruction Tracing options\n" ITRACE_HELP,
>  			    itrace_parse_synth_opts),
> -- 
> 2.36.0.464.gb9c8b46e94-goog

-- 

- Arnaldo

      reply	other threads:[~2022-05-10 17:39 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-02 23:20 [PATCH] perf annotate: Add --percent-limit option Namhyung Kim
2022-05-10 17:39 ` Arnaldo Carvalho de Melo [this message]

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=YnqjQmgXebK4itXj@kernel.org \
    --to=acme@kernel.org \
    --cc=ak@linux.intel.com \
    --cc=irogers@google.com \
    --cc=jolsa@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=namhyung@kernel.org \
    --cc=peterz@infradead.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;
as well as URLs for NNTP newsgroup(s).