Skip to content

Commit 500d520

Browse files
author
CKI KWF Bot
committed
Merge: sched/fair: Block delayed tasks on throttled hierarchy during dequeue
MR: https://gitlab.com/redhat/centos-stream/src/kernel/centos-stream-10/-/merge_requests/1630 JIRA: https://issues.redhat.com/browse/RHEL-69492 Upstream Status: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git (v6.12.54) CONFLICTS: minor context conflict in the first chunk of the patch. commit e67e3e7 Author: K Prateek Nayak <kprateek.nayak@amd.com> Date: Wed Oct 15 06:03:59 2025 +0000 sched/fair: Block delayed tasks on throttled hierarchy during dequeue Dequeuing a fair task on a throttled hierarchy returns early on encountering a throttled cfs_rq since the throttle path has already dequeued the hierarchy above and has adjusted the h_nr_* accounting till the root cfs_rq. dequeue_entities() crucially misses calling __block_task() for delayed tasks being dequeued on the throttled hierarchies, but this was mostly harmless until commit b7ca574 ("sched/core: Tweak wait_task_inactive() to force dequeue sched_delayed tasks") since all existing cases would re-enqueue the task if task_on_rq_queued() returned true and the task would eventually be blocked at pick after the hierarchy was unthrottled. wait_task_inactive() is special as it expects the delayed task on throttled hierarchy to reach the blocked state on dequeue but since __block_task() is never called, task_on_rq_queued() continues to return true. Furthermore, since the task is now off the hierarchy, the pick never reaches it to fully block the task even after unthrottle leading to wait_task_inactive() looping endlessly. Remedy this by calling __block_task() if a delayed task is being dequeued on a throttled hierarchy. This fix is only required for stabled kernels implementing delay dequeue (>= v6.12) before v6.18 since upstream commit e1fad12 ("sched/fair: Switch to task based throttle model") indirectly fixes this by removing the early return conditions in dequeue_entities() as part of the per-task throttle feature. Cc: stable@vger.kernel.org Reported-by: Matt Fleming <matt@readmodwrite.com> Closes: https://lore.kernel.org/all/20250925133310.1843863-1-matt@readmodwrite.com/ Fixes: b7ca574 ("sched/core: Tweak wait_task_inactive() to force dequeue sched_delayed tasks") Tested-by: Matt Fleming <mfleming@cloudflare.com> Signed-off-by: K Prateek Nayak <kprateek.nayak@amd.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: Luis Claudio R. Goncalves <lgoncalv@redhat.com> Approved-by: Phil Auld <pauld@redhat.com> Approved-by: Tomas Glozar <tglozar@redhat.com> Approved-by: Gabriele Monaco <gmonaco@redhat.com> Approved-by: Crystal Wood <crwood@redhat.com> Approved-by: Clark Williams <williams@redhat.com> Approved-by: CKI KWF Bot <cki-ci-bot+kwf-gitlab-com@redhat.com> Merged-by: CKI GitLab Kmaint Pipeline Bot <26919896-cki-kmaint-pipeline-bot@users.noreply.gitlab.com>
2 parents 9436462 + d9b4357 commit 500d520

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

kernel/sched/fair.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6964,6 +6964,7 @@ static int dequeue_entities(struct rq *rq, struct sched_entity *se, int flags)
69646964
int h_nr_runnable = 0;
69656965
struct cfs_rq *cfs_rq;
69666966
u64 slice = 0;
6967+
int ret = 0;
69676968

69686969
if (entity_is_task(se)) {
69696970
p = task_of(se);
@@ -6993,7 +6994,7 @@ static int dequeue_entities(struct rq *rq, struct sched_entity *se, int flags)
69936994

69946995
/* end evaluation on encountering a throttled cfs_rq */
69956996
if (cfs_rq_throttled(cfs_rq))
6996-
return 0;
6997+
goto out;
69976998

69986999
/* Don't dequeue parent if it has other entities besides us */
69997000
if (cfs_rq->load.weight) {
@@ -7034,7 +7035,7 @@ static int dequeue_entities(struct rq *rq, struct sched_entity *se, int flags)
70347035

70357036
/* end evaluation on encountering a throttled cfs_rq */
70367037
if (cfs_rq_throttled(cfs_rq))
7037-
return 0;
7038+
goto out;
70387039
}
70397040

70407041
sub_nr_running(rq, h_nr_queued);
@@ -7043,6 +7044,8 @@ static int dequeue_entities(struct rq *rq, struct sched_entity *se, int flags)
70437044
if (unlikely(!was_sched_idle && sched_idle_rq(rq)))
70447045
rq->next_balance = jiffies;
70457046

7047+
ret = 1;
7048+
out:
70467049
if (p && task_delayed) {
70477050
WARN_ON_ONCE(!task_sleep);
70487051
WARN_ON_ONCE(p->on_rq != 1);
@@ -7058,7 +7061,7 @@ static int dequeue_entities(struct rq *rq, struct sched_entity *se, int flags)
70587061
__block_task(rq, p);
70597062
}
70607063

7061-
return 1;
7064+
return ret;
70627065
}
70637066

70647067
/*

0 commit comments

Comments
 (0)