Fix a group-throttling bug in the fair scheduler.

Signed-off-by: Ingo Molnar <mingo@kernel.org>
 -----BEGIN PGP SIGNATURE-----
 
 iQJFBAABCgAvFiEEBpT5eoXrXCwVQwEKEnMQ0APhK1gFAmkPQRgRHG1pbmdvQGtl
 cm5lbC5vcmcACgkQEnMQ0APhK1jtjQ//UM9YfdauTXacEE2dPG4b0QwxHPgMsFmS
 GMT7c6H7ApCQoiBnGwv3K0d0bu4FZwnWBMulUv/yhe49vHXdIPdZAlMkJrM3IA7X
 80IVCfLHtRkbMaAUIDc3MGwkzneCUIuzKPPH1iXqn9/R0zBB8S7qxt4XHyBHzlX7
 uCNbFkUFhrh5s3sWond2ogAlCvGiZ5Qo7/oTfNrpOmYGvXfNIh4T1zDOWpPrsKLX
 Md6rucBs0bcV1vlyKwNrobqOuaS0mdSxjt+SKDuI1CdCj6mNbYvjLPinnAi2n3zZ
 CLaI8+rBe3JpLOH+kXuOf+CUatXDBjF4GO1k6XXwvcsK4ARqmKcbk9Xs3i/Tn/bm
 Ls7IdLkCrekXaGU2MlYLVg0twe+O5oUgwBpa4Ap/IObbI+fIKP/Pj2blZlpT1RlY
 J455LrldsMUy1NWaqVd13gCGOPGzR6SrD+ruOJS4BAK3JFyRw8rdDW4zJ7qEiCRj
 yejZfiFcCAoD7cqFJoCon6rt+WC3T5I1/Sc40JCmfKH/GhLzTAGt/8cRaic4ntRX
 Yv8T/lJVgjhGqfDWmcRYZVF/SiyZq8IP+wqrpr3ETAfRhqB5ZhQHPUGZPPDDeeqH
 QHEYSrWdbmxKqYpBK3nwgwAIz9dSJcdQUqWLvP85rjRTeLr08/reXha4P80RJ3wz
 XmLzR7KQ9mI=
 =zLw8
 -----END PGP SIGNATURE-----

Merge tag 'sched-urgent-2025-11-08' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip

Pull scheduler fix from Ingo Molnar:
 "Fix a group-throttling bug in the fair scheduler"

* tag 'sched-urgent-2025-11-08' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
  sched/fair: Prevent cfs_rq from being unthrottled with zero runtime_remaining
This commit is contained in:
Linus Torvalds 2025-11-08 08:59:05 -08:00
commit b5c0946029
2 changed files with 7 additions and 10 deletions

View File

@ -9606,7 +9606,7 @@ static int tg_set_cfs_bandwidth(struct task_group *tg,
guard(rq_lock_irq)(rq); guard(rq_lock_irq)(rq);
cfs_rq->runtime_enabled = runtime_enabled; cfs_rq->runtime_enabled = runtime_enabled;
cfs_rq->runtime_remaining = 0; cfs_rq->runtime_remaining = 1;
if (cfs_rq->throttled) if (cfs_rq->throttled)
unthrottle_cfs_rq(cfs_rq); unthrottle_cfs_rq(cfs_rq);

View File

@ -6024,20 +6024,17 @@ void unthrottle_cfs_rq(struct cfs_rq *cfs_rq)
struct sched_entity *se = cfs_rq->tg->se[cpu_of(rq)]; struct sched_entity *se = cfs_rq->tg->se[cpu_of(rq)];
/* /*
* It's possible we are called with !runtime_remaining due to things * It's possible we are called with runtime_remaining < 0 due to things
* like user changed quota setting(see tg_set_cfs_bandwidth()) or async * like async unthrottled us with a positive runtime_remaining but other
* unthrottled us with a positive runtime_remaining but other still * still running entities consumed those runtime before we reached here.
* running entities consumed those runtime before we reached here.
* *
* Anyway, we can't unthrottle this cfs_rq without any runtime remaining * We can't unthrottle this cfs_rq without any runtime remaining because
* because any enqueue in tg_unthrottle_up() will immediately trigger a * any enqueue in tg_unthrottle_up() will immediately trigger a throttle,
* throttle, which is not supposed to happen on unthrottle path. * which is not supposed to happen on unthrottle path.
*/ */
if (cfs_rq->runtime_enabled && cfs_rq->runtime_remaining <= 0) if (cfs_rq->runtime_enabled && cfs_rq->runtime_remaining <= 0)
return; return;
se = cfs_rq->tg->se[cpu_of(rq)];
cfs_rq->throttled = 0; cfs_rq->throttled = 0;
update_rq_clock(rq); update_rq_clock(rq);