Re: [patch v2 25/30] x86/cpu/topology: Use topology logical mapping mechanism

From: Thomas Gleixner
Date: Mon Feb 12 2024 - 11:21:47 EST


On Fri, Feb 02 2024 at 06:45, Rui Zhang wrote:
>> @@ -147,6 +148,9 @@ static void topo_set_ids(struct topo_sca
>>         c->topo.pkg_id = topo_shift_apicid(apicid, TOPO_PKG_DOMAIN);
>>         c->topo.die_id = topo_shift_apicid(apicid, TOPO_DIE_DOMAIN);
>>  
>> +       c->topo.logical_pkg_id = topology_get_logical_id(apicid,
>> TOPO_PKG_DOMAIN);
>> +       c->topo.logical_die_id = topology_get_logical_id(apicid,
>> TOPO_DIE_DOMAIN);
>> +
>
> Just wondering if we could have logical_core_id.
>
> drivers/hwmon/coretemp.c uses an array to save per core temperature
> information. We cannot use core_id as array index because it can be
> sparse. Currently, to get the temperature info for a specified core,
> we need to traverse the array to know which core each entry maps to.
>
> Ideally, we could have a global logical_core_id, and use that as the
> array index directly.
> This can also simplify kernel code in many places when checking if two
> cpus are in the same core or not.

That's trivial to do now :)

It's an orthogonal change and we can put it on top once this pile is
merged.

Thanks,

tglx