Re: [PATCH 5/5] sched/fair: Unify cfs_rq throttling via account_cfs_rq_runtime()
From: Peter Zijlstra
Date: Mon Jun 01 2026 - 09:51:34 EST
On Thu, May 28, 2026 at 09:48:30AM +0000, K Prateek Nayak wrote:
> @@ -9893,8 +9882,15 @@ static struct task_struct *pick_task_fair(struct rq *rq, struct rq_flags *rf)
> /* Might not have done put_prev_entity() */
> if (cfs_rq->curr && cfs_rq->curr->on_rq)
> update_curr(cfs_rq);
> -
> - throttled |= check_cfs_rq_runtime(cfs_rq);
> + /*
> + * For the current hierarchy, update_curr() above would
> + * have set the throttle indicators if the cfs_rq has
> + * run out of bandwidth. For others, enqueue / last
> + * update_curr() for the cfs_rq would have ensured the
> + * throttle indicators are set if bandwidth was not
> + * available.
> + */
> + throttled |= cfs_rq_throttled(cfs_rq);
>
> se = pick_next_entity(rq, cfs_rq, true);
> if (!se)
> @@ -15074,15 +15070,19 @@ static void __set_next_task_fair(struct rq *rq, struct task_struct *p, bool firs
> static void set_next_task_fair(struct rq *rq, struct task_struct *p, bool first)
> {
> struct sched_entity *se = &p->se;
> + bool throttled = false;
>
> for_each_sched_entity(se) {
> struct cfs_rq *cfs_rq = cfs_rq_of(se);
>
> set_next_entity(cfs_rq, se, first);
> /* ensure bandwidth has been allocated on our new cfs_rq */
> - account_cfs_rq_runtime(cfs_rq, 0);
> + throttled |= account_cfs_rq_runtime(cfs_rq, 0);
> }
>
> + if (throttled)
> + task_throttle_setup_work(p);
> +
> __set_next_task_fair(rq, p, first);
> }
(noticed while trying to rebase flat on top)
Why do we have both? Isn't just set_next_task_fair(.first=true)
sufficient?