Re: [PATCH 1/2] sched/topology: pre-compute topology_span_sane() loop params

From: Chen Yu
Date: Sat Aug 03 2024 - 11:33:15 EST


On 2024-08-02 at 10:57:42 -0700, Yury Norov wrote:
> tl->mask(cpu) is used unchanged in the loop, and tl->mask(i) in worst
> case may be calculated twice as parameters for cpumask_equal() and
> cpumask_intersects(). So, precalculate both.
>
> Suggested-by: Christophe JAILLET <christophe.jaillet@xxxxxxxxxx>
> Suggested-by: Leonardo Bras <leobras@xxxxxxxxxx>
> Signed-off-by: Yury Norov <yury.norov@xxxxxxxxx>
> ---
> kernel/sched/topology.c | 6 ++++--
> 1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/kernel/sched/topology.c b/kernel/sched/topology.c
> index 76504b776d03..754ad5fa3c99 100644
> --- a/kernel/sched/topology.c
> +++ b/kernel/sched/topology.c
> @@ -2353,6 +2353,7 @@ static struct sched_domain *build_sched_domain(struct sched_domain_topology_leve
> static bool topology_span_sane(struct sched_domain_topology_level *tl,
> const struct cpumask *cpu_map, int cpu)
> {
> + const struct cpumask *mi, *mc = tl->mask(cpu);

Could it avoid the calculation by putting
mc = tl->mask(cpu) after the
if (tl->flags & SDTL_OVERLAP)?

Other than that,

Reviewed-by: Chen Yu <yu.c.chen@xxxxxxxxx>

thanks,
Chenyu