Skip to contentSkip to conversation

perf tools: Fix missing feature check for inherit + SAMPLE_READ

PATCH Applied Namhyung Kim 3 participants 9 messages Nov 11, 2025 – Nov 12, 2025 perf events

lore
Share & tools
lore

Namhyung Kim

author maintainer
#0 lore raw

PATCH 1/1 perf tools: Fix missing feature check for inherit + SAMPLE_READ

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")
---
 tools/perf/util/evsel.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/util/evsel.c +1 -1
index 67a898cda86ab559..989c56d4a23f74f4 100644
@@ -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;
 	if (has_attr_feature(&attr, /*flags=*/0))
 		goto found;
 	perf_missing_features.inherit_sample_read = true;
Signature · 1 line
2.51.2.1041.gc1ab5b90ca-goog
reviewer Reviewed-by on v1 1/1
#1 lore raw
Quoted 8 lines · Namhyung Kim

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.

Quoted 8 lines
  $ 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")

Perhaps also:

Thanks,
Ian

Quoted 20 lines
---
 tools/perf/util/evsel.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/util/evsel.c +1 -2
index 67a898cda86ab559..989c56d4a23f74f4 100644
@@ -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;
        if (has_attr_feature(&attr, /*flags=*/0))
                goto found;
        perf_missing_features.inherit_sample_read = true;
--

2.51.2.1041.gc1ab5b90ca-goog

#2 lore raw
In reply to Namhyung Kim
Quoted 24 lines · Namhyung Kim

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")
---
 tools/perf/util/evsel.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/util/evsel.c +0 -0
index 67a898cda86ab559..989c56d4a23f74f4 100644

tools/perf/util/evsel.c static bool evsel__detect_missing_features(struct evsel *evsel, struct perf_cpu · line 2477

Quoted 5 lines
tools/perf/util/evsel.c +1 -1
@@ -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.

Quoted 3 lines
tools/perf/util/evsel.c +0 -0
 	if (has_attr_feature(&attr, /*flags=*/0))
 		goto found;
 	perf_missing_features.inherit_sample_read = true;
author maintainer
#3 lore raw
Quoted 38 lines · Zide
Quoted 24 lines · Namhyung Kim

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")
---
 tools/perf/util/evsel.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/util/evsel.c +0 -0
index 67a898cda86ab559..989c56d4a23f74f4 100644

tools/perf/util/evsel.c static bool evsel__detect_missing_features(struct evsel *evsel, struct perf_cpu · line 2477

Quoted 5 lines
tools/perf/util/evsel.c +1 -1
@@ -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:

Quoted 3 lines

- It fails to open the event on the first attempt;
- It goes through the inherit_sample_read detection and fails again after removing inherit;

This is not what we want. The kernel supports inherit + SAMPLE_READ so it should not remove the inherit bit.

Quoted 2 lines

- Finally, it succeeds after falling back to precision 2 — but the inherit attribute has been unexpectedly removed.

So it'll fallback to precision 2 without removing inherit.

Quoted 5 lines

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.

Because different platforms have different limitations on hardware events. You cannot simply use current event for kernel feature check since it can result in wrong decisions due to the limitation. So we picked the software event to avoid the hardware characteristics and to focus on kernel features.

Quoted 5 lines

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.

The purpose is to turn off the non-supported features only and try with other settings like precise_ip and exclude_kernels and so on.

Thanks,
Namhyung

#4 lore raw
Quoted 65 lines · Namhyung Kim
Quoted 38 lines · Zide
Quoted 24 lines · Namhyung Kim

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")
---
 tools/perf/util/evsel.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/util/evsel.c +0 -0
index 67a898cda86ab559..989c56d4a23f74f4 100644

tools/perf/util/evsel.c static bool evsel__detect_missing_features(struct evsel *evsel, struct perf_cpu · line 2477

Quoted 5 lines
tools/perf/util/evsel.c +1 -1
@@ -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:

Quoted 3 lines

- It fails to open the event on the first attempt;
- It goes through the inherit_sample_read detection and fails again after removing inherit;

This is not what we want. The kernel supports inherit + SAMPLE_READ so it should not remove the inherit bit.

Quoted 2 lines

- Finally, it succeeds after falling back to precision 2 — but the inherit attribute has been unexpectedly removed.

So it'll fallback to precision 2 without removing inherit.

Quoted 5 lines

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.

Because different platforms have different limitations on hardware events. You cannot simply use current event for kernel feature check since it can result in wrong decisions due to the limitation. So we picked the software event to avoid the hardware characteristics and to focus on kernel features.

Quoted 1 line
Quoted 7 lines
Quoted 4 lines

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.

The purpose is to turn off the non-supported features only and try with other settings like precise_ip and exclude_kernels and so on.

OK, thanks!

Quoted 3 lines

Thanks,
Namhyung

author maintainer
#5 lore raw
Quoted 73 lines · Zide
Quoted 70 lines · Namhyung Kim
Quoted 38 lines · Zide
Quoted 24 lines · Namhyung Kim

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")
---
 tools/perf/util/evsel.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/util/evsel.c +0 -0
index 67a898cda86ab559..989c56d4a23f74f4 100644

tools/perf/util/evsel.c static bool evsel__detect_missing_features(struct evsel *evsel, struct perf_cpu · line 2477

Quoted 5 lines
tools/perf/util/evsel.c +1 -1
@@ -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:

Quoted 3 lines

- It fails to open the event on the first attempt;
- It goes through the inherit_sample_read detection and fails again after removing inherit;

This is not what we want. The kernel supports inherit + SAMPLE_READ so it should not remove the inherit bit.

Quoted 2 lines

- Finally, it succeeds after falling back to precision 2 — but the inherit attribute has been unexpectedly removed.

So it'll fallback to precision 2 without removing inherit.

Quoted 5 lines

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.

Because different platforms have different limitations on hardware events. You cannot simply use current event for kernel feature check since it can result in wrong decisions due to the limitation. So we picked the software event to avoid the hardware characteristics and to focus on kernel features.

Quoted 5 lines

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.

Quoted 4 lines
Quoted 2 lines

The purpose is to turn off the non-supported features only and try with other settings like precise_ip and exclude_kernels and so on.

OK, thanks!

Can you please confirm if this patch fixes your problem?

Thanks,
Namhyung

#6 lore raw
Quoted 74 lines · Namhyung Kim
Quoted 73 lines · Zide
Quoted 70 lines · Namhyung Kim
Quoted 38 lines · Zide
Quoted 24 lines · Namhyung Kim

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")
---
 tools/perf/util/evsel.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/util/evsel.c +0 -0
index 67a898cda86ab559..989c56d4a23f74f4 100644

tools/perf/util/evsel.c static bool evsel__detect_missing_features(struct evsel *evsel, struct perf_cpu · line 2477

Quoted 5 lines
tools/perf/util/evsel.c +1 -1
@@ -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:

Quoted 3 lines

- It fails to open the event on the first attempt;
- It goes through the inherit_sample_read detection and fails again after removing inherit;

This is not what we want. The kernel supports inherit + SAMPLE_READ so it should not remove the inherit bit.

Quoted 2 lines

- Finally, it succeeds after falling back to precision 2 — but the inherit attribute has been unexpectedly removed.

So it'll fallback to precision 2 without removing inherit.

Quoted 5 lines

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.

Because different platforms have different limitations on hardware events. You cannot simply use current event for kernel feature check since it can result in wrong decisions due to the limitation. So we picked the software event to avoid the hardware characteristics and to focus on kernel features.

Quoted 5 lines

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.

Quoted 6 lines
Quoted 4 lines
Quoted 2 lines

The purpose is to turn off the non-supported features only and try with other settings like precise_ip and exclude_kernels and so on.

OK, thanks!

Can you please confirm if this patch fixes your problem?

Yes, it works!

Quoted 3 lines

Thanks,
Namhyung

author maintainer
#7 lore raw
Quoted 77 lines · Zide
Quoted 74 lines · Namhyung Kim
Quoted 73 lines · Zide
Quoted 70 lines · Namhyung Kim
Quoted 38 lines · Zide
Quoted 24 lines · Namhyung Kim

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")
---
 tools/perf/util/evsel.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/util/evsel.c +0 -0
index 67a898cda86ab559..989c56d4a23f74f4 100644

tools/perf/util/evsel.c static bool evsel__detect_missing_features(struct evsel *evsel, struct perf_cpu · line 2477

Quoted 5 lines
tools/perf/util/evsel.c +1 -1
@@ -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:

Quoted 3 lines

- It fails to open the event on the first attempt;
- It goes through the inherit_sample_read detection and fails again after removing inherit;

This is not what we want. The kernel supports inherit + SAMPLE_READ so it should not remove the inherit bit.

Quoted 2 lines

- Finally, it succeeds after falling back to precision 2 — but the inherit attribute has been unexpectedly removed.

So it'll fallback to precision 2 without removing inherit.

Quoted 5 lines

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.

Because different platforms have different limitations on hardware events. You cannot simply use current event for kernel feature check since it can result in wrong decisions due to the limitation. So we picked the software event to avoid the hardware characteristics and to focus on kernel features.

Quoted 5 lines

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.

Quoted 8 lines
Quoted 6 lines
Quoted 4 lines
Quoted 2 lines

The purpose is to turn off the non-supported features only and try with other settings like precise_ip and exclude_kernels and so on.

OK, thanks!

Can you please confirm if this patch fixes your problem?

Yes, it works!

Thanks, I'll add your Tested-by then!

Namhyung

author maintainer Applied
#8 lore raw
In reply to Namhyung Kim
Quoted 8 lines · Namhyung Kim

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.

[...]

Applied to perf-tools-next, thanks!

Best regards,
Namhyung