sched/fair: Fix burst unit mismatch error for cgroup v2 cfsb.
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 40 lines · NiuRuofei <[email protected]> 于2023年8月9日周三 14:27写道:
The burstable CFS controller is introduced:
The original patch directly used the 'cpu.max' interface file, and it handles the unit conversion when
cpu_period_quota_parse()functioncalled(something like this, *burstp *= NSEC_PER_USEC;), it works fine.However, in the official version, the single "cpu.max" file was split into 'cpu.max' and 'cpu.max.burst' interface files, and we don't parse 'burst' in
cpu_period_quota_parse()function anymore. Instead, we calltg_get_cfs_burst()to get burst value, which returnburst_timein microseconds. This could result in a unit mismatch bug.We can easily reproduce this bug using the following steps:
bash:/sys/fs/cgroup/mycgroup$ echo 25000 | sudo tee cpu.max.burst 25000 bash:/sys/fs/cgroup/mycgroup$ echo 50000 100000 | sudo tee cpu.max 50000 100000 bash:/sys/fs/cgroup/mycgroup$ cat cpu.max.burst 25Signed-off-by NiuRuofei <[email protected]>--- kernel/sched/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)kernel/sched/core.c +1
-2@@ -11380,7 +11380,7 @@ static ssize_t cpu_max_write(struct kernfs_open_file *of, {struct task_group *tg =css_tg (of_css (of));u64 period =tg_get_cfs_period (tg); -u64 burst =tg_get_cfs_burst (tg); +u64 burst =tg_get_cfs_burst (tg) *NSEC_PER_USEC ;u64 quota;int ret; --2.30.1 (Apple Git-130)
Quoted 41 lines · 牛若飞
Quoted 37 lines · NiuRuofei <[email protected]> 于2023年8月9日周三 14:27写道:
The burstable CFS controller is introduced:
The original patch directly used the 'cpu.max' interface file, and it handles the unit conversion when
cpu_period_quota_parse()functioncalled(something like this, *burstp *= NSEC_PER_USEC;), it works fine.However, in the official version, the single "cpu.max" file was split into 'cpu.max' and 'cpu.max.burst' interface files, and we don't parse 'burst' in
cpu_period_quota_parse()function anymore. Instead, we calltg_get_cfs_burst()to get burst value, which returnburst_timein microseconds. This could result in a unit mismatch bug.We can easily reproduce this bug using the following steps:
bash:/sys/fs/cgroup/mycgroup$ echo 25000 | sudo tee cpu.max.burst 25000 bash:/sys/fs/cgroup/mycgroup$ echo 50000 100000 | sudo tee cpu.max 50000 100000 bash:/sys/fs/cgroup/mycgroup$ cat cpu.max.burst 25Signed-off-by NiuRuofei <[email protected]>--- kernel/sched/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)kernel/sched/core.c +1
-1@@ -11380,7 +11380,7 @@ static ssize_t cpu_max_write(struct kernfs_open_file *of, {struct task_group *tg =css_tg (of_css (of));u64 period =tg_get_cfs_period (tg); -u64 burst =tg_get_cfs_burst (tg); +u64 burst =tg_get_cfs_burst (tg) *NSEC_PER_USEC ;u64 quota;int ret;
Quoted 3 lines
Quoted 3 lines
--
2.30.1 (Apple Git-130)
Seems we had a similar fix for this one from Kailun here:
https://lkml.org/lkml/2021/9/10/782