Re: [PATCH] cgroup/rstat: avoid disabling irqs for O(num_cpu)

From: Johannes Weiner
Date: Wed Mar 19 2025 - 14:06:58 EST


On Wed, Mar 19, 2025 at 05:16:02PM +0000, Yosry Ahmed wrote:
> @@ -365,9 +352,8 @@ __bpf_kfunc void cgroup_rstat_flush(struct cgroup *cgrp)
> void cgroup_rstat_flush_hold(struct cgroup *cgrp)
> __acquires(&cgroup_rstat_lock)
> {
> - might_sleep();
> + cgroup_rstat_flush(cgrp);
> __cgroup_rstat_lock(cgrp, -1);
> - cgroup_rstat_flush_locked(cgrp);
> }

Might as well remove cgroup_rstat_flush_hold/release entirely? There
are no external users, and the concept seems moot when the lock is
dropped per default. cgroup_base_stat_cputime_show() can open-code the
lock/unlock to stabilize the counts while reading.

(btw, why do we not have any locking around the root stats in
cgroup_base_stat_cputime_show()? There isn't anything preventing a
reader from seeing all zeroes if another reader runs the memset() on
cgrp->bstat, is there? Or double times...)