* [PATCH 0/2] memcg: fix memcg stat updates made in NMI
@ 2026-12-04 21:57 Shakeel Butt
2026-12-04 21:57 ` [PATCH 1/2] memcg: add NMI stat deltas before marking the css updated Shakeel Butt
2026-12-04 21:57 ` [PATCH 2/2] memcg: make memcg_uncharge_kmem() NMI safe Shakeel Butt
0 siblings, 2 replies; 5+ messages in thread
From: Shakeel Butt @ 2026-12-04 21:57 UTC (permalink / raw)
To: Andrew Morton
Cc: Johannes Weiner, Michal Hocko, Roman Gushchin, Muchun Song,
Alexei Starovoitov, Vlastimil Babka, Harry Yoo, Tejun Heo,
cgroups, linux-mm, linux-kernel, Meta kernel team, bpf
Two fixes for memcg stat updates made in NMI. Both affect only the
architectures where this_cpu operations are not NMI safe but atomics
are (CONFIG_MEMCG_NMI_SAFETY_REQUIRES_ATOMIC: powerpc, sparc64, and arm
and sh where cmpxchg is NMI safe). There, stat updates made in NMI go to
atomics, and flush_nmi_stats() folds them in when the css is flushed.
Patch 1 fixes the order in account_kmem_nmi_safe() and
account_slab_nmi_safe(). They mark the css for flushing before they add
the delta, so a flush on another CPU can run in between and miss the
delta. The delta then waits for the next update of that memcg, or never
reaches the ancestors if the memcg is freed first.
Patch 2 sends the MEMCG_KMEM update in memcg_uncharge_kmem() through
account_kmem_nmi_safe(). memcg_uncharge_kmem() runs in NMI when
kmalloc_nolock() or kfree_nolock() evicts an object stock slot, and it
still calls mod_memcg_state(), whose per-CPU read-modify-writes are not
NMI safe there. Hitting it also needs slub_debug and a page size below
64K.
A separate series makes percpu_ref gets, puts and releases NMI safe.
The two series don't depend on each other.
Testing:
- Built for x86-64 (W=1 on mm/memcontrol.o at each patch), and for
ppc64le with 4K pages and ppc32 with LLVM, where
CONFIG_MEMCG_NMI_SAFETY_REQUIRES_ATOMIC=y.
- On x86-64 with ARCH_HAS_NMI_SAFE_THIS_CPU_OPS turned off, so that the
atomic NMI paths are used, a test runs kmalloc_nolock() and
kfree_nolock() in NMI, through a self NMI IPI, across 8 memcgs.
memcg_uncharge_kmem() ran in NMI 7 or 8 times per run, and afterwards
MEMCG_KMEM matched the page counter in every memcg. The race that
patch 1 fixes needs a flush to land between two instructions, and the
test does not reproduce it.
- The cgroup selftests test_core, test_kmem and test_memcontrol in a VM
give the same results with and without the series. The test cases
that fail in that VM also fail on the base kernel.
Shakeel Butt (2):
memcg: add NMI stat deltas before marking the css updated
memcg: make memcg_uncharge_kmem() NMI safe
mm/memcontrol.c | 17 ++++++++++++-----
1 file changed, 12 insertions(+), 5 deletions(-)
base-commit: d0d65ff2e433e741c23715e8359c4a248d432179
--
2.53.1-Meta
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 1/2] memcg: add NMI stat deltas before marking the css updated
2026-12-04 21:57 [PATCH 0/2] memcg: fix memcg stat updates made in NMI Shakeel Butt
@ 2026-12-04 21:57 ` Shakeel Butt
2026-12-05 7:09 ` + memcg-add-nmi-stat-deltas-before-marking-the-css-updated.patch added to mm-new branch Andrew Morton
2026-12-04 21:57 ` [PATCH 2/2] memcg: make memcg_uncharge_kmem() NMI safe Shakeel Butt
1 sibling, 1 reply; 5+ messages in thread
From: Shakeel Butt @ 2026-12-04 21:57 UTC (permalink / raw)
To: Andrew Morton
Cc: Johannes Weiner, Michal Hocko, Roman Gushchin, Muchun Song,
Alexei Starovoitov, Vlastimil Babka, Harry Yoo, Tejun Heo,
cgroups, linux-mm, linux-kernel, Meta kernel team, bpf
On CONFIG_MEMCG_NMI_SAFETY_REQUIRES_ATOMIC architectures,
account_kmem_nmi_safe() and account_slab_nmi_safe() keep stat updates
made in NMI in atomics, which flush_nmi_stats() folds in when the css
is flushed. Since commit 8dcb0ed834a3 ("memcg: cgroup: call
css_rstat_updated irrespective of in_nmi()"), they mark the css updated
first and add the delta second. Regular stat updates do it the other
way around.
With this order, a flush on another CPU can take the css off the update
list and run flush_nmi_stats() between the two steps. The delta then
lands after the flush, while the css is no longer on the update list.
It waits there until the next update marks the css again. If the memcg
is freed first, the delta never reaches the ancestors, because
css_rstat_exit() only flushes csses that are on the update list.
Add the delta first. If the css is not on the update list yet,
__css_rstat_updated() puts it there with fully ordered cmpxchg
operations, so a flush that takes the css off the list also sees the
delta. If the css is already on the list, a concurrent flush can still
miss the update. That is the race described in
css_process_update_tree(), which regular updates have too.
Fixes: 8dcb0ed834a3 ("memcg: cgroup: call css_rstat_updated irrespective of in_nmi()")
Signed-off-by: Shakeel Butt <shakeel.butt@linux.dev>
---
mm/memcontrol.c | 14 ++++++++++----
1 file changed, 10 insertions(+), 4 deletions(-)
diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index b75a61ddeded..53e688083350 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -3016,12 +3016,15 @@ static inline void account_slab_nmi_safe(struct mem_cgroup *memcg,
} else {
struct mem_cgroup_per_node *pn = memcg->nodeinfo[pgdat->node_id];
- /* 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
atomic_add(nr, &pn->slab_unreclaimable);
+ /*
+ * Mark the css after the update, like regular stat updates
+ * do. Preemption is disabled in_nmi().
+ */
+ __css_rstat_updated(&memcg->css, smp_processor_id());
}
}
#else
@@ -3240,9 +3243,12 @@ 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 {
- /* preemption is disabled in_nmi(). */
- __css_rstat_updated(&memcg->css, smp_processor_id());
atomic_add(val, &memcg->kmem_stat);
+ /*
+ * Mark the css after the update, like regular stat updates
+ * do. Preemption is disabled in_nmi().
+ */
+ __css_rstat_updated(&memcg->css, smp_processor_id());
}
}
#else
--
2.53.1-Meta
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 2/2] memcg: make memcg_uncharge_kmem() NMI safe
2026-12-04 21:57 [PATCH 0/2] memcg: fix memcg stat updates made in NMI Shakeel Butt
2026-12-04 21:57 ` [PATCH 1/2] memcg: add NMI stat deltas before marking the css updated Shakeel Butt
@ 2026-12-04 21:57 ` Shakeel Butt
2026-12-05 7:09 ` + memcg-make-memcg_uncharge_kmem-nmi-safe.patch added to mm-new branch Andrew Morton
1 sibling, 1 reply; 5+ messages in thread
From: Shakeel Butt @ 2026-12-04 21:57 UTC (permalink / raw)
To: Andrew Morton
Cc: Johannes Weiner, Michal Hocko, Roman Gushchin, Muchun Song,
Alexei Starovoitov, Vlastimil Babka, Harry Yoo, Tejun Heo,
cgroups, linux-mm, linux-kernel, Meta kernel team, bpf
On architectures where this_cpu operations are not NMI safe but atomics
are (CONFIG_MEMCG_NMI_SAFETY_REQUIRES_ATOMIC), MEMCG_KMEM updates that
can run in NMI must go through account_kmem_nmi_safe(). The objcg charge
and uncharge paths do, but memcg_uncharge_kmem() still calls
mod_memcg_state() directly.
memcg_uncharge_kmem() runs in NMI when kmalloc_nolock() or
kfree_nolock() has to evict an object stock slot that holds at least a
page of charged bytes:
__refill_obj_stock()
drain_obj_stock_slot()
memcg_uncharge_kmem()
mod_memcg_state()
If the NMI interrupted mod_memcg_state() on the same CPU, the nested
read-modify-write of the per-CPU MEMCG_KMEM counter, or of the rstat
update counter, loses one of the two updates.
Use account_kmem_nmi_safe() in memcg_uncharge_kmem(). Outside NMI it
still calls mod_memcg_state(), so nothing changes there.
Hitting this needs slub_debug, because on these architectures
kmalloc_nolock() only works on slab debug caches. It also needs a base
page size below 64K, because an object stock slot holds at most
U16_MAX bytes, and a kernel without PREEMPT_RT, where local_trylock()
always fails in NMI.
Kernels without commit afe9ae3fda96 ("mm: memcontrol: factor out memcg
kmem uncharge sequence") have the same mod_memcg_state() call
open-coded in drain_obj_stock_slot(), or in drain_obj_stock() in older
ones. Backports to them need the change there.
Fixes: af92793e52c3 ("slab: Introduce kmalloc_nolock() and kfree_nolock().")
Signed-off-by: Shakeel Butt <shakeel.butt@linux.dev>
---
mm/memcontrol.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index 53e688083350..4289eb5a6d06 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -136,10 +136,11 @@ bool mem_cgroup_kmem_disabled(void)
}
static void memcg_uncharge(struct mem_cgroup *memcg, unsigned int nr_pages);
+static inline void account_kmem_nmi_safe(struct mem_cgroup *memcg, int val);
static void memcg_uncharge_kmem(struct mem_cgroup *memcg, unsigned int nr_pages)
{
- mod_memcg_state(memcg, MEMCG_KMEM, -nr_pages);
+ account_kmem_nmi_safe(memcg, -nr_pages);
memcg1_account_kmem(memcg, -nr_pages);
if (!mem_cgroup_is_root(memcg))
memcg_uncharge(memcg, nr_pages);
--
2.53.1-Meta
^ permalink raw reply related [flat|nested] 5+ messages in thread
* + memcg-add-nmi-stat-deltas-before-marking-the-css-updated.patch added to mm-new branch
2026-12-04 21:57 ` [PATCH 1/2] memcg: add NMI stat deltas before marking the css updated Shakeel Butt
@ 2026-12-05 7:09 ` Andrew Morton
0 siblings, 0 replies; 5+ messages in thread
From: Andrew Morton @ 2026-12-05 7:09 UTC (permalink / raw)
To: mm-commits, vbabka, tj, roman.gushchin, muchun.song, mhocko,
harry, hannes, ast, shakeel.butt, akpm
The patch titled
Subject: memcg: add NMI stat deltas before marking the css updated
has been added to the -mm mm-new branch. Its filename is
memcg-add-nmi-stat-deltas-before-marking-the-css-updated.patch
This patch will shortly appear at
https://git.kernel.org/pub/scm/linux/kernel/git/akpm/25-new.git/tree/patches/memcg-add-nmi-stat-deltas-before-marking-the-css-updated.patch
This patch will later appear in the mm-new branch at
git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
Note, mm-new is a provisional staging ground for work-in-progress
patches, and acceptance into mm-new is a notification for others take
notice and to finish up reviews. Please do not hesitate to respond to
review feedback and post updated versions to replace or incrementally
fixup patches in mm-new.
The mm-new branch of mm.git is not included in linux-next
If a few days of testing in mm-new is successful, the patch will me moved
into mm.git's mm-unstable branch, which is included in linux-next
Before you just go and hit "reply", please:
a) Consider who else should be cc'ed
b) Prefer to cc a suitable mailing list as well
c) Ideally: find the original patch on the mailing list and do a
reply-to-all to that, adding suitable additional cc's
*** Remember to use Documentation/process/submit-checklist.rst when testing your code ***
The -mm tree is included into linux-next via various
branches at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
and is updated there most days
------------------------------------------------------
From: Shakeel Butt <shakeel.butt@linux.dev>
Subject: memcg: add NMI stat deltas before marking the css updated
Date: Fri, 04 Dec 2026 13:57:08 -0800
Patch series "memcg: fix memcg stat updates made in NMI".
Two fixes for memcg stat updates made in NMI. Both affect only the
architectures where this_cpu operations are not NMI safe but atomics are
(CONFIG_MEMCG_NMI_SAFETY_REQUIRES_ATOMIC: powerpc, sparc64, and arm and sh
where cmpxchg is NMI safe). There, stat updates made in NMI go to
atomics, and flush_nmi_stats() folds them in when the css is flushed.
Patch 1 fixes the order in account_kmem_nmi_safe() and
account_slab_nmi_safe(). They mark the css for flushing before they add
the delta, so a flush on another CPU can run in between and miss the
delta. The delta then waits for the next update of that memcg, or never
reaches the ancestors if the memcg is freed first.
Patch 2 sends the MEMCG_KMEM update in memcg_uncharge_kmem() through
account_kmem_nmi_safe(). memcg_uncharge_kmem() runs in NMI when
kmalloc_nolock() or kfree_nolock() evicts an object stock slot, and it
still calls mod_memcg_state(), whose per-CPU read-modify-writes are not
NMI safe there. Hitting it also needs slub_debug and a page size below
64K.
A separate series makes percpu_ref gets, puts and releases NMI safe. The
two series don't depend on each other.
Testing:
- Built for x86-64 (W=1 on mm/memcontrol.o at each patch), and for
ppc64le with 4K pages and ppc32 with LLVM, where
CONFIG_MEMCG_NMI_SAFETY_REQUIRES_ATOMIC=y.
- On x86-64 with ARCH_HAS_NMI_SAFE_THIS_CPU_OPS turned off, so that the
atomic NMI paths are used, a test runs kmalloc_nolock() and
kfree_nolock() in NMI, through a self NMI IPI, across 8 memcgs.
memcg_uncharge_kmem() ran in NMI 7 or 8 times per run, and afterwards
MEMCG_KMEM matched the page counter in every memcg. The race that
patch 1 fixes needs a flush to land between two instructions, and the
test does not reproduce it.
- The cgroup selftests test_core, test_kmem and test_memcontrol in a VM
give the same results with and without the series. The test cases
that fail in that VM also fail on the base kernel.
This patch (of 2):
On CONFIG_MEMCG_NMI_SAFETY_REQUIRES_ATOMIC architectures,
account_kmem_nmi_safe() and account_slab_nmi_safe() keep stat updates made
in NMI in atomics, which flush_nmi_stats() folds in when the css is
flushed. Since commit 8dcb0ed834a3 ("memcg: cgroup: call
css_rstat_updated irrespective of in_nmi()"), they mark the css updated
first and add the delta second. Regular stat updates do it the other way
around.
With this order, a flush on another CPU can take the css off the update
list and run flush_nmi_stats() between the two steps. The delta then
lands after the flush, while the css is no longer on the update list. It
waits there until the next update marks the css again. If the memcg is
freed first, the delta never reaches the ancestors, because
css_rstat_exit() only flushes csses that are on the update list.
Add the delta first. If the css is not on the update list yet,
__css_rstat_updated() puts it there with fully ordered cmpxchg operations,
so a flush that takes the css off the list also sees the delta. If the
css is already on the list, a concurrent flush can still miss the update.
That is the race described in css_process_update_tree(), which regular
updates have too.
Link: https://lore.kernel.org/20261204215709.4129739-1-shakeel.butt@linux.dev
Link: https://patch.msgid.link/20261204215709.4129739-2-shakeel.butt@linux.dev
Fixes: 8dcb0ed834a3 ("memcg: cgroup: call css_rstat_updated irrespective of in_nmi()")
Signed-off-by: Shakeel Butt <shakeel.butt@linux.dev>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Cc: Johannes Weiner <hannes@cmpxchg.org>
Cc: Michal Hocko <mhocko@kernel.org>
Cc: Roman Gushchin <roman.gushchin@linux.dev>
Cc: Muchun Song <muchun.song@linux.dev>
Cc: Alexei Starovoitov <ast@kernel.org>
Cc: Vlastimil Babka <vbabka@kernel.org>
Cc: Harry Yoo <harry@kernel.org>
Cc: Tejun Heo <tj@kernel.org>
mm/memcontrol.c | 14 ++++++++++----
1 file changed, 10 insertions(+), 4 deletions(-)
--- a/mm/memcontrol.c~memcg-add-nmi-stat-deltas-before-marking-the-css-updated
+++ a/mm/memcontrol.c
@@ -3016,12 +3016,15 @@ static inline void account_slab_nmi_safe
} else {
struct mem_cgroup_per_node *pn = memcg->nodeinfo[pgdat->node_id];
- /* 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
atomic_add(nr, &pn->slab_unreclaimable);
+ /*
+ * Mark the css after the update, like regular stat updates
+ * do. Preemption is disabled in_nmi().
+ */
+ __css_rstat_updated(&memcg->css, smp_processor_id());
}
}
#else
@@ -3240,9 +3243,12 @@ static inline void account_kmem_nmi_safe
if (likely(!in_nmi())) {
mod_memcg_state(memcg, MEMCG_KMEM, val);
} else {
- /* preemption is disabled in_nmi(). */
- __css_rstat_updated(&memcg->css, smp_processor_id());
atomic_add(val, &memcg->kmem_stat);
+ /*
+ * Mark the css after the update, like regular stat updates
+ * do. Preemption is disabled in_nmi().
+ */
+ __css_rstat_updated(&memcg->css, smp_processor_id());
}
}
#else
_
Patches currently in -mm which might be from shakeel.butt@linux.dev are
memcg-move-memoryhigh-enforcement-out-of-try_charge_memcg.patch
memcg-force-charges-from-reclaim-before-trying-the-limits.patch
memcg-use-high_work-for-kernel-threads.patch
memcg-use-high_work-for-remote-charges.patch
memcg-simplify-high-limit-handling-after-a-charge.patch
memcg-warn-when-memory-cgroup-ids-run-out.patch
memcg-add-nmi-stat-deltas-before-marking-the-css-updated.patch
memcg-make-memcg_uncharge_kmem-nmi-safe.patch
kernfs-report-times-and-link-count-from-the-node-in-getattr.patch
kernfs-dont-copy-times-and-link-count-into-the-inode-on-refresh.patch
kernfs-dont-take-kernfs_iattr_rwsem-for-the-directory-counters.patch
kernfs-dont-take-kernfs_iattr_rwsem-to-publish-kernfs_removing.patch
kernfs-update-a-directorys-times-without-kernfs_iattr_rwsem.patch
kernfs-dont-take-kernfs_iattr_rwsem-in-__kernfs_remove.patch
cgroup-dont-lose-a-task-in-css_task_iter-when-a-migration-fails.patch
cgroup-kill-a-child-forked-while-cgroupkill-runs.patch
cgroup-refuse-cgroupkill-below-a-threaded-cgroup.patch
cgroup-freezer-check-own-tasks-and-descendants-for-the-frozen-state.patch
cgroup-freezer-dont-update-the-frozen-state-of-removed-cgroups.patch
cgroup-freezer-test-the-freeze-trap-bit-under-siglock.patch
selftests-cgroup-test-cgroupprocs-reads-across-a-failed-migration.patch
selftests-cgroup-test-the-frozen-state-of-a-cgroup-with-tasks-and-children.patch
selftests-cgroup-test-cgroupkill-in-and-below-a-threaded-cgroup.patch
cgroup-factor-out-cgroup_kn_break_active-and-cgroup_kn_unbreak_active.patch
cgroup-dont-hold-cgroup_mutex-for-cgroupkill.patch
cgroup-freezer-dont-hold-cgroup_mutex-for-cgroupfreeze.patch
kernfs-dont-look-for-open-files-of-directories-when-draining.patch
kernfs-add-a-sequence-count-to-directories.patch
kernfs-list-directories-without-kernfs_rwsem.patch
percpu_ref-make-get-and-put-nmi-safe-where-this_cpu-ops-are-not.patch
percpu_ref-defer-the-release-function-when-the-last-put-is-in-nmi.patch
^ permalink raw reply [flat|nested] 5+ messages in thread
* + memcg-make-memcg_uncharge_kmem-nmi-safe.patch added to mm-new branch
2026-12-04 21:57 ` [PATCH 2/2] memcg: make memcg_uncharge_kmem() NMI safe Shakeel Butt
@ 2026-12-05 7:09 ` Andrew Morton
0 siblings, 0 replies; 5+ messages in thread
From: Andrew Morton @ 2026-12-05 7:09 UTC (permalink / raw)
To: mm-commits, vbabka, tj, roman.gushchin, muchun.song, mhocko,
harry, hannes, ast, shakeel.butt, akpm
The patch titled
Subject: memcg: make memcg_uncharge_kmem() NMI safe
has been added to the -mm mm-new branch. Its filename is
memcg-make-memcg_uncharge_kmem-nmi-safe.patch
This patch will shortly appear at
https://git.kernel.org/pub/scm/linux/kernel/git/akpm/25-new.git/tree/patches/memcg-make-memcg_uncharge_kmem-nmi-safe.patch
This patch will later appear in the mm-new branch at
git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
Note, mm-new is a provisional staging ground for work-in-progress
patches, and acceptance into mm-new is a notification for others take
notice and to finish up reviews. Please do not hesitate to respond to
review feedback and post updated versions to replace or incrementally
fixup patches in mm-new.
The mm-new branch of mm.git is not included in linux-next
If a few days of testing in mm-new is successful, the patch will me moved
into mm.git's mm-unstable branch, which is included in linux-next
Before you just go and hit "reply", please:
a) Consider who else should be cc'ed
b) Prefer to cc a suitable mailing list as well
c) Ideally: find the original patch on the mailing list and do a
reply-to-all to that, adding suitable additional cc's
*** Remember to use Documentation/process/submit-checklist.rst when testing your code ***
The -mm tree is included into linux-next via various
branches at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
and is updated there most days
------------------------------------------------------
From: Shakeel Butt <shakeel.butt@linux.dev>
Subject: memcg: make memcg_uncharge_kmem() NMI safe
Date: Fri, 04 Dec 2026 13:57:09 -0800
On architectures where this_cpu operations are not NMI safe but atomics
are (CONFIG_MEMCG_NMI_SAFETY_REQUIRES_ATOMIC), MEMCG_KMEM updates that can
run in NMI must go through account_kmem_nmi_safe(). The objcg charge and
uncharge paths do, but memcg_uncharge_kmem() still calls mod_memcg_state()
directly.
memcg_uncharge_kmem() runs in NMI when kmalloc_nolock() or kfree_nolock()
has to evict an object stock slot that holds at least a page of charged
bytes:
__refill_obj_stock()
drain_obj_stock_slot()
memcg_uncharge_kmem()
mod_memcg_state()
If the NMI interrupted mod_memcg_state() on the same CPU, the nested
read-modify-write of the per-CPU MEMCG_KMEM counter, or of the rstat
update counter, loses one of the two updates.
Use account_kmem_nmi_safe() in memcg_uncharge_kmem(). Outside NMI it
still calls mod_memcg_state(), so nothing changes there.
Hitting this needs slub_debug, because on these architectures
kmalloc_nolock() only works on slab debug caches. It also needs a base
page size below 64K, because an object stock slot holds at most U16_MAX
bytes, and a kernel without PREEMPT_RT, where local_trylock() always fails
in NMI.
Kernels without commit afe9ae3fda96 ("mm: memcontrol: factor out memcg
kmem uncharge sequence") have the same mod_memcg_state() call open-coded
in drain_obj_stock_slot(), or in drain_obj_stock() in older ones.
Backports to them need the change there.
Link: https://patch.msgid.link/20261204215709.4129739-3-shakeel.butt@linux.dev
Fixes: af92793e52c3 ("slab: Introduce kmalloc_nolock() and kfree_nolock().")
Signed-off-by: Shakeel Butt <shakeel.butt@linux.dev>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Cc: Johannes Weiner <hannes@cmpxchg.org>
Cc: Michal Hocko <mhocko@kernel.org>
Cc: Roman Gushchin <roman.gushchin@linux.dev>
Cc: Muchun Song <muchun.song@linux.dev>
Cc: Alexei Starovoitov <ast@kernel.org>
Cc: Vlastimil Babka <vbabka@kernel.org>
Cc: Harry Yoo <harry@kernel.org>
Cc: Tejun Heo <tj@kernel.org>
mm/memcontrol.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
--- a/mm/memcontrol.c~memcg-make-memcg_uncharge_kmem-nmi-safe
+++ a/mm/memcontrol.c
@@ -136,10 +136,11 @@ bool mem_cgroup_kmem_disabled(void)
}
static void memcg_uncharge(struct mem_cgroup *memcg, unsigned int nr_pages);
+static inline void account_kmem_nmi_safe(struct mem_cgroup *memcg, int val);
static void memcg_uncharge_kmem(struct mem_cgroup *memcg, unsigned int nr_pages)
{
- mod_memcg_state(memcg, MEMCG_KMEM, -nr_pages);
+ account_kmem_nmi_safe(memcg, -nr_pages);
memcg1_account_kmem(memcg, -nr_pages);
if (!mem_cgroup_is_root(memcg))
memcg_uncharge(memcg, nr_pages);
_
Patches currently in -mm which might be from shakeel.butt@linux.dev are
memcg-move-memoryhigh-enforcement-out-of-try_charge_memcg.patch
memcg-force-charges-from-reclaim-before-trying-the-limits.patch
memcg-use-high_work-for-kernel-threads.patch
memcg-use-high_work-for-remote-charges.patch
memcg-simplify-high-limit-handling-after-a-charge.patch
memcg-warn-when-memory-cgroup-ids-run-out.patch
memcg-add-nmi-stat-deltas-before-marking-the-css-updated.patch
memcg-make-memcg_uncharge_kmem-nmi-safe.patch
kernfs-report-times-and-link-count-from-the-node-in-getattr.patch
kernfs-dont-copy-times-and-link-count-into-the-inode-on-refresh.patch
kernfs-dont-take-kernfs_iattr_rwsem-for-the-directory-counters.patch
kernfs-dont-take-kernfs_iattr_rwsem-to-publish-kernfs_removing.patch
kernfs-update-a-directorys-times-without-kernfs_iattr_rwsem.patch
kernfs-dont-take-kernfs_iattr_rwsem-in-__kernfs_remove.patch
cgroup-dont-lose-a-task-in-css_task_iter-when-a-migration-fails.patch
cgroup-kill-a-child-forked-while-cgroupkill-runs.patch
cgroup-refuse-cgroupkill-below-a-threaded-cgroup.patch
cgroup-freezer-check-own-tasks-and-descendants-for-the-frozen-state.patch
cgroup-freezer-dont-update-the-frozen-state-of-removed-cgroups.patch
cgroup-freezer-test-the-freeze-trap-bit-under-siglock.patch
selftests-cgroup-test-cgroupprocs-reads-across-a-failed-migration.patch
selftests-cgroup-test-the-frozen-state-of-a-cgroup-with-tasks-and-children.patch
selftests-cgroup-test-cgroupkill-in-and-below-a-threaded-cgroup.patch
cgroup-factor-out-cgroup_kn_break_active-and-cgroup_kn_unbreak_active.patch
cgroup-dont-hold-cgroup_mutex-for-cgroupkill.patch
cgroup-freezer-dont-hold-cgroup_mutex-for-cgroupfreeze.patch
kernfs-dont-look-for-open-files-of-directories-when-draining.patch
kernfs-add-a-sequence-count-to-directories.patch
kernfs-list-directories-without-kernfs_rwsem.patch
percpu_ref-make-get-and-put-nmi-safe-where-this_cpu-ops-are-not.patch
percpu_ref-defer-the-release-function-when-the-last-put-is-in-nmi.patch
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2026-12-05 7:09 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-04 21:57 [PATCH 0/2] memcg: fix memcg stat updates made in NMI Shakeel Butt
2026-12-04 21:57 ` [PATCH 1/2] memcg: add NMI stat deltas before marking the css updated Shakeel Butt
2026-12-05 7:09 ` + memcg-add-nmi-stat-deltas-before-marking-the-css-updated.patch added to mm-new branch Andrew Morton
2026-12-04 21:57 ` [PATCH 2/2] memcg: make memcg_uncharge_kmem() NMI safe Shakeel Butt
2026-12-05 7:09 ` + memcg-make-memcg_uncharge_kmem-nmi-safe.patch added to mm-new branch Andrew Morton
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.