Re: [Patch v2 2/2] x86/tsc: use logical_packages as a better estimation of socket numbers

From: Feng Tang
Date: Thu Jun 29 2023 - 10:07:47 EST


On Tue, Jun 27, 2023 at 01:14:34PM +0200, Thomas Gleixner wrote:
> On Sun, Jun 25 2023 at 22:51, Feng Tang wrote:
> > From debug, the reason of the hung/stall is detect_extended_topology_early()
> > is called by cpu hotplug after boot, where there is "maxcpus=XXX" setting,
> > (#echo 1 > /sys/devices/system/cpu/cpuX/online).
> >
> > It could be fixed with below patch:
> > ----------------------------------------------------------------
> > diff --git a/arch/x86/kernel/cpu/topology.c b/arch/x86/kernel/cpu/topology.c
> > index 828c1f7edac1..1ff73c8c4972 100644
> > --- a/arch/x86/kernel/cpu/topology.c
> > +++ b/arch/x86/kernel/cpu/topology.c
> > @@ -29,7 +29,7 @@ unsigned int __max_die_per_package __read_mostly = 1;
> > EXPORT_SYMBOL(__max_die_per_package);
> >
> > #ifdef CONFIG_SMP
> > -unsigned int apic_to_pkg_shift __ro_after_init;
> > +unsigned int apic_to_pkg_shift;
>
> Bah, yes. I missed the early_init() call from init_intel(). I hate that
> code with a passion.

I tested the patch on a 2S Icelake with Sub-NUMA-Cluster enabled, which
shows 4 NUMA nodes, and this patch gave the right package number: 2

On a hybrid system Alderlake with 8 P-core and 8 E-core,
'__max_logical_packages' is 1.

I also tried 'acpi=off' parameter. On a 2S Cascade Lake box, it only
brought up one CPU due to no MP table, while on another single socket
18C/36T Cascade Lake box which has MP table, it brought up 18 CPUs.
The '__max_logical_packages' is 1 for both of them.

The patch covers most of cases we have listed, so feel free to add:

Tested-by: Feng Tang <feng.tang@xxxxxxxxx>

Thanks,
Feng