[PATCH] sched_ext: add unlikely() hints in do_enqueue_task() hot path
From: David Carlier
Date: Thu Feb 26 2026 - 17:44:42 EST
Add unlikely() branch hints to the scx_rq_online() and
scx_rq_bypassing() checks in do_enqueue_task() that are rarely taken
during normal operation.
The PF_EXITING and migration_disabled checks are left unchanged as the
existing code already places unlikely() precisely on the runtime
condition.
Signed-off-by: David Carlier <devnexen@xxxxxxxxx>
---
kernel/sched/ext.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/kernel/sched/ext.c b/kernel/sched/ext.c
index c18e81e8ef51..9a888ce5e2f1 100644
--- a/kernel/sched/ext.c
+++ b/kernel/sched/ext.c
@@ -1360,10 +1360,10 @@ static void do_enqueue_task(struct rq *rq, struct task_struct *p, u64 enq_flags,
* is offline and are just running the hotplug path. Don't bother the
* BPF scheduler.
*/
- if (!scx_rq_online(rq))
+ if (unlikely(!scx_rq_online(rq)))
goto local;
- if (scx_rq_bypassing(rq)) {
+ if (unlikely(scx_rq_bypassing(rq))) {
__scx_add_event(sch, SCX_EV_BYPASS_DISPATCH, 1);
goto bypass;
}
--
2.51.0