From 83b97a283a9eac10a9571ed9004316b55b72277a Mon Sep 17 00:00:00 2001 From: Peter Zijlstra Date: Fri, 29 Nov 2024 11:15:41 +0100 Subject: [PATCH] sched/fair: Untangle NEXT_BUDDY and pick_next_task() BugLink: https://bugs.launchpad.net/bugs/2111953 [ Upstream commit 2a77e4be12cb58bbf774e7c717c8bb80e128b7a4 ] There are 3 sites using set_next_buddy() and only one is conditional on NEXT_BUDDY, the other two sites are unconditional; to note: - yield_to_task() - cgroup dequeue / pick optimization However, having NEXT_BUDDY control both the wakeup-preemption and the picking side of things means its near useless. Fixes: 147f3efaa241 ("sched/fair: Implement an EEVDF-like scheduling policy") Signed-off-by: Peter Zijlstra (Intel) Link: https://lkml.kernel.org/r/20241129101541.GA33464@noisy.programming.kicks-ass.net Signed-off-by: Sasha Levin Signed-off-by: Manuel Diewald Signed-off-by: Mehmet Basaran --- kernel/sched/fair.c | 4 ++-- kernel/sched/features.h | 9 +++++++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index 7911a402c931..c8a98e0d82d5 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -5474,9 +5474,9 @@ static struct sched_entity * pick_next_entity(struct cfs_rq *cfs_rq) { /* - * Enabling NEXT_BUDDY will affect latency but not fairness. + * Picking the ->next buddy will affect latency but not fairness. */ - if (sched_feat(NEXT_BUDDY) && + if (sched_feat(PICK_BUDDY) && cfs_rq->next && entity_eligible(cfs_rq, cfs_rq->next)) return cfs_rq->next; diff --git a/kernel/sched/features.h b/kernel/sched/features.h index 143f55df890b..f2a13a01dd7b 100644 --- a/kernel/sched/features.h +++ b/kernel/sched/features.h @@ -15,6 +15,15 @@ SCHED_FEAT(RUN_TO_PARITY, true) */ SCHED_FEAT(NEXT_BUDDY, false) +/* + * Allow completely ignoring cfs_rq->next; which can be set from various + * places: + * - NEXT_BUDDY (wakeup preemption) + * - yield_to_task() + * - cgroup dequeue / pick + */ +SCHED_FEAT(PICK_BUDDY, true) + /* * Consider buddies to be cache hot, decreases the likeliness of a * cache buddy being migrated away, increases cache locality.