]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
memcg: cgroup: call css_rstat_updated irrespective of in_nmi()
authorShakeel Butt <shakeel.butt@linux.dev>
Tue, 17 Jun 2025 19:57:25 +0000 (12:57 -0700)
committerTejun Heo <tj@kernel.org>
Tue, 17 Jun 2025 20:01:47 +0000 (10:01 -1000)
css_rstat_updated() is nmi safe, so there is no need to avoid it in
in_nmi(), so remove the check.

Signed-off-by: Shakeel Butt <shakeel.butt@linux.dev>
Tested-by: JP Kobryn <inwardvessel@gmail.com>
Signed-off-by: Tejun Heo <tj@kernel.org>
mm/memcontrol.c

index 902da8a9c643a070ca323804e557ae5173c688c5..d122bfe33e98a5bc909dc0362a9849603dc68f02 100644 (file)
@@ -573,9 +573,7 @@ static inline void memcg_rstat_updated(struct mem_cgroup *memcg, int val,
        if (!val)
                return;
 
-       /* TODO: add to cgroup update tree once it is nmi-safe. */
-       if (!in_nmi())
-               css_rstat_updated(&memcg->css, cpu);
+       css_rstat_updated(&memcg->css, cpu);
        statc_pcpu = memcg->vmstats_percpu;
        for (; statc_pcpu; statc_pcpu = statc->parent_pcpu) {
                statc = this_cpu_ptr(statc_pcpu);
@@ -2530,7 +2528,8 @@ static inline void account_slab_nmi_safe(struct mem_cgroup *memcg,
        } else {
                struct mem_cgroup_per_node *pn = memcg->nodeinfo[pgdat->node_id];
 
-               /* TODO: add to cgroup update tree once it is nmi-safe. */
+               /* preemption is disabled in_nmi(). */
+               css_rstat_updated(&memcg->css, smp_processor_id());
                if (idx == NR_SLAB_RECLAIMABLE_B)
                        atomic_add(nr, &pn->slab_reclaimable);
                else
@@ -2753,7 +2752,8 @@ static inline void account_kmem_nmi_safe(struct mem_cgroup *memcg, int val)
        if (likely(!in_nmi())) {
                mod_memcg_state(memcg, MEMCG_KMEM, val);
        } else {
-               /* TODO: add to cgroup update tree once it is nmi-safe. */
+               /* preemption is disabled in_nmi(). */
+               css_rstat_updated(&memcg->css, smp_processor_id());
                atomic_add(val, &memcg->kmem_stat);
        }
 }