Skip to contentSkip to conversation

perf evsel: Fix missing inherit + sample read check

PATCH Applied Namhyung Kim 2 participants 5 messages Oct 9, 2024 – Oct 16, 2024 perf events

lore
Share & tools
lore

Namhyung Kim

author maintainer
#0 lore raw

PATCH 1/1 perf evsel: Fix missing inherit + sample read check

It should not clear the inherit bit simply because the kernel doesn't support the sample read with it. IOW the inherit bit should be kept when the sample read is not requested for the event.

Fixes 90035d3cd876cb71 ("tools/perf: Allow inherit + PERF_SAMPLE_READ when opening events")
Cc Ben Gainey <[email protected]>
---
 tools/perf/util/evsel.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
tools/perf/util/evsel.c +2 -1
index d8fd493af01458b7..507f526ccbbcfc36 100644
@@ -2112,7 +2112,8 @@ static int __evsel__prepare_open(struct evsel *evsel, struct perf_cpu_map *cpus,
 
 static void evsel__disable_missing_features(struct evsel *evsel)
 {
-	if (perf_missing_features.inherit_sample_read)
+	if (perf_missing_features.inherit_sample_read && evsel->core.attr.inherit &&
+	    (evsel->core.attr.sample_type & PERF_SAMPLE_READ))
 		evsel->core.attr.inherit = 0;
 	if (perf_missing_features.branch_counters)
 		evsel->core.attr.branch_sample_type &= ~PERF_SAMPLE_BRANCH_COUNTERS;
Signature · 1 line
2.47.0.rc0.187.ge670bccf7e-goog
#1 lore raw
Quoted 3 lines · Namhyung Kim

It should not clear the inherit bit simply because the kernel doesn't support the sample read with it.  IOW the inherit bit should be kept when the sample read is not requested for the event.

Ah, sorry. Good spot.

Thanks
Ben

Quoted 26 lines
Fixes 90035d3cd876cb71 ("tools/perf: Allow inherit +

PERF_SAMPLE_READ when opening events")

---
 tools/perf/util/evsel.c | 3 ++-

 1 file changed, 2 insertions(+), 1 deletion(-)
tools/perf/util/evsel.c +0 -0
index d8fd493af01458b7..507f526ccbbcfc36 100644
@@ -2112,7 +2112,8 @@ static int __evsel__prepare_open(struct evsel
 *evsel, struct perf_cpu_map *cpus,


 static void evsel__disable_missing_features(struct evsel *evsel) {
- if (perf_missing_features.inherit_sample_read)
+ if (perf_missing_features.inherit_sample_read && evsel-

Quoted 1 line

core.attr.inherit &&

+     (evsel->core.attr.sample_type & PERF_SAMPLE_READ)) evsel->core.attr.inherit = 0;
  if (perf_missing_features.branch_counters) evsel->core.attr.branch_sample_type &= ~PERF_SAMPLE_BRANCH_COUNTERS;

author maintainer
#2 lore raw
Quoted 7 lines · Ben Gainey
Quoted 3 lines · Namhyung Kim

It should not clear the inherit bit simply because the kernel doesn't support the sample read with it.  IOW the inherit bit should be kept when the sample read is not requested for the event.

Ah, sorry. Good spot.

Thanks for the review, can I translate it your Acked-by?

Thanks,
Namhyung

Quoted 27 lines
Quoted 26 lines
Fixes 90035d3cd876cb71 ("tools/perf: Allow inherit +

PERF_SAMPLE_READ when opening events")

---
 tools/perf/util/evsel.c | 3 ++-

 1 file changed, 2 insertions(+), 1 deletion(-)
tools/perf/util/evsel.c +0 -0
index d8fd493af01458b7..507f526ccbbcfc36 100644
@@ -2112,7 +2112,8 @@ static int __evsel__prepare_open(struct evsel
 *evsel, struct perf_cpu_map *cpus,


 static void evsel__disable_missing_features(struct evsel *evsel) {
- if (perf_missing_features.inherit_sample_read)
+ if (perf_missing_features.inherit_sample_read && evsel-

Quoted 1 line

core.attr.inherit &&

+     (evsel->core.attr.sample_type & PERF_SAMPLE_READ)) evsel->core.attr.inherit = 0;
  if (perf_missing_features.branch_counters) evsel->core.attr.branch_sample_type &= ~PERF_SAMPLE_BRANCH_COUNTERS;

Acked-by
#3 lore raw
Quoted 9 lines · Namhyung Kim
Quoted 8 lines · Ben Gainey
Quoted 5 lines · Namhyung Kim

It should not clear the inherit bit simply because the kernel doesn't
support the sample read with it.  IOW the inherit bit should be kept
when the sample read is not requested for the event.

Quoted 4 lines
Quoted 1 line

Ah, sorry. Good spot.

Thanks for the review, can I translate it your Acked-by?

Yes, of course

:-)

Quoted 31 lines

Thanks,
Namhyung

Quoted 28 lines
Quoted 27 lines
Fixes 90035d3cd876cb71 ("tools/perf: Allow inherit +

PERF_SAMPLE_READ when opening events")

---
 tools/perf/util/evsel.c | 3 ++-

 1 file changed, 2 insertions(+), 1 deletion(-)
tools/perf/util/evsel.c +0 -0
index d8fd493af01458b7..507f526ccbbcfc36 100644
@@ -2112,7 +2112,8 @@ static int __evsel__prepare_open(struct

evsel
*evsel, struct perf_cpu_map *cpus,

 static void evsel__disable_missing_features(struct evsel *evsel) {
- if (perf_missing_features.inherit_sample_read)
+ if (perf_missing_features.inherit_sample_read && evsel-

Quoted 1 line

core.attr.inherit &&

+     (evsel->core.attr.sample_type & PERF_SAMPLE_READ)) evsel->core.attr.inherit = 0;
  if (perf_missing_features.branch_counters) evsel->core.attr.branch_sample_type &= ~PERF_SAMPLE_BRANCH_COUNTERS;

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

It should not clear the inherit bit simply because the kernel doesn't support the sample read with it. IOW the inherit bit should be kept when the sample read is not requested for the event.

Applied to perf-tools-next, thanks!

Best regards,
Namhyung