mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v2] sched/core: avoid calling select_task_rq cb if bound to one CPU for exec
@ 2025-12-01 10:55 Jianyong Wu
  2026-01-12  8:03 ` Jianyong Wu
  0 siblings, 1 reply; 2+ messages in thread
From: Jianyong Wu @ 2025-12-01 10:55 UTC (permalink / raw)
  To: peterz, mingo, juri.lelli, vincent.guittot
  Cc: dietmar.eggemann, rostedt, bsegall, mgorman, vschneid,
	linux-kernel, jianyong.wu, wujianyong, liuyibin

In the current implementation, even if the task calling execl is bound
to a single CPU (or not allowed to be migrated), it still invokes the
select_task_rq callback to select a CPU. This is unnecessary and
wastes cycles.

Since select_task_rq() already includes checks for the above scenarios
(e.g., tasks bound to a single CPU or forbidden to migrate) and skips
the select_task_rq callback in such cases, we can directly use
select_task_rq() instead of invoking the callback here.

Test environment: 256-CPU X86 server
Test method: Run unixbench's execl test with task bound to a single CPU:

  $ numactl -C 10 ./Run execl -c 1

Test results: Average of 5 runs

baseline    patched    improvement
383.82      436.78     +13.8%

Change Log:

v1->v2
As suggested by Peter, replace manual corner-case checks with
select_task_rq() to align with existing logic.

Additional testing on a 256-CPU server which all sched domains have
SD_BALANCE_EXEC flag, shows that sched_exec now searches all CPUs in the
system (previously, some SD_NUMA sched domains lacked SD_BALANCE_EXEC).
This increased the performance improvement to 13.8%.

Suggested-by: Peter Zijlstra <peterz@infradead.org>
Co-developed-by: Yibin Liu <liuyibin@hygon.cn>
Signed-off-by: Yibin Liu <liuyibin@hygon.cn>
Signed-off-by: Jianyong Wu <wujianyong@hygon.cn>
---
 kernel/sched/core.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index f754a60de848..6e4ba3c27e5c 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -5439,10 +5439,11 @@ void sched_exec(void)
 {
 	struct task_struct *p = current;
 	struct migration_arg arg;
-	int dest_cpu;
+	int dest_cpu, wake_flag = WF_EXEC;
 
 	scoped_guard (raw_spinlock_irqsave, &p->pi_lock) {
-		dest_cpu = p->sched_class->select_task_rq(p, task_cpu(p), WF_EXEC);
+		dest_cpu = select_task_rq(p, task_cpu(p), &wake_flag);
+
 		if (dest_cpu == smp_processor_id())
 			return;
 
-- 
2.43.0



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-01-12  8:24 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-12-01 10:55 [PATCH v2] sched/core: avoid calling select_task_rq cb if bound to one CPU for exec Jianyong Wu
2026-01-12  8:03 ` Jianyong Wu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®