Re: [PATCH 2/6] sched/topology: optimize topology_span_sane()

From: Leonardo Bras
Date: Wed Jul 31 2024 - 15:52:29 EST


On Tue, May 14, 2024 at 10:53:00PM +0200, Christophe JAILLET wrote:
> Le 14/05/2024 à 00:01, Yury Norov a écrit :
> > The function may call cpumask_equal with tl->mask(cpu) == tl->mask(i),
> > even though cpu != i. In such case, cpumask_equal() would always return
> > true, and we can proceed to the next CPU immediately.
> >
> > Signed-off-by: Yury Norov <yury.norov-Re5JQEeQqe8AvxtiuMwx3w@xxxxxxxxxxxxxxxx>
> > ---
> > kernel/sched/topology.c | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/kernel/sched/topology.c b/kernel/sched/topology.c
> > index 99ea5986038c..eb9eb17b0efa 100644
> > --- a/kernel/sched/topology.c
> > +++ b/kernel/sched/topology.c
> > @@ -2360,7 +2360,7 @@ static bool topology_span_sane(struct sched_domain_topology_level *tl,
> > * breaks the linking done for an earlier span.
> > */
> > for_each_cpu(i, cpu_map) {
> > - if (i == cpu)
> > + if (i == cpu || tl->mask(cpu) == tl->mask(i))
> > continue;
> > /*
> > * We should 'and' all those masks with 'cpu_map' to exactly
>
> Hi,
>
> does it make sense to pre-compute tl->mask(cpu) outside the for_each_cpu()?

Looks like a good idea to me.

Leo

>
> CJ
>