* [PATCH] perf evlist: Print hint for group
@ 2024-09-08 20:28 kan.liang
2024-09-09 16:54 ` Ian Rogers
0 siblings, 1 reply; 3+ messages in thread
From: kan.liang @ 2024-09-08 20:28 UTC (permalink / raw)
To: acme, namhyung
Cc: irogers, jolsa, adrian.hunter, linux-perf-users, linux-kernel,
Kan Liang
From: Kan Liang <kan.liang@linux.intel.com>
An event group is a critical relationship. There is a -g option that can
display the relationship. But it's hard for a user to know when should
this option be applied.
If there is an event group in the perf record, print a hint to suggest
the user apply the -g to display the group information.
With the patch,
$perf record -e "{cycles,instructions},instructions" sleep 1
[ perf record: Woken up 1 times to write data ]
[ perf record: Captured and wrote 0.024 MB perf.data (4 samples) ]
$perf evlist
cycles
instructions
instructions
# Tip: use 'perf evlist -g' to show group information
$perf evlist -g
{cycles,instructions}
instructions
Suggested-by: Arnaldo Carvalho de Melo <acme@kernel.org>
Closes: https://lore.kernel.org/lkml/ZttgvduaKsVn1r4p@x1/
Signed-off-by: Kan Liang <kan.liang@linux.intel.com>
---
tools/perf/builtin-evlist.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/tools/perf/builtin-evlist.c b/tools/perf/builtin-evlist.c
index 818ab21c3f73..a9bd7bbef5a9 100644
--- a/tools/perf/builtin-evlist.c
+++ b/tools/perf/builtin-evlist.c
@@ -36,7 +36,7 @@ static int __cmd_evlist(const char *file_name, struct perf_attr_details *details
.force = details->force,
};
struct perf_tool tool;
- bool has_tracepoint = false;
+ bool has_tracepoint = false, has_group = false;
perf_tool__init(&tool, /*ordered_events=*/false);
/* only needed for pipe mode */
@@ -54,11 +54,17 @@ static int __cmd_evlist(const char *file_name, struct perf_attr_details *details
if (pos->core.attr.type == PERF_TYPE_TRACEPOINT)
has_tracepoint = true;
+
+ if (!evsel__is_group_leader(pos))
+ has_group = true;
}
if (has_tracepoint && !details->trace_fields)
printf("# Tip: use 'perf evlist --trace-fields' to show fields for tracepoint events\n");
+ if (has_group && !details->event_group)
+ printf("# Tip: use 'perf evlist -g' to show group information\n");
+
perf_session__delete(session);
return 0;
}
--
2.38.1
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH] perf evlist: Print hint for group
2024-09-08 20:28 [PATCH] perf evlist: Print hint for group kan.liang
@ 2024-09-09 16:54 ` Ian Rogers
2024-09-11 15:52 ` Arnaldo Carvalho de Melo
0 siblings, 1 reply; 3+ messages in thread
From: Ian Rogers @ 2024-09-09 16:54 UTC (permalink / raw)
To: kan.liang
Cc: acme, namhyung, jolsa, adrian.hunter, linux-perf-users,
linux-kernel
On Sun, Sep 8, 2024 at 1:28 PM <kan.liang@linux.intel.com> wrote:
>
> From: Kan Liang <kan.liang@linux.intel.com>
>
> An event group is a critical relationship. There is a -g option that can
> display the relationship. But it's hard for a user to know when should
> this option be applied.
>
> If there is an event group in the perf record, print a hint to suggest
> the user apply the -g to display the group information.
>
> With the patch,
>
> $perf record -e "{cycles,instructions},instructions" sleep 1
> [ perf record: Woken up 1 times to write data ]
> [ perf record: Captured and wrote 0.024 MB perf.data (4 samples) ]
>
> $perf evlist
> cycles
> instructions
> instructions
> # Tip: use 'perf evlist -g' to show group information
>
> $perf evlist -g
> {cycles,instructions}
> instructions
>
> Suggested-by: Arnaldo Carvalho de Melo <acme@kernel.org>
> Closes: https://lore.kernel.org/lkml/ZttgvduaKsVn1r4p@x1/
> Signed-off-by: Kan Liang <kan.liang@linux.intel.com>
Reviewed-by: Ian Rogers <irogers@google.com>
Thanks,
Ian
> ---
> tools/perf/builtin-evlist.c | 8 +++++++-
> 1 file changed, 7 insertions(+), 1 deletion(-)
>
> diff --git a/tools/perf/builtin-evlist.c b/tools/perf/builtin-evlist.c
> index 818ab21c3f73..a9bd7bbef5a9 100644
> --- a/tools/perf/builtin-evlist.c
> +++ b/tools/perf/builtin-evlist.c
> @@ -36,7 +36,7 @@ static int __cmd_evlist(const char *file_name, struct perf_attr_details *details
> .force = details->force,
> };
> struct perf_tool tool;
> - bool has_tracepoint = false;
> + bool has_tracepoint = false, has_group = false;
>
> perf_tool__init(&tool, /*ordered_events=*/false);
> /* only needed for pipe mode */
> @@ -54,11 +54,17 @@ static int __cmd_evlist(const char *file_name, struct perf_attr_details *details
>
> if (pos->core.attr.type == PERF_TYPE_TRACEPOINT)
> has_tracepoint = true;
> +
> + if (!evsel__is_group_leader(pos))
> + has_group = true;
> }
>
> if (has_tracepoint && !details->trace_fields)
> printf("# Tip: use 'perf evlist --trace-fields' to show fields for tracepoint events\n");
>
> + if (has_group && !details->event_group)
> + printf("# Tip: use 'perf evlist -g' to show group information\n");
> +
> perf_session__delete(session);
> return 0;
> }
> --
> 2.38.1
>
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] perf evlist: Print hint for group
2024-09-09 16:54 ` Ian Rogers
@ 2024-09-11 15:52 ` Arnaldo Carvalho de Melo
0 siblings, 0 replies; 3+ messages in thread
From: Arnaldo Carvalho de Melo @ 2024-09-11 15:52 UTC (permalink / raw)
To: Ian Rogers
Cc: kan.liang, namhyung, jolsa, adrian.hunter, linux-perf-users,
linux-kernel
On Mon, Sep 09, 2024 at 09:54:57AM -0700, Ian Rogers wrote:
> On Sun, Sep 8, 2024 at 1:28 PM <kan.liang@linux.intel.com> wrote:
> >
> > From: Kan Liang <kan.liang@linux.intel.com>
> >
> > An event group is a critical relationship. There is a -g option that can
> > display the relationship. But it's hard for a user to know when should
> > this option be applied.
> >
> > If there is an event group in the perf record, print a hint to suggest
> > the user apply the -g to display the group information.
> >
> > With the patch,
> >
> > $perf record -e "{cycles,instructions},instructions" sleep 1
> > [ perf record: Woken up 1 times to write data ]
> > [ perf record: Captured and wrote 0.024 MB perf.data (4 samples) ]
> >
> > $perf evlist
> > cycles
> > instructions
> > instructions
> > # Tip: use 'perf evlist -g' to show group information
> >
> > $perf evlist -g
> > {cycles,instructions}
> > instructions
> >
> > Suggested-by: Arnaldo Carvalho de Melo <acme@kernel.org>
> > Closes: https://lore.kernel.org/lkml/ZttgvduaKsVn1r4p@x1/
> > Signed-off-by: Kan Liang <kan.liang@linux.intel.com>
>
> Reviewed-by: Ian Rogers <irogers@google.com>
Thanks, tested:
Committer testing:
So for a perf.data file _with_ a group:
root@number:~# perf evlist -g
{cpu_core/branch-instructions/pp,cpu_core/branches/}
dummy:u
root@number:~# perf evlist
cpu_core/branch-instructions/pp
cpu_core/branches/
dummy:u
# Tip: use 'perf evlist -g' to show group information
root@number:~#
Then for something _without_ a group, no hint:
root@number:~# perf record ls
<SNIP>
[ perf record: Woken up 1 times to write data ]
[ perf record: Captured and wrote 0.035 MB perf.data (7 samples) ]
root@number:~# perf evlist
cpu_atom/cycles/P
cpu_core/cycles/P
dummy:u
root@number:~#
No suggestion, good.
Suggested-by: Arnaldo Carvalho de Melo <acme@kernel.org>
Reviewed-by: Ian Rogers <irogers@google.com>
Signed-off-by: Kan Liang <kan.liang@linux.intel.com>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Applied.
- Arnaldo
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-09-11 15:52 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-09-08 20:28 [PATCH] perf evlist: Print hint for group kan.liang
2024-09-09 16:54 ` Ian Rogers
2024-09-11 15:52 ` Arnaldo Carvalho de Melo
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.