Re: [PATCH 1/2] perf/x86/rapl: Move the pmu allocation out of CPU hotplug

From: Liang, Kan
Date: Tue Oct 08 2024 - 16:10:39 EST




On 2024-10-08 12:33 p.m., Thomas Gleixner wrote:
> On Fri, Sep 13 2024 at 10:10, kan liang wrote:
>> +static void __init init_rapl_pmu(void)
>> +{
>> + struct rapl_pmu *pmu;
>> + s32 rapl_pmu_idx;
>> + int cpu;
>> +
>> + cpus_read_lock();
>> +
>> + for_each_cpu(cpu, cpu_online_mask) {
>
> How is that supposed to work, when not all CPUs are online when
> init_rapl_pmus() is invoked?
>

RAPL is a module. The module_init() is called during do_initcalls(),
which is after the smp_init(). The cpu_online_mask has been setup in the
smp_init().

I also patched the kernel to double check. The cpu_online_mask indeed
shows all the online CPUs.

[ 7.021212] smp: Brought up 1 node, 48 CPUs
[ 7.021212] smpboot: Total of 48 processors activated (211200.00
BogoMIPS)
... ...
[ 16.557323] RAPL PMU: rapl_pmu_init: cpu_online_mask 0xffffffffffff


Thanks,
Kan