Messages in this thread | | | From | 牛若飞 <> | Date | Wed, 30 Aug 2023 17:19:14 +0800 | Subject | Re: [PATCH] sched/fair: Fix burst unit mismatch error for cgroup v2 cfsb. |
| |
Cc: linux-kernel@vger.kernel.org
NiuRuofei <nrf233@gmail.com> 于2023年8月9日周三 14:27写道: > > The burstable CFS controller is introduced: > Link: https://lore.kernel.org/lkml/20210316044931.39733-2-changhuaixin@linux.alibaba.com/ > > The original patch directly used the 'cpu.max' interface file, and it handles the unit conversion > when cpu_period_quota_parse() function called(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 call tg_get_cfs_burst() to get burst value, > which return burst_time in 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 > 25 > > Signed-off-by: NiuRuofei <nrf233@gmail.com> > --- > kernel/sched/core.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/kernel/sched/core.c b/kernel/sched/core.c > index c52c2eba7c73..e635598486a9 100644 > --- a/kernel/sched/core.c > +++ b/kernel/sched/core.c > @@ -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) >
| |