perf: arm_cspmu: Reject events meant for other PMUs
authorIlkka Koskinen <ilkka@os.amperecomputing.com>
Fri, 3 Nov 2023 00:16:54 +0000 (17:16 -0700)
committerCatalin Marinas <catalin.marinas@arm.com>
Tue, 7 Nov 2023 11:00:49 +0000 (11:00 +0000)
Coresight PMU driver didn't reject events meant for other PMUs.
This caused some of the Core PMU events disappearing from
the output of "perf list". In addition, trying to run e.g.

     $ perf stat -e r2 sleep 1

made Coresight PMU driver to handle the event instead of letting
Core PMU driver to deal with it.

Cc: stable@vger.kernel.org
Fixes: e37dfd65731d ("perf: arm_cspmu: Add support for ARM CoreSight PMU driver")
Signed-off-by: Ilkka Koskinen <ilkka@os.amperecomputing.com>
Acked-by: Will Deacon <will@kernel.org>
Reviewed-by: Besar Wicaksono <bwicaksono@nvidia.com>
Acked-by: Mark Rutland <mark.rutland@arm.com>
Reviewed-by: Anshuman Khandual <anshuman.khandual@arm.com>
Link: https://lore.kernel.org/r/20231103001654.35565-1-ilkka@os.amperecomputing.com
Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
drivers/perf/arm_cspmu/arm_cspmu.c

index 0e3fe00d741d28678e019129068aae14d950ff69..9f478f2c85543eb7ca2f68e448e401f82a73adcf 100644 (file)
@@ -676,6 +676,9 @@ static int arm_cspmu_event_init(struct perf_event *event)
 
        cspmu = to_arm_cspmu(event->pmu);
 
+       if (event->attr.type != event->pmu->type)
+               return -ENOENT;
+
        /*
         * Following other "uncore" PMUs, we do not support sampling mode or
         * attach to a task (per-process mode).