Ensure all platform specific event flags are within PERF_EVENT_FLAG_ARCH.
Cc: Will Deacon <will@kernel.org>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Arnaldo Carvalho de Melo <acme@kernel.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: linux-arm-kernel@lists.infradead.org
Cc: linux-perf-users@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Anshuman Khandual <anshuman.khandual@arm.com>
---
drivers/perf/arm_spe_pmu.c | 4 +++-
include/linux/perf/arm_pmu.h | 9 +++++----
2 files changed, 8 insertions(+), 5 deletions(-)
diff --git a/drivers/perf/arm_spe_pmu.c b/drivers/perf/arm_spe_pmu.c
index b65a7d9640e1..db8a0a841062 100644
--- a/drivers/perf/arm_spe_pmu.c
+++ b/drivers/perf/arm_spe_pmu.c
@@ -44,7 +44,9 @@
* This allows us to perform the check, i.e, perfmon_capable(),
* in the context of the event owner, once, during the event_init().
*/
-#define SPE_PMU_HW_FLAGS_CX BIT(0)
+#define SPE_PMU_HW_FLAGS_CX 0x00001
+
+static_assert((PERF_EVENT_FLAG_ARCH & SPE_PMU_HW_FLAGS_CX) == SPE_PMU_HW_FLAGS_CX);
static void set_spe_event_has_cx(struct perf_event *event)
{
diff --git a/include/linux/perf/arm_pmu.h b/include/linux/perf/arm_pmu.h
index 0407a38b470a..0356cb6a215d 100644
--- a/include/linux/perf/arm_pmu.h
+++ b/include/linux/perf/arm_pmu.h
@@ -24,10 +24,11 @@
/*
* ARM PMU hw_event flags
*/
-/* Event uses a 64bit counter */
-#define ARMPMU_EVT_64BIT 1
-/* Event uses a 47bit counter */
-#define ARMPMU_EVT_47BIT 2
+#define ARMPMU_EVT_64BIT 0x00001 /* Event uses a 64bit counter */
+#define ARMPMU_EVT_47BIT 0x00002 /* Event uses a 47bit counter */
+
+static_assert((PERF_EVENT_FLAG_ARCH & ARMPMU_EVT_64BIT) == ARMPMU_EVT_64BIT);
+static_assert((PERF_EVENT_FLAG_ARCH & ARMPMU_EVT_47BIT) == ARMPMU_EVT_47BIT);
#define HW_OP_UNSUPPORTED 0xFFFF
#define C(_x) PERF_COUNT_HW_CACHE_##_x
--
2.25.1
On 05/09/2022 06:42, Anshuman Khandual wrote:
> Ensure all platform specific event flags are within PERF_EVENT_FLAG_ARCH.
>
> Cc: Will Deacon <will@kernel.org>
> Cc: Catalin Marinas <catalin.marinas@arm.com>
> Cc: Peter Zijlstra <peterz@infradead.org>
> Cc: Ingo Molnar <mingo@redhat.com>
> Cc: Arnaldo Carvalho de Melo <acme@kernel.org>
> Cc: Mark Rutland <mark.rutland@arm.com>
> Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
> Cc: Jiri Olsa <jolsa@kernel.org>
> Cc: Namhyung Kim <namhyung@kernel.org>
> Cc: linux-arm-kernel@lists.infradead.org
> Cc: linux-perf-users@vger.kernel.org
> Cc: linux-kernel@vger.kernel.org
> Signed-off-by: Anshuman Khandual <anshuman.khandual@arm.com>
> ---
> drivers/perf/arm_spe_pmu.c | 4 +++-
> include/linux/perf/arm_pmu.h | 9 +++++----
> 2 files changed, 8 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/perf/arm_spe_pmu.c b/drivers/perf/arm_spe_pmu.c
> index b65a7d9640e1..db8a0a841062 100644
> --- a/drivers/perf/arm_spe_pmu.c
> +++ b/drivers/perf/arm_spe_pmu.c
> @@ -44,7 +44,9 @@
> * This allows us to perform the check, i.e, perfmon_capable(),
> * in the context of the event owner, once, during the event_init().
> */
> -#define SPE_PMU_HW_FLAGS_CX BIT(0)
> +#define SPE_PMU_HW_FLAGS_CX 0x00001
> +
> +static_assert((PERF_EVENT_FLAG_ARCH & SPE_PMU_HW_FLAGS_CX) == SPE_PMU_HW_FLAGS_CX);
>
> static void set_spe_event_has_cx(struct perf_event *event)
> {
> diff --git a/include/linux/perf/arm_pmu.h b/include/linux/perf/arm_pmu.h
> index 0407a38b470a..0356cb6a215d 100644
> --- a/include/linux/perf/arm_pmu.h
> +++ b/include/linux/perf/arm_pmu.h
> @@ -24,10 +24,11 @@
> /*
> * ARM PMU hw_event flags
> */
> -/* Event uses a 64bit counter */
> -#define ARMPMU_EVT_64BIT 1
> -/* Event uses a 47bit counter */
> -#define ARMPMU_EVT_47BIT 2
> +#define ARMPMU_EVT_64BIT 0x00001 /* Event uses a 64bit counter */
> +#define ARMPMU_EVT_47BIT 0x00002 /* Event uses a 47bit counter */
> +
Minor nit:
I don't think changing the definitions to hex adds anything except more
noise in the git blame.
Either way, for the whole set:
Reviewed-by: James Clark <james.clark@arm.com>
> +static_assert((PERF_EVENT_FLAG_ARCH & ARMPMU_EVT_64BIT) == ARMPMU_EVT_64BIT);
> +static_assert((PERF_EVENT_FLAG_ARCH & ARMPMU_EVT_47BIT) == ARMPMU_EVT_47BIT);
>
> #define HW_OP_UNSUPPORTED 0xFFFF
> #define C(_x) PERF_COUNT_HW_CACHE_##_x
On 9/5/22 14:40, James Clark wrote: >> --- a/include/linux/perf/arm_pmu.h >> +++ b/include/linux/perf/arm_pmu.h >> @@ -24,10 +24,11 @@ >> /* >> * ARM PMU hw_event flags >> */ >> -/* Event uses a 64bit counter */ >> -#define ARMPMU_EVT_64BIT 1 >> -/* Event uses a 47bit counter */ >> -#define ARMPMU_EVT_47BIT 2 >> +#define ARMPMU_EVT_64BIT 0x00001 /* Event uses a 64bit counter */ >> +#define ARMPMU_EVT_47BIT 0x00002 /* Event uses a 47bit counter */ >> + > Minor nit: > > I don't think changing the definitions to hex adds anything except more > noise in the git blame. The idea here was just to make these five digit hex, in accordance with PERF_EVENT_FLAG_ARCH mask like the existing x86 platform event flags.
© 2016 - 2026 Red Hat, Inc.