From: kan.liang@linux.intel.com
To: acme@kernel.org, namhyung@kernel.org
Cc: irogers@google.com, jolsa@kernel.org, adrian.hunter@intel.com,
linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org,
Kan Liang <kan.liang@linux.intel.com>
Subject: [PATCH] perf evlist: Print hint for group
Date: Sun, 8 Sep 2024 13:28:47 -0700 [thread overview]
Message-ID: <20240908202847.176280-1-kan.liang@linux.intel.com> (raw)
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
next reply other threads:[~2024-09-08 20:28 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-09-08 20:28 kan.liang [this message]
2024-09-09 16:54 ` [PATCH] perf evlist: Print hint for group Ian Rogers
2024-09-11 15:52 ` 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=20240908202847.176280-1-kan.liang@linux.intel.com \
--to=kan.liang@linux.intel.com \
--cc=acme@kernel.org \
--cc=adrian.hunter@intel.com \
--cc=irogers@google.com \
--cc=jolsa@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=namhyung@kernel.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.