Skip to contentSkip to conversation

sched/fair: simplify task_numa_find_cpu()

PATCH RESEND Applied Yury Norov (NVIDIA) 2 participants 2 messages Dec 7, 2025 – Jan 12 Scheduler

lore
Share & tools
lore
#0 lore raw

PATCH RESEND 1/1 sched/fair: simplify task_numa_find_cpu()

Use for_each_cpu_and() and drop some housekeeping code.

---
Rebased and re-tested on top of master. Original patch:
https://lore.kernel.org/all/[email protected]/

 kernel/sched/fair.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)
kernel/sched/fair.c +2 -5
index da46c3164537..3ead55e4b8a5 100644
@@ -2458,11 +2458,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;
Signature · 1 line
2.43.0
#1 lore raw

[tip: sched/core] sched/fair: Simplify task_numa_find_cpu()

The following commit has been merged into the sched/core branch of tip:

The following commit has been merged into the sched/core branch of tip:

Commit-ID:     0ab25ea2a3b3a973fb914d0e47dc9c3c26049e8b
Gitweb:        https://git.kernel.org/tip/0ab25ea2a3b3a973fb914d0e47dc9c3c26049e8b
Author:        Yury Norov (NVIDIA) <[email protected]>
AuthorDate:    Sat, 06 Dec 2025 22:30:36 -05:00
Committer:     Peter Zijlstra <[email protected]>
CommitterDate: Thu, 08 Jan 2026 12:43:56 +01:00

sched/fair: Simplify task_numa_find_cpu()

Use for_each_cpu_and() and drop some housekeeping code.

---
 kernel/sched/fair.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)
kernel/sched/fair.c +2 -5
index 64275d7..842a0f2 100644
@@ -2494,11 +2494,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;