[RFC PATCH 1/4] perf: arm_pmuv3: Introduce module param to partition the PMU

Colton Lewis coltonlewis at google.com
Tue Jan 28 14:27:11 PST 2025


Hey Rob, thanks for the review.

Rob Herring <robh at kernel.org> writes:

> On Mon, Jan 27, 2025 at 4:26 PM Colton Lewis <coltonlewis at google.com>  
> wrote:
>> @@ -1215,10 +1243,19 @@ static void __armv8pmu_probe_pmu(void *info)

>>          cpu_pmu->pmuver = pmuver;
>>          probe->present = true;
>> +       pmcr_n = FIELD_GET(ARMV8_PMU_PMCR_N, armv8pmu_pmcr_read());

>>          /* Read the nb of CNTx counters supported from PMNC */
>> -       bitmap_set(cpu_pmu->cntr_mask,
>> -                  0, FIELD_GET(ARMV8_PMU_PMCR_N, armv8pmu_pmcr_read()));
>> +       bitmap_set(cpu_pmu->cntr_mask, 0, pmcr_n);
>> +
>> +       if (reserved_guest_counters > 0 && reserved_guest_counters <  
>> pmcr_n) {
>> +               cpu_pmu->hpmn = reserved_guest_counters;
>> +               cpu_pmu->partitioned = true;

> You're storing the same information 3 times. 'partitioned' is just
> 'reserved_guest_counters != 0' or 'cpu_pmu->hpmn != pmcr_n'.

Yes, because code outside this module that isn't already reading PMCR.N
will need to know the result of that comparion.

>> +       } else {
>> +               reserved_guest_counters = 0;
>> +               cpu_pmu->hpmn = pmcr_n;
>> +               cpu_pmu->partitioned = false;
>> +       }

>>          /* Add the CPU cycles counter */
>>          set_bit(ARMV8_PMU_CYCLE_IDX, cpu_pmu->cntr_mask);
>> @@ -1516,3 +1553,5 @@ void arch_perf_update_userpage(struct perf_event  
>> *event,
>>          userpg->cap_user_time_zero = 1;
>>          userpg->cap_user_time_short = 1;
>>   }
>> +
>> +module_param(reserved_guest_counters, byte, 0);

> Module params are generally discouraged. Since this driver can't be a
> module, this is a boot time only option. There's little reason this
> can't be a sysfs setting. There's some complexity in changing this
> when counters are in use (just reject the change) and when we have
> asymmetric PMUs. Alternatively, it could be a sysctl like user access.

I see what you mean. I'm not dealing with those complexities yet. That's
why this is an RFC.

> Rob


More information about the linux-arm-kernel mailing list