* [PATCH] sched/fair: limit burst to zero when cfs bandwidth is toggled off
@ 2022-08-09 12:03 Zhao Wenhui
2022-08-16 5:24 ` Tianchen Ding
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: Zhao Wenhui @ 2022-08-09 12:03 UTC (permalink / raw)
To: mingo, peterz, juri.lelli, vincent.guittot, dietmar.eggemann,
rostedt, bsegall, mgorman, bristot, vschneid, shanpeic,
changhuaixin, tj, dtcccc, linux-kernel
Cc: zhaowenhui8, zhaogongyi
When the quota value in CFS bandwidth is set to -1, that imples the
cfs bandwidth is toggled off. So the burst feature is supposed to
be disable as well.
Currently, when quota is -1, burst will not be check, so that it can be
set to almost arbitery 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 unalterable,
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>
---
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 ee28253c9ac0..4c1fc01d8c68 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -10584,6 +10584,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().
@@ -10643,8 +10649,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.17.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] sched/fair: limit burst to zero when cfs bandwidth is toggled off
2022-08-09 12:03 [PATCH] sched/fair: limit burst to zero when cfs bandwidth is toggled off Zhao Wenhui
@ 2022-08-16 5:24 ` Tianchen Ding
2022-08-17 21:16 ` Benjamin Segall
2022-08-30 3:19 ` zhaowenhui (A)
2 siblings, 0 replies; 6+ messages in thread
From: Tianchen Ding @ 2022-08-16 5:24 UTC (permalink / raw)
To: Zhao Wenhui
Cc: zhaogongyi, mingo, peterz, juri.lelli, vincent.guittot,
dietmar.eggemann, rostedt, bsegall, mgorman, bristot, vschneid,
shanpeic, changhuaixin, tj, linux-kernel
On 2022/8/9 20:03, Zhao Wenhui wrote:
> When the quota value in CFS bandwidth is set to -1, that imples the
> cfs bandwidth is toggled off. So the burst feature is supposed to
> be disable as well.
>
> Currently, when quota is -1, burst will not be check, so that it can be
> set to almost arbitery 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 unalterable,
> 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>
Nice catch! Thanks for the fix.
Reviewed-by: Tianchen Ding <dtcccc@linux.alibaba.com>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] sched/fair: limit burst to zero when cfs bandwidth is toggled off
2022-08-09 12:03 [PATCH] sched/fair: limit burst to zero when cfs bandwidth is toggled off Zhao Wenhui
2022-08-16 5:24 ` Tianchen Ding
@ 2022-08-17 21:16 ` Benjamin Segall
2022-08-30 3:19 ` zhaowenhui (A)
2 siblings, 0 replies; 6+ messages in thread
From: Benjamin Segall @ 2022-08-17 21:16 UTC (permalink / raw)
To: Zhao Wenhui
Cc: mingo, peterz, juri.lelli, vincent.guittot, dietmar.eggemann,
rostedt, mgorman, bristot, vschneid, shanpeic, changhuaixin, tj,
dtcccc, linux-kernel, zhaogongyi
Zhao Wenhui <zhaowenhui8@huawei.com> writes:
> When the quota value in CFS bandwidth is set to -1, that imples the
> cfs bandwidth is toggled off. So the burst feature is supposed to
> be disable as well.
>
> Currently, when quota is -1, burst will not be check, so that it can be
> set to almost arbitery 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 unalterable,
> 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>
Indeed, good catch.
Reviewed-by: Ben Segall <bsegall@google.com>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] sched/fair: limit burst to zero when cfs bandwidth is toggled off
2022-08-09 12:03 [PATCH] sched/fair: limit burst to zero when cfs bandwidth is toggled off Zhao Wenhui
2022-08-16 5:24 ` Tianchen Ding
2022-08-17 21:16 ` Benjamin Segall
@ 2022-08-30 3:19 ` zhaowenhui (A)
2022-09-30 8:32 ` zhaowenhui (A)
2 siblings, 1 reply; 6+ messages in thread
From: zhaowenhui (A) @ 2022-08-30 3:19 UTC (permalink / raw)
To: mingo, peterz, juri.lelli, vincent.guittot, dietmar.eggemann,
rostedt, bsegall, mgorman, bristot, vschneid, shanpeic,
changhuaixin, tj, dtcccc, linux-kernel
Cc: zhaogongyi
在 2022/8/9 20:03, Zhao Wenhui 写道:
> When the quota value in CFS bandwidth is set to -1, that imples the
> cfs bandwidth is toggled off. So the burst feature is supposed to
> be disable as well.
>
> Currently, when quota is -1, burst will not be check, so that it can be
> set to almost arbitery 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 unalterable,
> 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>
> ---
> 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 ee28253c9ac0..4c1fc01d8c68 100644
> --- a/kernel/sched/core.c
> +++ b/kernel/sched/core.c
> @@ -10584,6 +10584,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().
> @@ -10643,8 +10649,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
Gentle ping.
Thanks,
Zhao Wenhui
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] sched/fair: limit burst to zero when cfs bandwidth is toggled off
2022-08-30 3:19 ` zhaowenhui (A)
@ 2022-09-30 8:32 ` zhaowenhui (A)
2022-11-23 8:52 ` zhaowenhui (A)
0 siblings, 1 reply; 6+ messages in thread
From: zhaowenhui (A) @ 2022-09-30 8:32 UTC (permalink / raw)
To: mingo, peterz, juri.lelli, vincent.guittot, linux-kernel
Cc: zhaogongyi, dietmar.eggemann, rostedt, bsegall, mgorman, bristot,
vschneid, shanpeic, changhuaixin, tj, dtcccc
在 2022/8/30 11:19, zhaowenhui (A) 写道:
>
>
> 在 2022/8/9 20:03, Zhao Wenhui 写道:
>> When the quota value in CFS bandwidth is set to -1, that imples the
>> cfs bandwidth is toggled off. So the burst feature is supposed to
>> be disable as well.
>>
>> Currently, when quota is -1, burst will not be check, so that it can be
>> set to almost arbitery 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 unalterable,
>> 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>
>> ---
>> 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 ee28253c9ac0..4c1fc01d8c68 100644
>> --- a/kernel/sched/core.c
>> +++ b/kernel/sched/core.c
>> @@ -10584,6 +10584,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().
>> @@ -10643,8 +10649,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
>
> Gentle ping.
>
> Thanks,
> Zhao Wenhui
Dear Maintainers,
Hi, this patch has been reviewed by two reviewers over a month ago.
So, Any more suggestions for this patch or it can be picked?
Regards,
Zhao Wenhui
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] sched/fair: limit burst to zero when cfs bandwidth is toggled off
2022-09-30 8:32 ` zhaowenhui (A)
@ 2022-11-23 8:52 ` zhaowenhui (A)
0 siblings, 0 replies; 6+ messages in thread
From: zhaowenhui (A) @ 2022-11-23 8:52 UTC (permalink / raw)
To: peterz
Cc: zhaogongyi, dietmar.eggemann, rostedt, bsegall, mgorman, bristot,
vschneid, shanpeic, changhuaixin, tj, dtcccc, mingo, juri.lelli,
vincent.guittot, linux-kernel
在 2022/9/30 16:32, zhaowenhui (A) 写道:
>
>
> 在 2022/8/30 11:19, zhaowenhui (A) 写道:
>>
>>
>> 在 2022/8/9 20:03, Zhao Wenhui 写道:
>>> When the quota value in CFS bandwidth is set to -1, that imples the
>>> cfs bandwidth is toggled off. So the burst feature is supposed to
>>> be disable as well.
>>>
>>> Currently, when quota is -1, burst will not be check, so that it can be
>>> set to almost arbitery 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 unalterable,
>>> 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>
>>> ---
>>> 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 ee28253c9ac0..4c1fc01d8c68 100644
>>> --- a/kernel/sched/core.c
>>> +++ b/kernel/sched/core.c
>>> @@ -10584,6 +10584,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().
>>> @@ -10643,8 +10649,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
>>
>> Gentle ping.
>>
>> Thanks,
>> Zhao Wenhui
>
> Dear Maintainers,
> Hi, this patch has been reviewed by two reviewers over a month ago.
> So, Any more suggestions for this patch or it can be picked?
>
> Regards,
> Zhao Wenhui
Peter,
Sorry to disturbed, for this patch is submitted long long time ago...
And this is my first patch, so I really wonder if there is something
to be improved for the patch.
Looking forward to your reply.
Thank you,
Zhao Wenhui
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2022-11-23 8:52 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-09 12:03 [PATCH] sched/fair: limit burst to zero when cfs bandwidth is toggled off Zhao Wenhui
2022-08-16 5:24 ` Tianchen Ding
2022-08-17 21:16 ` Benjamin Segall
2022-08-30 3:19 ` zhaowenhui (A)
2022-09-30 8:32 ` zhaowenhui (A)
2022-11-23 8:52 ` zhaowenhui (A)
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).