* [PATCH] sched/fair: Simplify task_numa_find_cpu()
@ 2021-10-30 7:25 Yuan ZhaoXiong
2021-11-01 11:18 ` Mel Gorman
0 siblings, 1 reply; 5+ messages in thread
From: Yuan ZhaoXiong @ 2021-10-30 7:25 UTC (permalink / raw)
To: mingo, peterz, juri.lelli, vincent.guittot, dietmar.eggemann,
rostedt, bsegall, mgorman, bristot
Cc: linux-kernel
Combine the 'cpumask_of_node()' with 'env->p->cpus_ptr' and drop the
cpumask_test_cpu().
Signed-off-by: Yuan ZhaoXiong <yuanzhaoxiong@baidu.com>
---
kernel/sched/fair.c | 6 +-----
1 file changed, 1 insertion(+), 5 deletions(-)
diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index f6a05d9..dc064d7 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -1950,11 +1950,7 @@ static void task_numa_find_cpu(struct task_numa_env *env,
maymove = !load_too_imbalanced(src_load, dst_load, env);
}
- for_each_cpu(cpu, cpumask_of_node(env->dst_nid)) {
- /* Skip this CPU if the source task cannot migrate */
- if (!cpumask_test_cpu(cpu, env->p->cpus_ptr))
- continue;
-
+ for_each_cpu_and(cpu, cpumask_of_node(env->dst_nid), env->p->cpus_ptr) {
env->dst_cpu = cpu;
if (task_numa_compare(env, taskimp, groupimp, maymove))
break;
--
1.8.3.1
^ permalink raw reply related [flat|nested] 5+ messages in thread* Re: [PATCH] sched/fair: Simplify task_numa_find_cpu()
2021-10-30 7:25 [PATCH] sched/fair: Simplify task_numa_find_cpu() Yuan ZhaoXiong
@ 2021-11-01 11:18 ` Mel Gorman
0 siblings, 0 replies; 5+ messages in thread
From: Mel Gorman @ 2021-11-01 11:18 UTC (permalink / raw)
To: Yuan ZhaoXiong
Cc: mingo, peterz, juri.lelli, vincent.guittot, dietmar.eggemann,
rostedt, bsegall, bristot, linux-kernel
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@baidu.com>
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
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH] sched/fair: simplify task_numa_find_cpu()
@ 2025-09-11 20:31 Yury Norov
2025-09-11 21:20 ` Phil Auld
2025-09-12 2:40 ` K Prateek Nayak
0 siblings, 2 replies; 5+ messages in thread
From: Yury Norov @ 2025-09-11 20:31 UTC (permalink / raw)
To: Ingo Molnar, Peter Zijlstra, Juri Lelli, Vincent Guittot,
Dietmar Eggemann, Steven Rostedt, Ben Segall, Mel Gorman,
Valentin Schneider, linux-kernel
Cc: Yury Norov
From: Yury Norov (NVIDIA) <yury.norov@gmail.com>
Use for_each_cpu_and() and drop some housekeeping code.
Signed-off-by: Yury Norov (NVIDIA) <yury.norov@gmail.com>
---
kernel/sched/fair.c | 7 ++-----
1 file changed, 2 insertions(+), 5 deletions(-)
diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index 0990ed90c14e..c48c0975fe7a 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -2474,11 +2474,8 @@ static void task_numa_find_cpu(struct task_numa_env *env,
maymove = !load_too_imbalanced(src_load, dst_load, env);
}
- for_each_cpu(cpu, cpumask_of_node(env->dst_nid)) {
- /* Skip this CPU if the source task cannot migrate */
- if (!cpumask_test_cpu(cpu, env->p->cpus_ptr))
- continue;
-
+ /* Skip CPUs if the source task cannot migrate */
+ for_each_cpu_and(cpu, cpumask_of_node(env->dst_nid), env->p->cpus_ptr) {
env->dst_cpu = cpu;
if (task_numa_compare(env, taskimp, groupimp, maymove))
break;
--
2.43.0
^ permalink raw reply related [flat|nested] 5+ messages in thread* Re: [PATCH] sched/fair: simplify task_numa_find_cpu()
2025-09-11 20:31 [PATCH] sched/fair: simplify task_numa_find_cpu() Yury Norov
@ 2025-09-11 21:20 ` Phil Auld
2025-09-12 2:40 ` K Prateek Nayak
1 sibling, 0 replies; 5+ messages in thread
From: Phil Auld @ 2025-09-11 21:20 UTC (permalink / raw)
To: Yury Norov
Cc: Ingo Molnar, Peter Zijlstra, Juri Lelli, Vincent Guittot,
Dietmar Eggemann, Steven Rostedt, Ben Segall, Mel Gorman,
Valentin Schneider, linux-kernel
On Thu, Sep 11, 2025 at 04:31:35PM -0400 Yury Norov wrote:
> From: Yury Norov (NVIDIA) <yury.norov@gmail.com>
>
> Use for_each_cpu_and() and drop some housekeeping code.
>
> Signed-off-by: Yury Norov (NVIDIA) <yury.norov@gmail.com>
The "housekeeping" part threw me off for a second. I was looking for
isolation related code being dropped :)
Reviewed-by: Phil Auld <pauld@redhat.com>
> ---
> kernel/sched/fair.c | 7 ++-----
> 1 file changed, 2 insertions(+), 5 deletions(-)
>
> diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
> index 0990ed90c14e..c48c0975fe7a 100644
> --- a/kernel/sched/fair.c
> +++ b/kernel/sched/fair.c
> @@ -2474,11 +2474,8 @@ static void task_numa_find_cpu(struct task_numa_env *env,
> maymove = !load_too_imbalanced(src_load, dst_load, env);
> }
>
> - for_each_cpu(cpu, cpumask_of_node(env->dst_nid)) {
> - /* Skip this CPU if the source task cannot migrate */
> - if (!cpumask_test_cpu(cpu, env->p->cpus_ptr))
> - continue;
> -
> + /* Skip CPUs if the source task cannot migrate */
> + for_each_cpu_and(cpu, cpumask_of_node(env->dst_nid), env->p->cpus_ptr) {
> env->dst_cpu = cpu;
> if (task_numa_compare(env, taskimp, groupimp, maymove))
> break;
> --
> 2.43.0
>
>
--
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [PATCH] sched/fair: simplify task_numa_find_cpu()
2025-09-11 20:31 [PATCH] sched/fair: simplify task_numa_find_cpu() Yury Norov
2025-09-11 21:20 ` Phil Auld
@ 2025-09-12 2:40 ` K Prateek Nayak
1 sibling, 0 replies; 5+ messages in thread
From: K Prateek Nayak @ 2025-09-12 2:40 UTC (permalink / raw)
To: Yury Norov, Ingo Molnar, Peter Zijlstra, Juri Lelli,
Vincent Guittot, Dietmar Eggemann, Steven Rostedt, Ben Segall,
Mel Gorman, Valentin Schneider, linux-kernel
Hello Yury,
On 9/12/2025 2:01 AM, Yury Norov wrote:
> From: Yury Norov (NVIDIA) <yury.norov@gmail.com>
>
> Use for_each_cpu_and() and drop some housekeeping code.
Please feel free to include:
Reviewed-by: K Prateek Nayak <kprateek.nayak@amd.com>
>
> Signed-off-by: Yury Norov (NVIDIA) <yury.norov@gmail.com>
> ---
> kernel/sched/fair.c | 7 ++-----
> 1 file changed, 2 insertions(+), 5 deletions(-)
>
> diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
> index 0990ed90c14e..c48c0975fe7a 100644
> --- a/kernel/sched/fair.c
> +++ b/kernel/sched/fair.c
> @@ -2474,11 +2474,8 @@ static void task_numa_find_cpu(struct task_numa_env *env,
> maymove = !load_too_imbalanced(src_load, dst_load, env);
> }
>
> - for_each_cpu(cpu, cpumask_of_node(env->dst_nid)) {
> - /* Skip this CPU if the source task cannot migrate */
> - if (!cpumask_test_cpu(cpu, env->p->cpus_ptr))
> - continue;
> -
> + /* Skip CPUs if the source task cannot migrate */
> + for_each_cpu_and(cpu, cpumask_of_node(env->dst_nid), env->p->cpus_ptr) {
> env->dst_cpu = cpu;
> if (task_numa_compare(env, taskimp, groupimp, maymove))
> break;
--
Thanks and Regards,
Prateek
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2025-09-12 2:40 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-10-30 7:25 [PATCH] sched/fair: Simplify task_numa_find_cpu() Yuan ZhaoXiong
2021-11-01 11:18 ` Mel Gorman
-- strict thread matches above, loose matches on Subject: below --
2025-09-11 20:31 [PATCH] sched/fair: simplify task_numa_find_cpu() Yury Norov
2025-09-11 21:20 ` Phil Auld
2025-09-12 2:40 ` K Prateek Nayak
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.