Hello,
c4af66a95aa3 ("cgroup/rstat: Fix forceidle time in cpu.stat") fixes b824766504e4 ("cgroup/rstat: add force idle show helper") and should be backported to v6.11+ but I forgot to add the tag and the patch is currently queued in cgroup/for-6.15. Once the cgroup pull request is merged, can you please include the commit in -stable backports?
Thanks.
On Thu, Mar 20, 2025 at 07:55:03AM -1000, Tejun Heo wrote:
Hello,
c4af66a95aa3 ("cgroup/rstat: Fix forceidle time in cpu.stat") fixes b824766504e4 ("cgroup/rstat: add force idle show helper") and should be backported to v6.11+ but I forgot to add the tag and the patch is currently queued in cgroup/for-6.15. Once the cgroup pull request is merged, can you please include the commit in -stable backports?
Included now in 6.13.y and 6.14.y queues, but fails to apply to 6.12.y, so can you send a backported version of that to us?
thanks,
greg k-h
On Tue, Apr 01, 2025 at 11:47:14AM +0100, Greg Kroah-Hartman wrote:
On Thu, Mar 20, 2025 at 07:55:03AM -1000, Tejun Heo wrote:
Hello,
c4af66a95aa3 ("cgroup/rstat: Fix forceidle time in cpu.stat") fixes b824766504e4 ("cgroup/rstat: add force idle show helper") and should be backported to v6.11+ but I forgot to add the tag and the patch is currently queued in cgroup/for-6.15. Once the cgroup pull request is merged, can you please include the commit in -stable backports?
Included now in 6.13.y and 6.14.y queues, but fails to apply to 6.12.y, so can you send a backported version of that to us?
Here's the version for v6.12 and v6.11. Thanks.
From ff4f8b0e9e7ff0f534f7b95c7040ef254083265c Mon Sep 17 00:00:00 2001 From: Tejun Heo tj@kernel.org Date: Tue, 1 Apr 2025 21:26:03 -1000 Subject: [PATCH] cgroup/rstat: Fix forceidle time in cpu.stat
The commit b824766504e4 ("cgroup/rstat: add force idle show helper") retrieves forceidle_time outside cgroup_rstat_lock for non-root cgroups which can be potentially inconsistent with other stats.
Rather than reverting that commit, fix it in a way that retains the effort of cleaning up the ifdef-messes.
Fixes: b824766504e4 ("cgroup/rstat: add force idle show helper") Signed-off-by: Abel Wu wuyun.abel@bytedance.com Signed-off-by: Tejun Heo tj@kernel.org --- kernel/cgroup/rstat.c | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-)
diff --git a/kernel/cgroup/rstat.c b/kernel/cgroup/rstat.c index ce295b73c0a3..5f9121a3b7dd 100644 --- a/kernel/cgroup/rstat.c +++ b/kernel/cgroup/rstat.c @@ -607,32 +607,30 @@ static void cgroup_force_idle_show(struct seq_file *seq, struct cgroup_base_stat void cgroup_base_stat_cputime_show(struct seq_file *seq) { struct cgroup *cgrp = seq_css(seq)->cgroup; - u64 usage, utime, stime; + struct cgroup_base_stat bstat;
if (cgroup_parent(cgrp)) { cgroup_rstat_flush_hold(cgrp); - usage = cgrp->bstat.cputime.sum_exec_runtime; + bstat = cgrp->bstat; cputime_adjust(&cgrp->bstat.cputime, &cgrp->prev_cputime, - &utime, &stime); + &bstat.cputime.utime, &bstat.cputime.stime); cgroup_rstat_flush_release(cgrp); } else { - /* cgrp->bstat of root is not actually used, reuse it */ - root_cgroup_cputime(&cgrp->bstat); - usage = cgrp->bstat.cputime.sum_exec_runtime; - utime = cgrp->bstat.cputime.utime; - stime = cgrp->bstat.cputime.stime; + root_cgroup_cputime(&bstat); }
- do_div(usage, NSEC_PER_USEC); - do_div(utime, NSEC_PER_USEC); - do_div(stime, NSEC_PER_USEC); + do_div(bstat.cputime.sum_exec_runtime, NSEC_PER_USEC); + do_div(bstat.cputime.utime, NSEC_PER_USEC); + do_div(bstat.cputime.stime, NSEC_PER_USEC);
seq_printf(seq, "usage_usec %llu\n" "user_usec %llu\n" "system_usec %llu\n", - usage, utime, stime); + bstat.cputime.sum_exec_runtime, + bstat.cputime.utime, + bstat.cputime.stime);
- cgroup_force_idle_show(seq, &cgrp->bstat); + cgroup_force_idle_show(seq, &bstat); }
/* Add bpf kfuncs for cgroup_rstat_updated() and cgroup_rstat_flush() */
linux-stable-mirror@lists.linaro.org