perf/x86/rapl: Rename 'maxdie' to nr_rapl_pmu and 'dieid' to rapl_pmu_idx
authorDhananjay Ugwekar <Dhananjay.Ugwekar@amd.com>
Thu, 2 May 2024 09:51:14 +0000 (15:21 +0530)
committerIngo Molnar <mingo@kernel.org>
Thu, 2 May 2024 11:32:21 +0000 (13:32 +0200)
AMD CPUs have the scope of RAPL energy-pkg event as package, whereas
Intel Cascade Lake CPUs have the scope as die.

To account for the difference in the energy-pkg event scope between AMD
and Intel CPUs, give more generic and semantically correct names to the
maxdie and dieid variables.

No functional change.

Signed-off-by: Dhananjay Ugwekar <Dhananjay.Ugwekar@amd.com>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Tested-by: K Prateek Nayak <kprateek.nayak@amd.com>
Link: https://lore.kernel.org/r/20240502095115.177713-2-Dhananjay.Ugwekar@amd.com
arch/x86/events/rapl.c

index ca5f687fa4200ff2855895fac0192b59614b5f14..46e673585560312fbc8f54b910ccc247da6adb38 100644 (file)
@@ -114,8 +114,8 @@ struct rapl_pmu {
 
 struct rapl_pmus {
        struct pmu              pmu;
-       unsigned int            maxdie;
-       struct rapl_pmu         *pmus[] __counted_by(maxdie);
+       unsigned int            nr_rapl_pmu;
+       struct rapl_pmu         *pmus[] __counted_by(nr_rapl_pmu);
 };
 
 enum rapl_unit_quirk {
@@ -141,13 +141,13 @@ static struct perf_msr *rapl_msrs;
 
 static inline struct rapl_pmu *cpu_to_rapl_pmu(unsigned int cpu)
 {
-       unsigned int dieid = topology_logical_die_id(cpu);
+       unsigned int rapl_pmu_idx = topology_logical_die_id(cpu);
 
        /*
         * The unsigned check also catches the '-1' return value for non
         * existent mappings in the topology map.
         */
-       return dieid < rapl_pmus->maxdie ? rapl_pmus->pmus[dieid] : NULL;
+       return rapl_pmu_idx < rapl_pmus->nr_rapl_pmu ? rapl_pmus->pmus[rapl_pmu_idx] : NULL;
 }
 
 static inline u64 rapl_read_counter(struct perf_event *event)
@@ -658,7 +658,7 @@ static void cleanup_rapl_pmus(void)
 {
        int i;
 
-       for (i = 0; i < rapl_pmus->maxdie; i++)
+       for (i = 0; i < rapl_pmus->nr_rapl_pmu; i++)
                kfree(rapl_pmus->pmus[i]);
        kfree(rapl_pmus);
 }
@@ -674,13 +674,13 @@ static const struct attribute_group *rapl_attr_update[] = {
 
 static int __init init_rapl_pmus(void)
 {
-       int maxdie = topology_max_packages() * topology_max_dies_per_package();
+       int nr_rapl_pmu = topology_max_packages() * topology_max_dies_per_package();
 
-       rapl_pmus = kzalloc(struct_size(rapl_pmus, pmus, maxdie), GFP_KERNEL);
+       rapl_pmus = kzalloc(struct_size(rapl_pmus, pmus, nr_rapl_pmu), GFP_KERNEL);
        if (!rapl_pmus)
                return -ENOMEM;
 
-       rapl_pmus->maxdie               = maxdie;
+       rapl_pmus->nr_rapl_pmu          = nr_rapl_pmu;
        rapl_pmus->pmu.attr_groups      = rapl_attr_groups;
        rapl_pmus->pmu.attr_update      = rapl_attr_update;
        rapl_pmus->pmu.task_ctx_nr      = perf_invalid_context;