Since commit bb30acae4c4dacfa ("perf report: Bail out --mem-mode if mem info is not available") "perf mem report" and "perf report --mem-mode" don't report result if the PERF_SAMPLE_DATA_SRC bit is missed in sample type. The commit ffab487052054162 ("perf: arm-spe: Fix perf report --mem-mode") partially fixes the issue. It adds PERF_SAMPLE_DATA_SRC bit for Arm SPE event, this allows the perf data file generated by kernel v5.18-rc1 or later version can be reported properly. On the other hand, perf tool still fails to be backward compatibility for a data file recorded by an older version's perf which contains Arm SPE trace data. This patch is a workaround in reporting phase, when detects ARM SPE PMU event and without PERF_SAMPLE_DATA_SRC bit, it will force to set the bit in the sample type and give a warning info.
Unified · Split
| @@ -353,6 +353,7 @@ static int report__setup_sample_type(struct report *rep) · 352 unmodified lines | |||
| 353 | struct perf_session *session = rep->session; | 353 | struct perf_session *session = rep->session; |
| 354 | u64 sample_type = evlist__combined_sample_type(session->evlist); | 354 | u64 sample_type = evlist__combined_sample_type(session->evlist); |
| 355 | bool is_pipe = perf_data__is_pipe(session->data); | 355 | bool is_pipe = perf_data__is_pipe(session->data); |
| 356 | struct evsel *evsel; | ||
| 356 | 357 | ||
| 357 | if (session->itrace_synth_opts->callchain || | 358 | if (session->itrace_synth_opts->callchain || |
| 358 | session->itrace_synth_opts->add_callchain || | 359 | session->itrace_synth_opts->add_callchain || |
| @@ -407,6 +408,19 @@ static int report__setup_sample_type(struct report *rep) · 48 unmodified lines | |||
| 407 | } | 408 | } |
| 408 | 409 | ||
| 409 | if (sort__mode == SORT_MODE__MEMORY) { | 410 | if (sort__mode == SORT_MODE__MEMORY) { |
| 411 | /* | ||
| 412 | * FIXUP: prior to kernel 5.18, Arm SPE missed to set | ||
| 413 | * PERF_SAMPLE_DATA_SRC bit in sample type. For backward | ||
| 414 | * compatibility, set the bit if it's an old perf data file. | ||
| 415 | */ | ||
| 416 | evlist__for_each_entry(session->evlist, evsel) { | ||
| 417 | if (strstr(evsel->name, "arm_spe") && | ||
| 418 | !(sample_type & PERF_SAMPLE_DATA_SRC)) { | ||
| 419 | evsel->core.attr.sample_type |= PERF_SAMPLE_DATA_SRC; | ||
| 420 | sample_type |= PERF_SAMPLE_DATA_SRC; | ||
| 421 | } | ||
| 422 | } | ||
| 423 | |||
| 410 | if (!is_pipe && !(sample_type & PERF_SAMPLE_DATA_SRC)) { | 424 | if (!is_pipe && !(sample_type & PERF_SAMPLE_DATA_SRC)) { |
| 411 | ui__error("Selected --mem-mode but no mem data. " | 425 | ui__error("Selected --mem-mode but no mem data. " |
| 412 | "Did you call perf record without -d?\n"); | 426 | "Did you call perf record without -d?\n"); |