提交 8c9bb956 编写于 作者: Z Zhao Wenhui 提交者: Zheng Zengkai

sched/fair: limit burst to zero when cfs bandwidth is toggled off

hulk inclusion
category: bugfix
bugzilla: 187464, https://gitee.com/openeuler/kernel/issues/I612GU

--------------------------------

sched/fair: limit burst to zero when cfs bandwidth is toggled off

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: f4183717 ("sched/fair: Introduce the burstable CFS controller")
Signed-off-by: NZhao Wenhui <zhaowenhui8@huawei.com>
Signed-off-by: NZheng Zucheng <zhengzucheng@huawei.com>
Reviewed-by: NZhang Qiao <zhangqiao22@huawei.com>
Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
上级 0d813f1e
......@@ -9120,6 +9120,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().
......@@ -9179,8 +9185,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
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册