Re: [patch V2 08/28] sched/smt: Make sched_smt_present track topology

From: Peter Zijlstra
Date: Thu Nov 29 2018 - 10:48:18 EST


On Thu, Nov 29, 2018 at 09:50:13AM -0500, Konrad Rzeszutek Wilk wrote:
> On Thu, Nov 29, 2018 at 09:42:56AM -0500, Konrad Rzeszutek Wilk wrote:
> > On Sun, Nov 25, 2018 at 07:33:36PM +0100, Thomas Gleixner wrote:
> > > Currently the 'sched_smt_present' static key is enabled when at CPU bringup
> > > SMT topology is observed, but it is never disabled. However there is demand
> > > to also disable the key when the topology changes such that there is no SMT
> > > present anymore.
> > >
> > > Implement this by making the key count the number of cores that have SMT
> > > enabled.
> > >
> > > In particular, the SMT topology bits are set before interrrupts are enabled
> > > and similarly, are cleared after interrupts are disabled for the last time
> > > and the CPU dies.
> >
> > I see that the number you used is '2', but I thought that there are some
> > CPUs out there (Knights Landing?) that could have four threads?

This code is generic, Sparc, Power and I think MIPS all have parts with
SMT8.

> > Would it be better to have a generic function that would provide the
> > amount of threads the platform does expose - and use that instead
> > of a constant value?
>
> Nevermind - this would work even with 4 threads as we would hit the
> number '2' before '4' and the key would be turned on/off properly.

Indeed so, 2 is the point where we either have more than 1 sibling, or
will go back to 1.