On Fri, Jan 24, 2025 at 03:49:16PM +0800, Abel Wu wrote:
...
--- a/kernel/cgroup/rstat.c
+++ b/kernel/cgroup/rstat.c
@@ -613,36 +613,33 @@ 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, ntime;
+ struct cgroup_base_stat bstat;
if (cgroup_parent(cgrp)) {
cgroup_rstat_flush_hold(cgrp);
- usage = cgrp->bstat.cputime.sum_exec_runtime;
+ bstat = cgrp->bstat;
Thank you for finding that.
In my version 2, I used to assign cgrp->bstat to bstat.
This is Tj's comment:
https://lore.kernel.org/linux-kernel/ZoQ2ti7nnz9EJSc3@xxxxxxxxxxxxxxx/
I wasn't saying that memcpy() should be used instead of assignment. I was
saying that if a non-trivial struct can be pointed to instead of being
copied, it should be pointed to. If all the fields need to be snapshotted,
assigning is fine.