All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Fernand Sieber" <sieberf@amazon.com>
Cc: sched-ext@lists.linux.dev, bpf@vger.kernel.org, tj@kernel.org,
	hannes@cmpxchg.org, mkoutny@suse.com
Subject: Re: [PATCH v2 2/4] sched/fair: refill bandwidth for the periods the timer slept through
Date: Tue, 10 Nov 2026 11:29:06 +0000	[thread overview]
Message-ID: <sashiko-outbox-206938@kernel.org> (raw)
In-Reply-To: <681751a52093faada8da25d8dbccc59444c3d251.1794303670.git.sieberf@amazon.com>

Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] sched/fair: period_timer forwarded with old period in
  tg_set_cfs_bandwidth()
--

commit 6dcac4d8cedf5c5fafb47bd8f0ac725a2be649bc
Author: Fernand Sieber <sieberf@amazon.com>

sched/fair: refill bandwidth for the periods the timer slept through

This commit refills a CFS group's accumulated bandwidth for the period
boundaries missed while its period timer was stopped, capped at quota +
burst, and updates bandwidth configuration and cpu.max.runtime reads and
writes to account for those idle periods.

> diff --git a/kernel/sched/core.c b/kernel/sched/core.c
> index 76fcd70ff207a..75a5f5d1b8f54 100644
> --- a/kernel/sched/core.c
> +++ b/kernel/sched/core.c
> @@ -9856,6 +9856,12 @@ static int tg_set_cfs_bandwidth(struct task_group *tg,
>  		cfs_bandwidth_usage_inc();
>  
>  	scoped_guard (raw_spinlock_irq, &cfs_b->lock) {
> +		/*
> +		 * The new bandwidth applies from now on. The group keeps what
> +		 * it earned while idle under the old one.
> +		 */
> +		cfs_bandwidth_refill_idle_periods(cfs_b);
> +
>  		cfs_b->period = ns_to_ktime(period);
>  		cfs_b->quota = quota;
>  		cfs_b->burst = burst;

[Severity: Medium]
When cfs_b->period_active is 0, does calling
cfs_bandwidth_refill_idle_periods() before updating cfs_b->period arm
cfs_b->period_timer with the old period's expiry instead of the new one?

cfs_bandwidth_refill_idle_periods() calls hrtimer_forward_now() with the
old cfs_b->period, pushing period_timer's expiry into (now, now +
old_period].  When tg_set_cfs_bandwidth() then calls
start_cfs_bandwidth() after updating cfs_b->period:

kernel/sched/core.c:tg_set_cfs_bandwidth() {
	...
		__refill_cfs_bandwidth_runtime(cfs_b);

		/*
		 * Restart the period timer (if active) to handle new
		 * period expiry:
		 */
		if (runtime_enabled)
			start_cfs_bandwidth(cfs_b);
	}
}

the second cfs_bandwidth_refill_idle_periods() call inside
start_cfs_bandwidth() sees an expiry already in the future, so
hrtimer_forward_now() returns 0 without adjusting it to the new period.
When a newly created cgroup (initialized with a 100ms period) or an idle
cgroup is configured with a shorter period such as 1ms,
hrtimer_start_expires() arms period_timer up to old_period in the future,
starving the group of refills for that interval after its initial quota is
spent.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/cover.1794303670.git.sieberf@amazon.com?part=2

  reply	other threads:[~2026-11-10 11:29 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-10 11:08 [PATCH v2 0/4] sched/fair: cpu.max.runtime and idle refill for CPU credits Fernand Sieber
2026-11-10 11:08 ` [PATCH v2 1/4] sched/fair: expose cpu.max.runtime to set bandwidth runtime directly Fernand Sieber
2026-11-10 11:28   ` sashiko-bot
2026-11-11  8:28   ` bot+bpf-ci
2026-11-10 11:08 ` [PATCH v2 2/4] sched/fair: refill bandwidth for the periods the timer slept through Fernand Sieber
2026-11-10 11:29   ` sashiko-bot [this message]
2026-11-10 11:08 ` [PATCH v2 3/4] sched_ext: add cgroup_set_runtime ops callback Fernand Sieber
2026-11-11  8:08   ` bot+bpf-ci
2026-11-10 11:08 ` [PATCH v2 4/4] sched_ext: charge BPF scheduler tasks to cpu.max bandwidth Fernand Sieber
2026-11-10 11:39   ` sashiko-bot
2026-11-11  8:28   ` bot+bpf-ci
2026-11-10 20:10 ` [PATCH v2 0/4] sched/fair: cpu.max.runtime and idle refill for CPU credits Tejun Heo
2026-11-11 12:20   ` Fernand Sieber
2026-11-11 17:26     ` Tejun Heo
2026-11-12  8:11       ` Fernand Sieber
2026-11-11 12:29 ` [PATCH v3 0/2] sched/fair: cpu.max.runtime and idle refill for a burstable budget Fernand Sieber
2026-11-11 12:29   ` [PATCH v3 1/2] sched/fair: expose cpu.max.runtime to set bandwidth runtime directly Fernand Sieber
2026-11-11 12:29   ` [PATCH v3 2/2] sched/fair: refill bandwidth for the periods the timer slept through Fernand Sieber

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=sashiko-outbox-206938@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=hannes@cmpxchg.org \
    --cc=mkoutny@suse.com \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=sched-ext@lists.linux.dev \
    --cc=sieberf@amazon.com \
    --cc=tj@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.