Re: [PATCH] x86/tsc: Use topology_max_packages() to get package number

From: Feng Tang
Date: Sun Mar 17 2024 - 21:17:31 EST


On Fri, Mar 15, 2024 at 09:51:32PM +0100, Thomas Gleixner wrote:
> On Fri, Mar 15 2024 at 10:58, Dave Hansen wrote:
> > On 3/15/24 04:26, Feng Tang wrote:
> >> /*
> >> * Today neither Intel nor AMD support heterogeneous systems so
> >> * extrapolate the boot cpu's data to all packages.
> >> */
> >> ncpus = cpu_data(0).booted_cores * topology_max_smt_threads();
> >> __max_logical_packages = DIV_ROUND_UP(total_cpus, ncpus);
> >
> > Because Intel obviously has heterogeneous systems today.
>
> Hybrid is a per package property.
>
> But neither Intel nor AMD support populating multi socket systems with
> random packages, where socket 0 has less cores than socket 1 or socket 0
> is hybrid and socket 1 is not.


Before posting the patch, I run the latest upstream kernel with your
topology refactoring patchset on one AlderLake and one MetorLake box,
and they both show the number of package is 1.

>
> > So I'll buy that removing 'nr_online_nodes' takes NUMA out of the
> > picture (which is good), but I want to hear more about why
> > topology_max_packages() and '4' are the right things to be checking.
> >
> > I suspect the real reason '4' was picked was to give the calculation
> > some wiggle room because it's not actually all that precise.
>
> IIRC the TSC is only guaranteed to be synchronized up to 4 sockets, but
> my memory might be wrong as usual.

Yes. I did try to increase the bar to '8' with a patch, and at that
time Peter Zijlstra mentioned there was real issue with TSC found on
some old 8 sockets machine.

Thanks,
Feng

>
> Thanks,
>
> tglx