Re: [PATCH 1/8] perf/x86/uncore: Save the unit control address of all units

From: Liang, Kan
Date: Wed Jun 12 2024 - 15:25:11 EST




On 2024-06-12 1:33 p.m., Tim Chen wrote:
> On Wed, 2024-06-12 at 10:49 -0400, Liang, Kan wrote:
>>
>>
>> The id and pmu_idx+die can all be used as a key to search the RB tree in
>> different places.
>>
>> The id is the physical ID of a unit. The search via id is invoked when
>> adding a new unit. Perf needs to make sure that the same PMU idx
>> (logical id) is assigned to the unit with the same physical ID. Because
>> the units with the same physical ID in different dies share the same PMU.
>
> This info about having same physical ID implies the same PMU
> is worth mentioning in a comment and will be quite helpful in
> understanding the rb-tree organization.
>

Sure I will update the description to explain the choice. Thanks.

Thanks,
Kan

> Thanks.
>
> Tim
>>
>> The pmu_idx+die key is used when setting the cpumask. Please see
>> intel_uncore_find_discovery_unit_id() in the patch 2. Perf wants to
>> understand on which dies the given PMU is available.
>>
>> Since different keys can be used to search the RB tree, I think one of
>> them has to traverse the whole tree. At the stage of adding a new unit,
>> the tree is not complete yet. It minimizes the impact of the O(N)
>> search. So I choose the pmu_idx+die rather than id.
>>
>> Also, the driver only does once to build the tree and set the cpumask at
>> driver load time. I think the O(N) should be acceptable here.
>>
>> Thanks,
>> Kan
>