All of lore.kernel.org
 help / color / mirror / Atom feed
From: Benjamin Segall <bsegall@google.com>
To: Zhe Liu <liuzhe1@kylinos.cn>
Cc: tj@kernel.org,  hannes@cmpxchg.org,  mkoutny@suse.com,
	 corbet@lwn.net, mingo@redhat.com,  peterz@infradead.org,
	 juri.lelli@redhat.com, vincent.guittot@linaro.org,
	 skhan@linuxfoundation.org, rdunlap@infradead.org,
	 dietmar.eggemann@arm.com,  rostedt@goodmis.org, mgorman@suse.de,
	 vschneid@redhat.com,  kprateek.nayak@amd.com,
	dtcccc@linux.alibaba.com,  changhuaixin@linux.alibaba.com,
	shanpeic@linux.alibaba.com,  cgroups@vger.kernel.org,
	linux-doc@vger.kernel.org,  linux-kernel@vger.kernel.org,
	linux-kselftest@vger.kernel.org,  Tao Cui <cuitao@kylinos.cn>
Subject: Re: [PATCH v3 1/3] sched/fair: remove quota/burst write-order dependency
Date: Fri, 18 Sep 2026 14:41:05 -0700	[thread overview]
Message-ID: <xm2633v6w83y.fsf@google.com> (raw)
In-Reply-To: <20260911092258.660771-2-liuzhe1@kylinos.cn> (Zhe Liu's message of "Fri, 11 Sep 2026 17:22:56 +0800")

Zhe Liu <liuzhe1@kylinos.cn> writes:

> Burst validation currently depends on the active quota, so the same quota
> and burst values may be accepted or rejected depending on the order in
> which userspace updates them.
>
> Make burst validation independent of the current quota while preserving,
> for finite quotas, the previous maximum configurable burst at
> max_bw_runtime_us / 2. Keep the configured burst across quota updates and
> cap the effective burst to min(burst, quota) when CFS runtime is refilled.
>
> Fixes: f4183717b370 ("sched/fair: Introduce the burstable CFS controller")
> Signed-off-by: Zhe Liu <liuzhe1@kylinos.cn>
> Tested-by: Tao Cui <cuitao@kylinos.cn>
> Reviewed-by: Michal Koutný <mkoutny@suse.com>

Yeah, all the state validation that winds up requiring doing edits in a
particular order is annoying and imo not particularly valuable.

Reviewed-by: Ben Segall <bsegall@google.com>

> ---
>  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 b998ef6b87af..c399f0a59c25 100644
> --- a/kernel/sched/core.c
> +++ b/kernel/sched/core.c
> @@ -10181,8 +10181,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 / 2)
>  		return -EINVAL;
>  
>  #ifdef CONFIG_CFS_BANDWIDTH
> diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
> index ade1eceb39b8..e6f9d9296fd2 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-18 21:41 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-11  9:22 [PATCH v3 0/3] sched/fair: remove quota/burst write-order dependency Zhe Liu
2026-09-11  9:22 ` [PATCH v3 1/3] " Zhe Liu
2026-09-18 21:41   ` Benjamin Segall [this message]
2026-09-11  9:22 ` [PATCH v3 2/3] selftests: cgroup: test CPU quota and burst write order Zhe Liu
2026-09-11  9:22 ` [PATCH v3 3/3] docs: cgroup-v2: document CPU quota and burst ordering 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=xm2633v6w83y.fsf@google.com \
    --to=bsegall@google.com \
    --cc=cgroups@vger.kernel.org \
    --cc=changhuaixin@linux.alibaba.com \
    --cc=corbet@lwn.net \
    --cc=cuitao@kylinos.cn \
    --cc=dietmar.eggemann@arm.com \
    --cc=dtcccc@linux.alibaba.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=rdunlap@infradead.org \
    --cc=rostedt@goodmis.org \
    --cc=shanpeic@linux.alibaba.com \
    --cc=skhan@linuxfoundation.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 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.