Commit 49217ea1 authored by Cheng Yu's avatar Cheng Yu Committed by Ingo Molnar

sched/core: Fix incorrect initialization of the 'burst' parameter in cpu_max_write()

In the cgroup v2 CPU subsystem, assuming we have a
cgroup named 'test', and we set cpu.max and cpu.max.burst:

    # echo 1000000 > /sys/fs/cgroup/test/cpu.max
    # echo 1000000 > /sys/fs/cgroup/test/cpu.max.burst

then we check cpu.max and cpu.max.burst:

    # cat /sys/fs/cgroup/test/cpu.max
    1000000 100000
    # cat /sys/fs/cgroup/test/cpu.max.burst
    1000000

Next we set cpu.max again and check cpu.max and
cpu.max.burst:

    # echo 2000000 > /sys/fs/cgroup/test/cpu.max
    # cat /sys/fs/cgroup/test/cpu.max
    2000000 100000

    # cat /sys/fs/cgroup/test/cpu.max.burst
    1000

... we find that the cpu.max.burst value changed unexpectedly.

In cpu_max_write(), the unit of the burst value returned
by tg_get_cfs_burst() is microseconds, while in cpu_max_write(),
the burst unit used for calculation should be nanoseconds,
which leads to the bug.

To fix it, get the burst value directly from tg->cfs_bandwidth.burst.

Fixes: f4183717 ("sched/fair: Introduce the burstable CFS controller")
Reported-by: default avatarQixin Liao <liaoqixin@huawei.com>
Signed-off-by: default avatarCheng Yu <serein.chengyu@huawei.com>
Signed-off-by: default avatarZhang Qiao <zhangqiao22@huawei.com>
Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
Reviewed-by: default avatarVincent Guittot <vincent.guittot@linaro.org>
Tested-by: default avatarVincent Guittot <vincent.guittot@linaro.org>
Link: https://lore.kernel.org/r/20240424132438.514720-1-serein.chengyu@huawei.com
parent 7cb7fb5b
...@@ -11402,7 +11402,7 @@ static ssize_t cpu_max_write(struct kernfs_open_file *of, ...@@ -11402,7 +11402,7 @@ static ssize_t cpu_max_write(struct kernfs_open_file *of,
{ {
struct task_group *tg = css_tg(of_css(of)); struct task_group *tg = css_tg(of_css(of));
u64 period = tg_get_cfs_period(tg); u64 period = tg_get_cfs_period(tg);
u64 burst = tg_get_cfs_burst(tg); u64 burst = tg->cfs_bandwidth.burst;
u64 quota; u64 quota;
int ret; int ret;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment