From: Arnaldo Carvalho de Melo <acme@kernel.org>
To: charles.baylis@linaro.org
Cc: peterz@infradead.org, mingo@redhat.com,
alexander.shishkin@linux.intel.com, linux-kernel@vger.kernel.org,
maxim.kuvyrkov@linaro.org
Subject: Re: [PATCH] perf report: Allow sorting by symbol size.
Date: Fri, 24 Feb 2017 16:22:02 -0300 [thread overview]
Message-ID: <20170224192202.GK3595@kernel.org> (raw)
In-Reply-To: <1487943176-13840-1-git-send-email-charles.baylis@linaro.org>
Em Fri, Feb 24, 2017 at 01:32:56PM +0000, charles.baylis@linaro.org escreveu:
> From: Charles Baylis <charles.baylis@linaro.org>
>
> Add new sort key 'symbol_size' to allow user to sort by
> symbol size, or (more usefully) display the symbol size
> using --fields=...,symbol_size.
>
> Signed-off-by: Charles Baylis <charles.baylis@linaro.org>
> ---
> tools/perf/Documentation/perf-report.txt | 1 +
> tools/perf/util/hist.h | 1 +
> tools/perf/util/sort.c | 46 ++++++++++++++++++++++++++++++++
> tools/perf/util/sort.h | 1 +
> 4 files changed, 49 insertions(+)
>
> diff --git a/tools/perf/Documentation/perf-report.txt b/tools/perf/Documentation/perf-report.txt
> index f2914f0..d2a8c15 100644
> --- a/tools/perf/Documentation/perf-report.txt
> +++ b/tools/perf/Documentation/perf-report.txt
> @@ -76,6 +76,7 @@ OPTIONS
> - pid: command and tid of the task
> - dso: name of library or module executed at the time of sample
> - symbol: name of function executed at the time of sample
> + - symbol_size: size of function executed at the time of sample
> - parent: name of function matched to the parent regex filter. Unmatched
> entries are displayed as "[other]".
> - cpu: cpu number the task ran at the time of sample
> diff --git a/tools/perf/util/hist.h b/tools/perf/util/hist.h
> index 28c216e..2e839bf 100644
> --- a/tools/perf/util/hist.h
> +++ b/tools/perf/util/hist.h
> @@ -57,6 +57,7 @@ enum hist_column {
> HISTC_SRCLINE_FROM,
> HISTC_SRCLINE_TO,
> HISTC_TRACE,
> + HISTC_SYM_SIZE,
> HISTC_NR_COLS, /* Last entry */
> };
>
> diff --git a/tools/perf/util/sort.c b/tools/perf/util/sort.c
> index df622f4..0ad397c 100644
> --- a/tools/perf/util/sort.c
> +++ b/tools/perf/util/sort.c
> @@ -1396,6 +1396,51 @@ struct sort_entry sort_transaction = {
> .se_width_idx = HISTC_TRANSACTION,
> };
>
> +/* --sort symbol_size */
> +
> +static int64_t _sort__sym_size_cmp(struct symbol *sym_l, struct symbol *sym_r)
> +{
> + int64_t size_l = sym_l != NULL ? sym_l->end - sym_l->start : 0;
> + int64_t size_r = sym_r != NULL ? sym_r->end - sym_r->start : 0;
We have symbol__size(), no need to open code it, I'll fix it
> +
> + return size_l < size_r ? -1 :
> + size_l == size_r ? 0 : 1;
> +}
> +
> +static int64_t
> +sort__sym_size_cmp(struct hist_entry *left, struct hist_entry *right)
> +{
> + return _sort__sym_size_cmp(right->ms.sym, left->ms.sym);
> +}
> +
> +static int _hist_entry__sym_size_snprintf(struct symbol *sym, char *bf,
> + size_t bf_size, unsigned int width)
> +{
> + if (sym) {
> + int64_t sym_size = sym->end - sym->start;
Ditto
> +
> + return repsep_snprintf(bf, bf_size, "%*lld", width,
> + (long long)sym_size);
Humm, why use lld instead of plain d, that way you can get rid of that
(long long)? I'm fixing this as well
> + } else {
> + return repsep_snprintf(bf, bf_size, "%*s", width,
> + "unknown");
> + }
> +}
> +
> +static int hist_entry__sym_size_snprintf(struct hist_entry *he, char *bf,
> + size_t size, unsigned int width)
> +{
> + return _hist_entry__sym_size_snprintf(he->ms.sym, bf, size, width);
> +}
> +
> +struct sort_entry sort_sym_size = {
> + .se_header = "Symbol size",
> + .se_cmp = sort__sym_size_cmp,
> + .se_snprintf = hist_entry__sym_size_snprintf,
> + .se_width_idx = HISTC_SYM_SIZE,
> +};
> +
> +
> struct sort_dimension {
> const char *name;
> struct sort_entry *entry;
> @@ -1418,6 +1463,7 @@ static struct sort_dimension common_sort_dimensions[] = {
> DIM(SORT_GLOBAL_WEIGHT, "weight", sort_global_weight),
> DIM(SORT_TRANSACTION, "transaction", sort_transaction),
> DIM(SORT_TRACE, "trace", sort_trace),
> + DIM(SORT_SYM_SIZE, "symbol_size", sort_sym_size),
> };
>
> #undef DIM
> diff --git a/tools/perf/util/sort.h b/tools/perf/util/sort.h
> index 7aff317..acb2c57 100644
> --- a/tools/perf/util/sort.h
> +++ b/tools/perf/util/sort.h
> @@ -211,6 +211,7 @@ enum sort_type {
> SORT_GLOBAL_WEIGHT,
> SORT_TRANSACTION,
> SORT_TRACE,
> + SORT_SYM_SIZE,
>
> /* branch stack specific sort keys */
> __SORT_BRANCH_STACK,
> --
> 2.7.4
next prev parent reply other threads:[~2017-02-24 19:22 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-02-24 13:32 [PATCH] perf report: Allow sorting by symbol size charles.baylis
2017-02-24 13:35 ` Arnaldo Carvalho de Melo
2017-02-24 19:22 ` Arnaldo Carvalho de Melo [this message]
2017-02-25 13:06 ` Charles Baylis
2017-03-07 8:04 ` [tip:perf/core] perf tools: " tip-bot for Charles Baylis
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=20170224192202.GK3595@kernel.org \
--to=acme@kernel.org \
--cc=alexander.shishkin@linux.intel.com \
--cc=charles.baylis@linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=maxim.kuvyrkov@linaro.org \
--cc=mingo@redhat.com \
--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).