Skip to content

Commit 2b70702

Browse files
committed
perf tools: Remove evsel__handle_error_quirks()
The evsel__handle_error_quirks() is to fixup invalid event attributes on some architecture based on the error code. Currently it's only used for AMD to disable precise_ip not to use IBS which has more restrictions. But the commit c33aea4 changed call evsel__precise_ip_fallback for any errors so there's no difference with the above function. To make matter worse, it caused a problem with branch stack on Zen3. The IBS doesn't support branch stack so it should use a regular core PMU event. The default event is set precise_max and it starts with 3. And evsel__precise_ip_fallback() tries with it and reduces the level one by one. At last it tries with 0 but it also failed on Zen3 since the branch stack is not supported for the cycles event. At this point, evsel__precise_ip_fallback() restores the original precise_ip value (3) in the hope that it can succeed with other modifier (like exclude_kernel). Then evsel__handle_error_quirks() see it has precise_ip != 0 and make it retry with 0. This created an infinite loop. Before: $ perf record -b -vv |& grep removing removing precise_ip on AMD removing precise_ip on AMD removing precise_ip on AMD removing precise_ip on AMD removing precise_ip on AMD removing precise_ip on AMD removing precise_ip on AMD removing precise_ip on AMD removing precise_ip on AMD removing precise_ip on AMD removing precise_ip on AMD removing precise_ip on AMD ... After: $ perf record -b true Error: Failure to open event 'cycles:P' on PMU 'cpu' which will be removed. Invalid event (cycles:P) in per-thread mode, enable system wide with '-a'. Error: Failure to open any events for recording. Fixes: c33aea4 ("perf tools: Fix precise_ip fallback logic") Tested-by: Chun-Tse Shao <ctshao@google.com> Cc: Ravi Bangoria <ravi.bangoria@amd.com> Link: https://lore.kernel.org/r/20250410010252.402221-1-namhyung@kernel.org Signed-off-by: Namhyung Kim <namhyung@kernel.org>
1 parent 1293dac commit 2b70702

File tree

1 file changed

+0
-22
lines changed

1 file changed

+0
-22
lines changed

tools/perf/util/evsel.c

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2566,25 +2566,6 @@ static bool evsel__detect_missing_features(struct evsel *evsel, struct perf_cpu
25662566
return false;
25672567
}
25682568

2569-
static bool evsel__handle_error_quirks(struct evsel *evsel, int error)
2570-
{
2571-
/*
2572-
* AMD core PMU tries to forward events with precise_ip to IBS PMU
2573-
* implicitly. But IBS PMU has more restrictions so it can fail with
2574-
* supported event attributes. Let's forward it back to the core PMU
2575-
* by clearing precise_ip only if it's from precise_max (:P).
2576-
*/
2577-
if ((error == -EINVAL || error == -ENOENT) && x86__is_amd_cpu() &&
2578-
evsel->core.attr.precise_ip && evsel->precise_max) {
2579-
evsel->core.attr.precise_ip = 0;
2580-
pr_debug2_peo("removing precise_ip on AMD\n");
2581-
display_attr(&evsel->core.attr);
2582-
return true;
2583-
}
2584-
2585-
return false;
2586-
}
2587-
25882569
static int evsel__open_cpu(struct evsel *evsel, struct perf_cpu_map *cpus,
25892570
struct perf_thread_map *threads,
25902571
int start_cpu_map_idx, int end_cpu_map_idx)
@@ -2730,9 +2711,6 @@ static int evsel__open_cpu(struct evsel *evsel, struct perf_cpu_map *cpus,
27302711
if (evsel__precise_ip_fallback(evsel))
27312712
goto retry_open;
27322713

2733-
if (evsel__handle_error_quirks(evsel, err))
2734-
goto retry_open;
2735-
27362714
out_close:
27372715
if (err)
27382716
threads->err_thread = thread;

0 commit comments

Comments
 (0)