[PATCH 3/3] sched/core: Check CFS bandwidth against the donor for NOHZ

From: Jemmy Wong

Date: Thu Oct 08 2026 - 09:33:25 EST


sched_can_stop_tick() tests rq->curr, the execution context, for CFS
bandwidth. Quota is consumed by the donor, the scheduling context:
account_cfs_rq_runtime() charges rq->donor's cfs_rq, and
sched_fair_update_stop_tick() already passes the donor picked in
set_next_task_fair() to cfs_task_bw_constrained().

Test rq->donor in sched_can_stop_tick() as well, so both callers name
the task whose quota is consumed. The tick decision is unchanged:
both paths return before the bandwidth test unless nr_running == 1,
and proxy execution keeps the donor and the lock holder (curr) queued.
Without CONFIG_SCHED_PROXY_EXEC, curr and donor are a union and
therefore the same task.

No functional change.

Signed-off-by: Jemmy Wong <jemmywong512@xxxxxxxxx>
Assisted-by: LLM
---
kernel/sched/core.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index b2005fafae59..7eddbc14ddcb 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -1477,9 +1477,11 @@ bool sched_can_stop_tick(struct rq *rq)
* This check prevents clearing the bit if a newly enqueued task here is
* dequeued by migrating while the constrained task continues to run.
* E.g. going from 2->1 without going through pick_next_task().
+ *
+ * Test the donor, as sched_fair_update_stop_tick() does.
*/
- if (__need_bw_check(rq, rq->curr)) {
- if (cfs_task_bw_constrained(rq->curr))
+ if (__need_bw_check(rq, rq->donor)) {
+ if (cfs_task_bw_constrained(rq->donor))
return false;
}

--
2.54.0 (Apple Git-157)