Re: [RFC PATCH V2 0/1] x86: cpu topology fix and question on x86_max_cores

From: Peter Zijlstra
Date: Mon Feb 20 2023 - 14:08:13 EST


On Mon, Feb 20, 2023 at 02:33:09PM +0000, Zhang, Rui wrote:

> > If only there was a sane way to tell these things without actually
> > bringing everything online first :-(
>
> I thought of improving this by parsing all the valid APIC-IDs in MADT
> during BSP bootup, and get such information by decoding the APIC-IDs
> using the APIC-ID layout information retrieved from BSP. But this is
> likely to be a fertile new source of bugs as Dave concerned.

Yes and no, aren't we using those APIC-IDs to send INIT to the APs?
Consequently, those APIC-IDs must be good, otherwise SMP bringup will go
side-ways -- and it typically doesn't.

We could add an assertion in SMP bringup that the APIC-ID from MADT
matches the state as read from CPUID ? If that matches (it really
should) then using the MADT table IDs early should work and at least
give us a litle bit more data.

APIC-ID is of no use vs hybrid though, and MADT doesn't include any
either, so that's all still buggered.

Luckily it looks like MADT is fairly extensible, ideally we add an field
to entry-type-0 to help with the hybrid mess.

TL;DR, I really think we should try this.