Skip to content

Commit ff6f41f

Browse files
ahunter6acmel
authored andcommitted
perf script: Fix ip display when type != attr->type
set_print_ip_opts() was not being called when type != attr->type because there is not a one-to-one relationship between output types and attr->type. That resulted in ip not printing. The attr_type() function is removed, and the match of attr->type to output type is corrected. Example on ADL using taskset to select an atom cpu: # perf record -e cpu_atom/cpu-cycles/ taskset 0x1000 uname Linux [ perf record: Woken up 1 times to write data ] [ perf record: Captured and wrote 0.003 MB perf.data (7 samples) ] Before: # perf script | head taskset 428 [-01] 10394.179041: 1 cpu_atom/cpu-cycles/: taskset 428 [-01] 10394.179043: 1 cpu_atom/cpu-cycles/: taskset 428 [-01] 10394.179044: 11 cpu_atom/cpu-cycles/: taskset 428 [-01] 10394.179045: 407 cpu_atom/cpu-cycles/: taskset 428 [-01] 10394.179046: 16789 cpu_atom/cpu-cycles/: taskset 428 [-01] 10394.179052: 676300 cpu_atom/cpu-cycles/: uname 428 [-01] 10394.179278: 4079859 cpu_atom/cpu-cycles/: After: # perf script | head taskset 428 10394.179041: 1 cpu_atom/cpu-cycles/: ffffffff95a0bb97 __intel_pmu_enable_all.constprop.48+0x47 ([kernel.kallsyms]) taskset 428 10394.179043: 1 cpu_atom/cpu-cycles/: ffffffff95a0bb97 __intel_pmu_enable_all.constprop.48+0x47 ([kernel.kallsyms]) taskset 428 10394.179044: 11 cpu_atom/cpu-cycles/: ffffffff95a0bb97 __intel_pmu_enable_all.constprop.48+0x47 ([kernel.kallsyms]) taskset 428 10394.179045: 407 cpu_atom/cpu-cycles/: ffffffff95a0bb97 __intel_pmu_enable_all.constprop.48+0x47 ([kernel.kallsyms]) taskset 428 10394.179046: 16789 cpu_atom/cpu-cycles/: ffffffff95a0bb97 __intel_pmu_enable_all.constprop.48+0x47 ([kernel.kallsyms]) taskset 428 10394.179052: 676300 cpu_atom/cpu-cycles/: 7f829ef73800 cfree+0x0 (/lib/libc-2.32.so) uname 428 10394.179278: 4079859 cpu_atom/cpu-cycles/: ffffffff95bae912 vma_interval_tree_remove+0x1f2 ([kernel.kallsyms]) Signed-off-by: Adrian Hunter <[email protected]> Reviewed-by: Kan Liang <[email protected]> Cc: Jin Yao <[email protected]> Cc: Jiri Olsa <[email protected]> Link: http://lore.kernel.org/lkml/[email protected] Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
1 parent 7efbcc8 commit ff6f41f

File tree

1 file changed

+13
-11
lines changed

1 file changed

+13
-11
lines changed

tools/perf/builtin-script.c

+13-11
Original file line numberDiff line numberDiff line change
@@ -368,16 +368,6 @@ static inline int output_type(unsigned int type)
368368
return OUTPUT_TYPE_OTHER;
369369
}
370370

371-
static inline unsigned int attr_type(unsigned int type)
372-
{
373-
switch (type) {
374-
case OUTPUT_TYPE_SYNTH:
375-
return PERF_TYPE_SYNTH;
376-
default:
377-
return type;
378-
}
379-
}
380-
381371
static bool output_set_by_user(void)
382372
{
383373
int j;
@@ -556,6 +546,18 @@ static void set_print_ip_opts(struct perf_event_attr *attr)
556546
output[type].print_ip_opts |= EVSEL__PRINT_SRCLINE;
557547
}
558548

549+
static struct evsel *find_first_output_type(struct evlist *evlist,
550+
unsigned int type)
551+
{
552+
struct evsel *evsel;
553+
554+
evlist__for_each_entry(evlist, evsel) {
555+
if (output_type(evsel->core.attr.type) == (int)type)
556+
return evsel;
557+
}
558+
return NULL;
559+
}
560+
559561
/*
560562
* verify all user requested events exist and the samples
561563
* have the expected data
@@ -567,7 +569,7 @@ static int perf_session__check_output_opt(struct perf_session *session)
567569
struct evsel *evsel;
568570

569571
for (j = 0; j < OUTPUT_TYPE_MAX; ++j) {
570-
evsel = perf_session__find_first_evtype(session, attr_type(j));
572+
evsel = find_first_output_type(session->evlist, j);
571573

572574
/*
573575
* even if fields is set to 0 (ie., show nothing) event must

0 commit comments

Comments
 (0)