Re: [patch V3 23/40] x86/cpu: Provide cpu_init/parse_topology()

From: Thomas Gleixner
Date: Mon Aug 14 2023 - 02:22:39 EST


On Sun, Aug 13 2023 at 16:36, Thomas Gleixner wrote:
> On Sun, Aug 13 2023 at 13:30, Rui Zhang wrote:
>>> My understanding is that, to ensure a package scope unique core_id,
>>> rather than Module/Tile scope unique, what is really needed here is
>>> something like,
>>>>
>>>         apicid >>= x86_topo_system.dom_shifts[SMT];
>>>         c->topo.core_id = apicid & (x86_topo_system.dom_size[PACKAGE]
>>> - 1);

Actually it needs to be:

apicid &= (1U << x86_topo_system.dom_shifts[TOPO_PKG_DOMAIN]) - 1;
c->topo.core_id = apicid >> x86_topo_system.dom_shifts[TOPO_SMT_DOMAIN];

because otherwise you shift the lowest package ID bit into the result.