From: Cheng Yu <serein.chengyu@huawei.com>
To: <mingo@redhat.com>, <peterz@infradead.org>,
<juri.lelli@redhat.com>, <vincent.guittot@linaro.org>,
<dietmar.eggemann@arm.com>, <rostedt@goodmis.org>,
<bsegall@google.com>, <mgorman@suse.de>, <bristot@redhat.com>,
<vschneid@redhat.com>, <changhuaixin@linux.alibaba.com>,
<shanpeic@linux.alibaba.com>, <dtcccc@linux.alibaba.com>,
<tj@kernel.org>, <linux-kernel@vger.kernel.org>
Cc: <zhangqiao22@huawei.com>, <judy.chenhui@huawei.com>,
<yusongping@huawei.com>, <zhaowenhui8@huawei.com>,
<liaoqixin@huawei.com>, <serein.chengyu@huawei.com>
Subject: [PATCH 1/2] sched/fair: limit burst to zero when cfs bandwidth is turned off
Date: Wed, 22 May 2024 11:10:06 +0800 [thread overview]
Message-ID: <20240522031007.643498-2-serein.chengyu@huawei.com> (raw)
In-Reply-To: <20240522031007.643498-1-serein.chengyu@huawei.com>
From: Zhao Wenhui <zhaowenhui8@huawei.com>
When the quota value in CFS bandwidth is set to -1, that imples the
cfs bandwidth is turned off. So the burst feature is supposed to
be disable as well.
Currently, when quota is -1, burst will not be checked, so that it can be
set to any value. Examples:
mkdir /sys/fs/cgroup/cpu/test
echo -1 > /sys/fs/cgroup/cpu/test/cpu.cfs_quota_us
echo 10000000000000000 > /sys/fs/cgroup/cpu/test/cpu.cfs_burst_us
Moreover, after the burst modified by this way, quota can't be set
to any value:
echo 100000 > cpu.cfs_quota_us
-bash: echo: write error: Invalid argument
This patch can ensure the burst value being zero and unchangeable,
when quota is set to -1.
Fixes: f4183717b370 ("sched/fair: Introduce the burstable CFS controller")
Reported-by: Zhao Gongyi <zhaogongyi@huawei.com>
Signed-off-by: Zhao Wenhui <zhaowenhui8@huawei.com>
Reviewed-by: Tianchen Ding <dtcccc@linux.alibaba.com>
Reviewed-by: Ben Segall <bsegall@google.com>
---
v1: https://lore.kernel.org/all/20220809120320.19496-1-zhaowenhui8@huawei.com/
---
kernel/sched/core.c | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index bcf2c4cc0522..e9198e30bb74 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -10840,6 +10840,12 @@ static int tg_set_cfs_bandwidth(struct task_group *tg, u64 period, u64 quota,
burst + quota > max_cfs_runtime))
return -EINVAL;
+ /*
+ * Ensure burst equals to zero when quota is -1.
+ */
+ if (quota == RUNTIME_INF && burst)
+ return -EINVAL;
+
/*
* Prevent race between setting of cfs_rq->runtime_enabled and
* unthrottle_offline_cfs_rqs().
@@ -10899,8 +10905,10 @@ static int tg_set_cfs_quota(struct task_group *tg, long cfs_quota_us)
period = ktime_to_ns(tg->cfs_bandwidth.period);
burst = tg->cfs_bandwidth.burst;
- if (cfs_quota_us < 0)
+ if (cfs_quota_us < 0) {
quota = RUNTIME_INF;
+ burst = 0;
+ }
else if ((u64)cfs_quota_us <= U64_MAX / NSEC_PER_USEC)
quota = (u64)cfs_quota_us * NSEC_PER_USEC;
else
--
2.25.1
next prev parent reply other threads:[~2024-05-22 3:16 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-05-22 3:10 [PATCH 0/2] cgroup cpu: set burst to zero when cfs bandwidth is Cheng Yu
2024-05-22 3:10 ` Cheng Yu [this message]
2024-05-22 3:10 ` [PATCH 2/2] sched/fair: set burst to zero when set max to cpu.max Cheng Yu
2024-05-28 23:10 ` Benjamin Segall
2024-05-29 6:20 ` Cheng Yu
2024-05-24 10:52 ` [PATCH 0/2] cgroup cpu: set burst to zero when cfs bandwidth is Vishal Chourasia
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=20240522031007.643498-2-serein.chengyu@huawei.com \
--to=serein.chengyu@huawei.com \
--cc=bristot@redhat.com \
--cc=bsegall@google.com \
--cc=changhuaixin@linux.alibaba.com \
--cc=dietmar.eggemann@arm.com \
--cc=dtcccc@linux.alibaba.com \
--cc=judy.chenhui@huawei.com \
--cc=juri.lelli@redhat.com \
--cc=liaoqixin@huawei.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mgorman@suse.de \
--cc=mingo@redhat.com \
--cc=peterz@infradead.org \
--cc=rostedt@goodmis.org \
--cc=shanpeic@linux.alibaba.com \
--cc=tj@kernel.org \
--cc=vincent.guittot@linaro.org \
--cc=vschneid@redhat.com \
--cc=yusongping@huawei.com \
--cc=zhangqiao22@huawei.com \
--cc=zhaowenhui8@huawei.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®