lkml.org 
[lkml]   [2021]   [Apr]   [9]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH V5 16/25] perf/x86: Register hybrid PMUs
From
Date


On 4/9/2021 2:58 AM, Peter Zijlstra wrote:
> On Mon, Apr 05, 2021 at 08:10:58AM -0700, kan.liang@linux.intel.com wrote:
>> @@ -2089,9 +2119,46 @@ 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_this_hybrid_cpu_type();
>> + struct x86_hybrid_pmu *hybrid_pmu;
>> + bool registered = false;
>> + int i;
>> +
>> + if (!cpu_type && x86_pmu.get_hybrid_cpu_type)
>> + cpu_type = x86_pmu.get_hybrid_cpu_type();
>> +
>> + 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;
>> +
>> + err = perf_pmu_register(&hybrid_pmu->pmu, hybrid_pmu->name,
>> + (hybrid_pmu->cpu_type == hybrid_big) ? PERF_TYPE_RAW : -1);
>> + if (err)
>> + continue;
>> +
>> + if (cpu_type == hybrid_pmu->cpu_type)
>> + x86_pmu_update_cpu_context(&hybrid_pmu->pmu, raw_smp_processor_id());
>> +
>> + registered = true;
>> + }
>> +
>> + if (!registered) {
>> + pr_warn("Failed to register hybrid PMUs\n");
>> + kfree(x86_pmu.hybrid_pmu);
>> + x86_pmu.hybrid_pmu = NULL;
>> + x86_pmu.num_hybrid_pmus = 0;
>> + goto out2;
>> + }
>
> I don't think this is quite right. registered will be true even if one
> fails, while I think you meant to only have it true when all (both)
> types registered correctly.

No, I mean that perf error out only when all types fail to be registered.

For the case (1 failure, 1 success), users can still access the
registered PMU.
When a CPU belongs to the unregistered PMU online, a warning will be
displayed. Because in init_hybrid_pmu(), we will check the PMU type
before update the CPU mask.

if (WARN_ON_ONCE(!pmu || (pmu->pmu.type == -1))) {
cpuc->pmu = NULL;
return false;
}


Thanks,
Kan

\
 
 \ /
  Last update: 2021-04-09 15:50    [W:0.075 / U:0.072 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site