From: Namhyung Kim <namhyung@kernel.org>
To: Arnaldo Carvalho de Melo <acme@kernel.org>,
Ian Rogers <irogers@google.com>,
Kan Liang <kan.liang@linux.intel.com>
Cc: Jiri Olsa <jolsa@kernel.org>,
Adrian Hunter <adrian.hunter@intel.com>,
Peter Zijlstra <peterz@infradead.org>,
Ingo Molnar <mingo@kernel.org>,
LKML <linux-kernel@vger.kernel.org>,
linux-perf-users@vger.kernel.org,
Dmitry Vyukov <dvyukov@google.com>
Subject: Re: [PATCH 1/3] perf sort: Keep output fields in the same level
Date: Wed, 19 Mar 2025 17:36:57 -0700 [thread overview]
Message-ID: <Z9tjKcKvjYgbR6hb@google.com> (raw)
In-Reply-To: <20250307080829.354947-1-namhyung@kernel.org>
On Fri, Mar 07, 2025 at 12:08:27AM -0800, Namhyung Kim wrote:
> This is useful for hierarchy output mode where the first level is
> considered as output fields. We want them in the same level so that it
> can show only the remaining groups in the hierarchy.
>
> Before:
> $ perf report -s overhead,sample,period,comm,dso -H --stdio
> ...
> # Overhead Samples / Period / Command / Shared Object
> # ................. ..........................................
> #
> 100.00% 4035
> 100.00% 3835883066
> 100.00% perf
> 99.37% perf
> 0.50% ld-linux-x86-64.so.2
> 0.06% [unknown]
> 0.04% libc.so.6
> 0.02% libLLVM-16.so.1
>
> After:
> $ perf report -s overhead,sample,period,comm,dso -H --stdio
> ...
> # Overhead Samples Period Command / Shared Object
> # ....................................... .......................
> #
> 100.00% 4035 3835883066 perf
> 99.37% 4005 3811826223 perf
> 0.50% 19 19210014 ld-linux-x86-64.so.2
> 0.06% 8 2367089 [unknown]
> 0.04% 2 1720336 libc.so.6
> 0.02% 1 759404 libLLVM-16.so.1
>
> Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Ping! Anybody interested in this change? :)
Thanks,
Namhyung
> ---
> tools/perf/util/sort.c | 44 ++++++++++++++++++++++++++++++++++++++++++
> 1 file changed, 44 insertions(+)
>
> diff --git a/tools/perf/util/sort.c b/tools/perf/util/sort.c
> index f08fbc4bf0a2ce29..6b49d64854f5f986 100644
> --- a/tools/perf/util/sort.c
> +++ b/tools/perf/util/sort.c
> @@ -3720,6 +3720,34 @@ int sort_dimension__add(struct perf_hpp_list *list, const char *tok,
> return -ESRCH;
> }
>
> +/* This should match with sort_dimension__add() above */
> +static bool is_hpp_sort_key(const char *key)
> +{
> + unsigned i;
> +
> + for (i = 0; i < ARRAY_SIZE(arch_specific_sort_keys); i++) {
> + if (!strcmp(arch_specific_sort_keys[i], key) &&
> + !arch_support_sort_key(key)) {
> + return false;
> + }
> + }
> +
> + for (i = 0; i < ARRAY_SIZE(common_sort_dimensions); i++) {
> + struct sort_dimension *sd = &common_sort_dimensions[i];
> +
> + if (sd->name && !strncasecmp(key, sd->name, strlen(key)))
> + return false;
> + }
> +
> + for (i = 0; i < ARRAY_SIZE(hpp_sort_dimensions); i++) {
> + struct hpp_dimension *hd = &hpp_sort_dimensions[i];
> +
> + if (!strncasecmp(key, hd->name, strlen(key)))
> + return true;
> + }
> + return false;
> +}
> +
> static int setup_sort_list(struct perf_hpp_list *list, char *str,
> struct evlist *evlist)
> {
> @@ -3727,7 +3755,9 @@ static int setup_sort_list(struct perf_hpp_list *list, char *str,
> int ret = 0;
> int level = 0;
> int next_level = 1;
> + int prev_level = 0;
> bool in_group = false;
> + bool prev_was_hpp = false;
>
> do {
> tok = str;
> @@ -3748,6 +3778,19 @@ static int setup_sort_list(struct perf_hpp_list *list, char *str,
> }
>
> if (*tok) {
> + if (is_hpp_sort_key(tok)) {
> + /* keep output (hpp) sort keys in the same level */
> + if (prev_was_hpp) {
> + bool next_same = (level == next_level);
> +
> + level = prev_level;
> + next_level = next_same ? level : level+1;
> + }
> + prev_was_hpp = true;
> + } else {
> + prev_was_hpp = false;
> + }
> +
> ret = sort_dimension__add(list, tok, evlist, level);
> if (ret == -EINVAL) {
> if (!cacheline_size() && !strncasecmp(tok, "dcacheline", strlen(tok)))
> @@ -3759,6 +3802,7 @@ static int setup_sort_list(struct perf_hpp_list *list, char *str,
> ui__error("Unknown --sort key: `%s'", tok);
> break;
> }
> + prev_level = level;
> }
>
> level = next_level;
> --
> 2.49.0.rc0.332.g42c0ae87b1-goog
>
next prev parent reply other threads:[~2025-03-20 0:36 UTC|newest]
Thread overview: 37+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-07 8:08 [PATCH 1/3] perf sort: Keep output fields in the same level Namhyung Kim
2025-03-07 8:08 ` [PATCH 2/3] perf report: Allow hierarchy mode for --children Namhyung Kim
2025-03-07 8:08 ` [PATCH 3/3] perf report: Disable children column for data type profiling Namhyung Kim
2025-03-20 0:36 ` Namhyung Kim [this message]
2025-03-20 9:32 ` [PATCH 1/3] perf sort: Keep output fields in the same level Ingo Molnar
2025-03-20 16:16 ` Namhyung Kim
2025-03-24 7:28 ` Ingo Molnar
2025-03-25 0:26 ` Namhyung Kim
2025-04-04 9:41 ` [perf top] annotation doesn't work, libunwind doesn't seem to be working either Ingo Molnar
2025-04-04 17:28 ` Namhyung Kim
2025-04-04 18:13 ` Arnaldo Carvalho de Melo
2025-04-04 18:25 ` Arnaldo Carvalho de Melo
2025-04-04 18:40 ` Arnaldo Carvalho de Melo
2025-04-05 9:06 ` Ingo Molnar
2025-04-05 9:09 ` Ingo Molnar
2025-04-07 6:02 ` Howard Chu
2025-04-07 16:58 ` Ingo Molnar
2025-04-07 17:04 ` Ingo Molnar
2025-04-08 0:54 ` Arnaldo Carvalho de Melo
2025-04-08 6:16 ` Namhyung Kim
2025-04-09 3:26 ` Arnaldo Carvalho de Melo
2025-04-10 20:48 ` Namhyung Kim
2025-04-10 20:54 ` Ingo Molnar
2025-04-24 12:37 ` Arnaldo Carvalho de Melo
2025-04-08 8:05 ` Ingo Molnar
2025-04-09 2:23 ` Arnaldo Carvalho de Melo
2025-04-09 12:19 ` Arnaldo Carvalho de Melo
2025-04-09 15:57 ` Arnaldo Carvalho de Melo
2025-04-09 19:17 ` Arnaldo Carvalho de Melo
2025-04-09 19:22 ` Arnaldo Carvalho de Melo
2025-04-09 21:26 ` Ingo Molnar
2025-04-10 1:38 ` Arnaldo Carvalho de Melo
2025-04-10 6:24 ` Ingo Molnar
2025-04-10 14:03 ` Fixes for perf build system and TUI browsers was " Arnaldo Carvalho de Melo
2025-03-25 0:46 ` [PATCH 1/3] perf sort: Keep output fields in the same level Namhyung Kim
2025-03-30 5:54 ` Namhyung Kim
2025-03-21 18:30 ` Namhyung Kim
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=Z9tjKcKvjYgbR6hb@google.com \
--to=namhyung@kernel.org \
--cc=acme@kernel.org \
--cc=adrian.hunter@intel.com \
--cc=dvyukov@google.com \
--cc=irogers@google.com \
--cc=jolsa@kernel.org \
--cc=kan.liang@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=mingo@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.