Skip to contentSkip to conversation

cgroup: fix display of forceidle time at root

PATCH Applied Josh Don 3 participants 4 messages Mar 15, 2023 – Mar 17, 2023 cgroup

lore
Share & tools
lore

Josh Don

author
#0 lore raw

PATCH 1/1 cgroup: fix display of forceidle time at root

We need to reset forceidle_sum to 0 when reading from root, since the bstat we accumulate into is stack allocated.

To make this more robust, just replace the existing cputime reset with a memset of the overall bstat.

---
 kernel/cgroup/rstat.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
kernel/cgroup/rstat.c +1 -3
index 831f1f472bb8..0a2b4967e333 100644
@@ -457,9 +457,7 @@ static void root_cgroup_cputime(struct cgroup_base_stat *bstat)
 	struct task_cputime *cputime = &bstat->cputime;
 	int i;
 
-	cputime->stime = 0;
-	cputime->utime = 0;
-	cputime->sum_exec_runtime = 0;
+	memset(bstat, 0, sizeof(*bstat));
 	for_each_possible_cpu(i) {
 		struct kernel_cpustat kcpustat;
 		u64 *cpustat = kcpustat.cpustat;
Signature · 1 line
2.40.0.rc1.284.g88254d51c5-goog
#1 lore raw
Quoted 16 lines · Josh Don

We need to reset forceidle_sum to 0 when reading from root, since the bstat we accumulate into is stack allocated.

To make this more robust, just replace the existing cputime reset with a memset of the overall bstat.

---
  kernel/cgroup/rstat.c | 4 +---
  1 file changed, 1 insertion(+), 3 deletions(-)
kernel/cgroup/rstat.c +0 -0
index 831f1f472bb8..0a2b4967e333 100644

kernel/cgroup/rstat.c static void root_cgroup_cputime(struct cgroup_base_stat *bstat) · line 463

Quoted 10 lines
kernel/cgroup/rstat.c +1 -3
@@ -457,9 +457,7 @@ static void root_cgroup_cputime(struct cgroup_base_stat *bstat)
  	struct task_cputime *cputime = &bstat->cputime;
  	int i;
 
-	cputime->stime = 0;
-	cputime->utime = 0;
-	cputime->sum_exec_runtime = 0;
+	memset(bstat, 0, sizeof(*bstat));
  	for_each_possible_cpu(i) {
  		struct kernel_cpustat kcpustat;
  		u64 *cpustat = kcpustat.cpustat;

How about adding the following fixes tag?

Fixes 1fcf54deb767 ("sched/core: add forced idle accounting for cgroups")

Cheers,
Longman

author
#2 lore raw
Quoted 4 lines · On Wed, Mar 15, 2023 at 7:19 PM Waiman Long…

How about adding the following fixes tag?

Fixes 1fcf54deb767 ("sched/core: add forced idle accounting for cgroups")

SGTM, thanks Waiman!

maintainer Applied
#3 lore raw
In reply to Josh Don
Quoted 7 lines · Josh Don

We need to reset forceidle_sum to 0 when reading from root, since the bstat we accumulate into is stack allocated.

To make this more robust, just replace the existing cputime reset with a memset of the overall bstat.

Applied to cgroup/for-6.3-fixes w/ Fixes tag added and stable cc'd.

Thanks.

Signature · 1 line
tejun