Re: [PATCH] sched/fair: Simplify task_numa_find_cpu()

From: Mel Gorman
Date: Mon Nov 01 2021 - 07:18:50 EST


On Sat, Oct 30, 2021 at 03:25:59PM +0800, Yuan ZhaoXiong wrote:
> Combine the 'cpumask_of_node()' with 'env->p->cpus_ptr' and drop the
> cpumask_test_cpu().
>
> Signed-off-by: Yuan ZhaoXiong <yuanzhaoxiong@xxxxxxxxx>

This potentially creates of a temporary cpumask variable as noted in the
comment for for_each_cpu_and.

* This saves a temporary CPU mask in many places. It is equivalent to:
* struct cpumask tmp;
* cpumask_and(&tmp, &mask1, &mask2);
* for_each_cpu(cpu, &tmp)
* ...

task_numa_find_cpu() is a relatively deep function. Did you check
the stack usage to make sure it's not pushing too close to the stack
boundary? While there are other users of for_each_cpu_and, they are mostly
shallow although find_energy_efficient_cpu() is a bit questionable and
probably should have used select_idle_mask.

Does the patch have a noticable performance impact?

--
Mel Gorman
SUSE Labs