linux-perf-users.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] perf tools: Refactor precise_ip fallback logic
@ 2025-10-22 22:08 Zide Chen
  2025-10-23 16:14 ` Ian Rogers
  2025-10-24  2:30 ` Namhyung Kim
  0 siblings, 2 replies; 17+ messages in thread
From: Zide Chen @ 2025-10-22 22:08 UTC (permalink / raw)
  To: linux-kernel
  Cc: linux-perf-users, Namhyung Kim, Peter Zijlstra, Adrian Hunter,
	Ingo Molnar, Jiri Olsa, Mark Rutland, Arnaldo Carvalho de Melo,
	Ian Rogers, Alexander Shishkin, thomas.falcon, dapeng1.mi,
	xudong.hao, Zide Chen

Commit c33aea446bf555ab ("perf tools: Fix precise_ip fallback logic")
unconditionally called the precise_ip fallback and moved it after the
missing-feature checks so that it could handle EINVAL as well.

However, this introduced an issue: after disabling missing features,
the event could fail to open, which makes the subsequent precise_ip
fallback useless since it will always fail.

For example, run the following command on Intel SPR:

$ perf record -e '{cpu/mem-loads-aux/S,cpu/mem-loads,ldlat=3/PS}' -- ls

Opening the event "cpu/mem-loads,ldlat=3/PS" returns EINVAL when
precise_ip == 3. It then sets attr.inherit = false, which triggers a
kernel check failure since it doesn't match the group leader's inherit
attribute. As a result, it continues to fail even after precise_ip is
reduced.

By moving the precise_ip fallback earlier, this issue is resolved, as
well as the kernel test robot report mentioned in commit
c33aea446bf555ab.

No negative side effects are expected, because the precise_ip level is
restored by evsel__precise_ip_fallback() if the fallback does not help.

This also aligns with commit 2b70702917337a8d ("perf tools: Remove
evsel__handle_error_quirks()").

Fixes: af954f76eea56453 ("perf tools: Check fallback error and order")
Fixes: c33aea446bf555ab ("perf tools: Fix precise_ip fallback logic")
Reviewed-by: Dapeng Mi <dapeng1.mi@linux.intel.com>
Signed-off-by: Zide Chen <zide.chen@intel.com>
---
 tools/perf/util/evsel.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c
index ca74514c8707..6ce32533a213 100644
--- a/tools/perf/util/evsel.c
+++ b/tools/perf/util/evsel.c
@@ -2714,12 +2714,12 @@ static int evsel__open_cpu(struct evsel *evsel, struct perf_cpu_map *cpus,
 	if (err == -EMFILE && rlimit__increase_nofile(&set_rlimit))
 		goto retry_open;
 
+	if (evsel__precise_ip_fallback(evsel))
+		goto retry_open;
+
 	if (err == -EINVAL && evsel__detect_missing_features(evsel, cpu))
 		goto fallback_missing_features;
 
-	if (evsel__precise_ip_fallback(evsel))
-		goto retry_open;
-
 out_close:
 	if (err)
 		threads->err_thread = thread;
-- 
2.51.0


^ permalink raw reply related	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2025-11-11 20:01 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-10-22 22:08 [PATCH] perf tools: Refactor precise_ip fallback logic Zide Chen
2025-10-23 16:14 ` Ian Rogers
2025-10-23 22:11   ` Chen, Zide
2025-10-24  2:30 ` Namhyung Kim
2025-10-24 18:03   ` Chen, Zide
2025-10-26  0:42     ` Namhyung Kim
2025-10-27 18:56       ` Chen, Zide
2025-11-04  3:48         ` Namhyung Kim
2025-11-04 19:10           ` Chen, Zide
2025-11-06 18:52             ` Namhyung Kim
2025-11-07  1:23               ` Chen, Zide
2025-11-07 21:42                 ` Namhyung Kim
2025-11-07 22:31                   ` Chen, Zide
2025-11-11  7:50                     ` Namhyung Kim
2025-11-11 19:11                       ` Chen, Zide
2025-11-11 19:34                         ` Namhyung Kim
2025-11-11 20:01                           ` Chen, Zide

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).