mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Chen, Zide" <zide.chen@intel.com>
To: Namhyung Kim <namhyung@kernel.org>,
	Arnaldo Carvalho de Melo <acme@kernel.org>,
	Ian Rogers <irogers@google.com>,
	James Clark <james.clark@linaro.org>
Cc: Jiri Olsa <jolsa@kernel.org>,
	Adrian Hunter <adrian.hunter@intel.com>,
	Peter Zijlstra <peterz@infradead.org>,
	Ingo Molnar <mingo@kernel.org>,
	LKML <linux-kernel@vger.kernel.org>,
	linux-perf-users@vger.kernel.org
Subject: Re: [PATCH] perf tools: Fix missing feature check for inherit + SAMPLE_READ
Date: Tue, 11 Nov 2025 11:13:20 -0800	[thread overview]
Message-ID: <ac137eff-674c-4fa4-b870-80878af032a0@intel.com> (raw)
In-Reply-To: <20251111075944.2328021-1-namhyung@kernel.org>



On 11/10/2025 11:59 PM, Namhyung Kim wrote:
> It should also have PERF_SAMPLE_TID to enable inherit and PERF_SAMPLE_READ
> on recent kernels.  Not having _TID makes the feature check wrongly detect
> the inherit and _READ support.
> 
> It was reported that the following command failed due to the error in
> the missing feature check on Intel SPR machines.
> 
>   $ perf record -e '{cpu/mem-loads-aux/S,cpu/mem-loads,ldlat=3/PS}' -- ls
>   Error:
>   Failure to open event 'cpu/mem-loads,ldlat=3/PS' on PMU 'cpu' which will be removed.
>   Invalid event (cpu/mem-loads,ldlat=3/PS) in per-thread mode, enable system wide with '-a'.
> 
> Fixes: 3b193a57baf15c468 ("perf tools: Detect missing kernel features properly")
> Reported-by: "Chen, Zide" <zide.chen@intel.com>
> Signed-off-by: Namhyung Kim <namhyung@kernel.org>
> ---
>  tools/perf/util/evsel.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c
> index 67a898cda86ab559..989c56d4a23f74f4 100644
> --- a/tools/perf/util/evsel.c
> +++ b/tools/perf/util/evsel.c
> @@ -2474,7 +2474,7 @@ static bool evsel__detect_missing_features(struct evsel *evsel, struct perf_cpu
>  	/* Please add new feature detection here. */
>  
>  	attr.inherit = true;
> -	attr.sample_type = PERF_SAMPLE_READ;
> +	attr.sample_type = PERF_SAMPLE_READ | PERF_SAMPLE_TID;


Seems this could have some unintended side effects. For example,
consider a :ppp event with PERF_SAMPLE_READ and inherit attributes
running on a system where the maximum precise_ip is 2:

- It fails to open the event on the first attempt;
- It goes through the inherit_sample_read detection and fails again
after removing inherit;
- Finally, it succeeds after falling back to precision 2 — but the
inherit attribute has been unexpectedly removed.

I may have missed something, but I don’t quite understand why commit
3b193a57baf15 ("perf tools: Detect missing kernel features properly")
performs the check on a dummy evsel instead of the original one. In this
way, it might incorrectly fall back an attribute that doesn’t actually help.

This means evsel__detect_missing_features() could theoretically roll
back a feature that might not actually work. Given that it cannot
restore the original evsel state after a failed attempt, side effects
may occur.


>  	if (has_attr_feature(&attr, /*flags=*/0))
>  		goto found;
>  	perf_missing_features.inherit_sample_read = true;


  parent reply	other threads:[~2025-11-11 19:13 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-11-11  7:59 Namhyung Kim
2025-11-11 18:36 ` Ian Rogers
2025-11-11 19:13 ` Chen, Zide [this message]
2025-11-11 19:40   ` Namhyung Kim
2025-11-11 20:03     ` Chen, Zide
2025-11-11 22:31       ` Namhyung Kim
2025-11-11 22:36         ` Chen, Zide
2025-11-12  0:43           ` Namhyung Kim
2025-11-12 17:56 ` Namhyung Kim

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ac137eff-674c-4fa4-b870-80878af032a0@intel.com \
    --to=zide.chen@intel.com \
    --cc=acme@kernel.org \
    --cc=adrian.hunter@intel.com \
    --cc=irogers@google.com \
    --cc=james.clark@linaro.org \
    --cc=jolsa@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=namhyung@kernel.org \
    --cc=peterz@infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®