perf evsel: Fix missing inherit + sample read check
authorNamhyung Kim <namhyung@kernel.org>
Wed, 9 Oct 2024 06:22:50 +0000 (23:22 -0700)
committerNamhyung Kim <namhyung@kernel.org>
Mon, 14 Oct 2024 19:04:31 +0000 (12:04 -0700)
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")
Acked-by: Ben Gainey <ben.gainey@arm.com>
Link: https://lore.kernel.org/r/20241009062250.730192-1-namhyung@kernel.org
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
tools/perf/util/evsel.c

index ed0d4d20e35761efe48c3b712100ca57200c8a8d..e9e1f576d34ddf6482fffb1c21d2bd18370ad4d3 100644 (file)
@@ -1915,7 +1915,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;