Skip to content

Commit 9953807

Browse files
Kan Liangacmel
authored andcommitted
perf evlist: Print hint for group
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 $ 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 <[email protected]> Reviewed-by: Ian Rogers <[email protected]> Signed-off-by: Kan Liang <[email protected]> Tested-by: Arnaldo Carvalho de Melo <[email protected]> Cc: Adrian Hunter <[email protected]> Cc: Jiri Olsa <[email protected]> Cc: Namhyung Kim <[email protected]> Closes: https://lore.kernel.org/lkml/ZttgvduaKsVn1r4p@x1/ Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
1 parent eb9b9a6 commit 9953807

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

tools/perf/builtin-evlist.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ static int __cmd_evlist(const char *file_name, struct perf_attr_details *details
3636
.force = details->force,
3737
};
3838
struct perf_tool tool;
39-
bool has_tracepoint = false;
39+
bool has_tracepoint = false, has_group = false;
4040

4141
perf_tool__init(&tool, /*ordered_events=*/false);
4242
/* only needed for pipe mode */
@@ -54,11 +54,17 @@ static int __cmd_evlist(const char *file_name, struct perf_attr_details *details
5454

5555
if (pos->core.attr.type == PERF_TYPE_TRACEPOINT)
5656
has_tracepoint = true;
57+
58+
if (!evsel__is_group_leader(pos))
59+
has_group = true;
5760
}
5861

5962
if (has_tracepoint && !details->trace_fields)
6063
printf("# Tip: use 'perf evlist --trace-fields' to show fields for tracepoint events\n");
6164

65+
if (has_group && !details->event_group)
66+
printf("# Tip: use 'perf evlist -g' to show group information\n");
67+
6268
perf_session__delete(session);
6369
return 0;
6470
}

0 commit comments

Comments
 (0)