Re: [PATCH v3 05/10] perf/x86/rapl: Move cpumask variable to rapl_pmus struct
From: Peter Zijlstra
Date: Mon Jul 01 2024 - 09:03:18 EST
On Mon, Jun 24, 2024 at 05:59:02AM +0000, Dhananjay Ugwekar wrote:
> This patch is in preparation for addition of per-core energy counter
> support for AMD CPUs.
>
> Per-core energy counter PMU will need a separate cpumask. It seems like
> a better approach to add the cpumask inside the rapl_pmus struct, instead
> of creating another global cpumask variable for per-core PMU. This way, in
> future, if there is a need for a new PMU with a different scope (e.g. CCD),
> adding a new global cpumask variable won't be necessary.
>
> No functional change.
>
> Signed-off-by: Dhananjay Ugwekar <Dhananjay.Ugwekar@xxxxxxx>
> ---
> arch/x86/events/rapl.c | 12 ++++++------
> 1 file changed, 6 insertions(+), 6 deletions(-)
>
> diff --git a/arch/x86/events/rapl.c b/arch/x86/events/rapl.c
> index e5e878146542..be139e9f9ee0 100644
> --- a/arch/x86/events/rapl.c
> +++ b/arch/x86/events/rapl.c
> @@ -119,6 +119,7 @@ struct rapl_pmu {
>
> struct rapl_pmus {
> struct pmu pmu;
> + cpumask_t cpumask;
> unsigned int nr_rapl_pmu;
> struct rapl_pmu *rapl_pmu[] __counted_by(nr_rapl_pmu);
> };
Yikes no, please use cpumask_var_t and alloc_cpumask_var() and friends.