Re: [PATCH V2 16/25] perf/x86: Register hybrid PMUs

From: Liang, Kan
Date: Thu Mar 11 2021 - 10:41:55 EST




On 3/11/2021 7:34 AM, Peter Zijlstra wrote:
On Wed, Mar 10, 2021 at 08:37:52AM -0800, kan.liang@xxxxxxxxxxxxxxx wrote:
@@ -2092,9 +2105,37 @@ static int __init init_hw_perf_events(void)
if (err)
goto out1;
- err = perf_pmu_register(&pmu, "cpu", PERF_TYPE_RAW);
- if (err)
- goto out2;
+ if (!is_hybrid()) {
+ err = perf_pmu_register(&pmu, "cpu", PERF_TYPE_RAW);
+ if (err)
+ goto out2;
+ } else {
+ u8 cpu_type = get_hybrid_cpu_type(smp_processor_id());
+ struct x86_hybrid_pmu *hybrid_pmu;
+ int i;
+
+ for (i = 0; i < x86_pmu.num_hybrid_pmus; i++) {
+ hybrid_pmu = &x86_pmu.hybrid_pmu[i];
+
+ hybrid_pmu->pmu = pmu;
+ hybrid_pmu->pmu.type = -1;
+ hybrid_pmu->pmu.attr_update = x86_pmu.attr_update;
+ hybrid_pmu->pmu.capabilities |= PERF_PMU_CAP_HETEROGENEOUS_CPUS;
+
+ /* Only register the PMU for the boot CPU */

Why ?!
> AFAICT we could register them all here. That instantly fixes that
CPU_STARTING / CPU_DEAD fail elsewhere in this patch.

It's possible that all CPUs of a certain type all offline, but I cannot know the information here, because the boot CPU is the only online CPU. I don't know the status of the other CPUs.

If we unconditionally register all PMUs, users may see a PMU in /sys/devices, but they cannot use it, because there is no available CPU.
Is it acceptable that registering an empty PMU?


Thanks,
Kan