mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Tao Cui <cui.tao@linux.dev>
To: Zhe Liu <liuzhe1@kylinos.cn>, mkoutny@suse.com
Cc: cui.tao@linux.dev, bsegall@google.com, cgroups@vger.kernel.org,
	corbet@lwn.net, dietmar.eggemann@arm.com, hannes@cmpxchg.org,
	juri.lelli@redhat.com, kprateek.nayak@amd.com,
	linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-kselftest@vger.kernel.org, mgorman@suse.de,
	mingo@redhat.com, peterz@infradead.org, rostedt@goodmis.org,
	skhan@linuxfoundation.org, tj@kernel.org,
	vincent.guittot@linaro.org, vschneid@redhat.com,
	stable@vger.kernel.org
Subject: Re: [PATCH v2 1/3] sched/fair: Remove the write-order dependency between cpu.max and cpu.max.burst
Date: Fri, 4 Sep 2026 17:21:42 +0800	[thread overview]
Message-ID: <ce007c25-8d49-4df4-9508-3af911f90eb7@linux.dev> (raw)
In-Reply-To: <20260904062013.504236-2-liuzhe1@kylinos.cn>

Hi, Zhe,

在 2026/9/4 14:20, Zhe Liu 写道:
> Keep the configured burst independent of the current quota and cap it
> when CFS refills runtime. This allows quota and burst updates in either
> order.
> 

Ran the selftests on next-20260903 in a VM: all 10 test_cpu cases pass
with the series applied, and test_cpucg_max_burst fails on the unpatched
kernel, so the test does catch the old behavior.

One problem (spotted by sashiko, an automated overflow checker; I
re-did the arithmetic): dropping the burst_us + quota_us <=
max_bw_runtime_us check is not safe. With quota and burst both near
MAX_BW, the period-scaling path in sched_cfs_period_timer() can double
both up to 512x, and the new clamp quota + min(burst, quota) in
__refill_cfs_bandwidth_runtime() then wraps u64 to 0, leaving the group
with zero runtime on every refill.

I believe you can just drop the burst_us > quota_us comparison and keep
the sum check. Both write-order cases still pass that way: burst=80ms
with quota=50ms gives 130ms, well under the limit.

Tested-by: Tao Cui <cuitao@kylinos.cn>

> Fixes: f4183717b370 ("sched/fair: Introduce the burstable CFS controller")
> 
> Cc: stable@vger.kernel.org
> Signed-off-by: Zhe Liu <liuzhe1@kylinos.cn>
> ---
>  kernel/sched/core.c | 3 +--
>  kernel/sched/fair.c | 3 ++-
>  2 files changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/kernel/sched/core.c b/kernel/sched/core.c
> index f78275192036..5269b8cfcf7f 100644
> --- a/kernel/sched/core.c
> +++ b/kernel/sched/core.c
> @@ -10159,8 +10159,7 @@ static int tg_set_bandwidth(struct task_group *tg,
>  	if (quota_us != RUNTIME_INF && quota_us > max_bw_runtime_us)
>  		return -EINVAL;
>  
> -	if (quota_us != RUNTIME_INF && (burst_us > quota_us ||
> -					burst_us + quota_us > max_bw_runtime_us))
> +	if (burst_us > max_bw_runtime_us)
>  		return -EINVAL;
>  
>  #ifdef CONFIG_CFS_BANDWIDTH
> diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
> index 6d881e530f89..488de18d477e 100644
> --- a/kernel/sched/fair.c
> +++ b/kernel/sched/fair.c
> @@ -6627,7 +6627,8 @@ void __refill_cfs_bandwidth_runtime(struct cfs_bandwidth *cfs_b)
>  		cfs_b->nr_burst++;
>  	}
>  
> -	cfs_b->runtime = min(cfs_b->runtime, cfs_b->quota + cfs_b->burst);
> +	cfs_b->runtime = min(cfs_b->runtime,
> +			     cfs_b->quota + min(cfs_b->burst, cfs_b->quota));
>  	cfs_b->runtime_snap = cfs_b->runtime;
>  }
>  


  reply	other threads:[~2026-09-04  9:21 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-20  3:32 [PATCH 0/2] sched/fair: Reset incompatible burst on quota change Zhe Liu
2026-08-20  3:32 ` [PATCH 1/2] " Zhe Liu
2026-08-20 11:43   ` Michal Koutný
2026-08-26  3:00     ` Zhe Liu
2026-09-04  6:20     ` [PATCH v2 0/3] sched/fair: remove quota/burst write-order dependency Zhe Liu
2026-09-04  6:20       ` [PATCH v2 1/3] sched/fair: Remove the write-order dependency between cpu.max and cpu.max.burst Zhe Liu
2026-09-04  9:21         ` Tao Cui [this message]
2026-09-04  6:20       ` [PATCH v2 2/3] selftests: cgroup: Test CPU quota and burst write order Zhe Liu
2026-09-04  6:20       ` [PATCH v2 3/3] Documentation: describe CPU quota and burst ordering Zhe Liu
2026-08-20  3:32 ` [PATCH 2/2] Documentation: describe burst reset on quota changes Zhe Liu

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=ce007c25-8d49-4df4-9508-3af911f90eb7@linux.dev \
    --to=cui.tao@linux.dev \
    --cc=bsegall@google.com \
    --cc=cgroups@vger.kernel.org \
    --cc=corbet@lwn.net \
    --cc=dietmar.eggemann@arm.com \
    --cc=hannes@cmpxchg.org \
    --cc=juri.lelli@redhat.com \
    --cc=kprateek.nayak@amd.com \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=liuzhe1@kylinos.cn \
    --cc=mgorman@suse.de \
    --cc=mingo@redhat.com \
    --cc=mkoutny@suse.com \
    --cc=peterz@infradead.org \
    --cc=rostedt@goodmis.org \
    --cc=skhan@linuxfoundation.org \
    --cc=stable@vger.kernel.org \
    --cc=tj@kernel.org \
    --cc=vincent.guittot@linaro.org \
    --cc=vschneid@redhat.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®