diff options
| author | Vincent Guittot <vincent.guittot@linaro.org> | 2026-06-24 17:12:24 +0200 |
|---|---|---|
| committer | Peter Zijlstra <peterz@infradead.org> | 2026-06-30 10:56:54 +0200 |
| commit | 8f97b627ff1c9b0f2eba71b326ac09326bf6b4ea (patch) | |
| tree | e4d1bd83094829c3887cf04462dec85af7073446 | |
| parent | 3cd1f657fae568904564b572e1a8e708e50c3b5e (diff) | |
| download | linux-8f97b627ff1c9b0f2eba71b326ac09326bf6b4ea.tar.gz linux-8f97b627ff1c9b0f2eba71b326ac09326bf6b4ea.zip | |
sched/fair: Set next buddy for preempt short
If a shorter slice task can preempt current at wakeup, we make sure that
the decision will not be overwritten in between by setting the task as the
next buddy. This still implies that the waking task remains eligible when
the scheduler will actually pick the next task to run.
Signed-off-by: Vincent Guittot <vincent.guittot@linaro.org>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Tested-by: K Prateek Nayak <kprateek.nayak@amd.com>
Link: https://patch.msgid.link/20260624151229.1710703-2-vincent.guittot@linaro.org
| -rw-r--r-- | kernel/sched/fair.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index 90d7f8346d71..976cc3ca72a7 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -9757,6 +9757,15 @@ static inline bool set_preempt_buddy(struct cfs_rq *cfs_rq, struct sched_entity return true; } +static inline bool set_short_buddy(struct cfs_rq *cfs_rq, struct sched_entity *pse) +{ + if (cfs_rq->next && cfs_rq->next->slice < pse->slice) + return false; + + set_next_buddy(cfs_rq, pse); + return true; +} + /* * WF_SYNC|WF_TTWU indicates the waker expects to sleep but it is not * strictly enforced because the hint is either misunderstood or @@ -9931,7 +9940,7 @@ pick: preempt: if (preempt_action == PREEMPT_WAKEUP_SHORT) { cancel_protect_slice(se); - clear_buddies(cfs_rq, se); + set_short_buddy(cfs_rq, pse); } resched_curr_lazy(rq); |
