bpf.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 0/5] memcg: nmi-safe kmem charging
@ 2025-05-16  6:49 Shakeel Butt
  2025-05-16  6:49 ` [PATCH 1/5] memcg: disable kmem charging in nmi for unsupported arch Shakeel Butt
                   ` (4 more replies)
  0 siblings, 5 replies; 14+ messages in thread
From: Shakeel Butt @ 2025-05-16  6:49 UTC (permalink / raw)
  To: Andrew Morton
  Cc: Johannes Weiner, Michal Hocko, Roman Gushchin, Muchun Song,
	Vlastimil Babka, Alexei Starovoitov, Sebastian Andrzej Siewior,
	Harry Yoo, Yosry Ahmed, Peter Zijlstra, Mathieu Desnoyers, bpf,
	linux-mm, cgroups, linux-kernel, Meta kernel team

Users can attached their BPF programs at arbitrary execution points in
the kernel and such BPF programs may run in nmi context. In addition,
these programs can trigger memcg charged kernel allocations in the nmi
context. However memcg charging infra for kernel memory is not equipped
to handle nmi context for all architectures.

This series removes the hurdles to enable kmem charging in the nmi
context for most of the archs. For archs without CONFIG_HAVE_NMI, this
series is a noop. For archs with NMI support and have
CONFIG_ARCH_HAS_NMI_SAFE_THIS_CPU_OPS, the previous work to make memcg
stats re-entrant is sufficient for allowing kmem charging in nmi
context. For archs with NMI support but without
CONFIG_ARCH_HAS_NMI_SAFE_THIS_CPU_OPS and with
ARCH_HAVE_NMI_SAFE_CMPXCHG, this series added infra to support kmem
charging in nmi context. Lastly those archs with NMI support but without
CONFIG_ARCH_HAS_NMI_SAFE_THIS_CPU_OPS and ARCH_HAVE_NMI_SAFE_CMPXCHG,
kmem charging in nmi context is not supported at all.

Mostly used archs have support for CONFIG_ARCH_HAS_NMI_SAFE_THIS_CPU_OPS
and this series should be almost a noop (other than making
memcg_rstat_updated nmi safe) for such archs. 

Changes since v1:
- The main change was to explicitly differentiate between archs which
  have sane NMI support from others and make the series almost a noop
  for such archs. (Suggested by Vlastimil)
- This version very explicitly describes where kmem charging in nmi
  context is supported and where it is not.

Shakeel Butt (5):
  memcg: disable kmem charging in nmi for unsupported arch
  memcg: nmi safe memcg stats for specific archs
  memcg: add nmi-safe update for MEMCG_KMEM
  memcg: nmi-safe slab stats updates
  memcg: make memcg_rstat_updated nmi safe

 include/linux/memcontrol.h |  21 ++++++
 mm/memcontrol.c            | 136 +++++++++++++++++++++++++++++++++----
 2 files changed, 145 insertions(+), 12 deletions(-)

-- 
2.47.1


^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2025-05-16 18:21 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-05-16  6:49 [PATCH v2 0/5] memcg: nmi-safe kmem charging Shakeel Butt
2025-05-16  6:49 ` [PATCH 1/5] memcg: disable kmem charging in nmi for unsupported arch Shakeel Butt
2025-05-16  9:30   ` Vlastimil Babka
2025-05-16 15:37     ` Shakeel Butt
2025-05-16 18:20       ` Shakeel Butt
2025-05-16  6:49 ` [PATCH 2/5] memcg: nmi safe memcg stats for specific archs Shakeel Butt
2025-05-16  9:43   ` Vlastimil Babka
2025-05-16  6:49 ` [PATCH 3/5] memcg: add nmi-safe update for MEMCG_KMEM Shakeel Butt
2025-05-16  9:43   ` Vlastimil Babka
2025-05-16  6:49 ` [PATCH 4/5] memcg: nmi-safe slab stats updates Shakeel Butt
2025-05-16  9:44   ` Vlastimil Babka
2025-05-16  6:49 ` [PATCH 5/5] memcg: make memcg_rstat_updated nmi safe Shakeel Butt
2025-05-16  9:45   ` Vlastimil Babka
2025-05-16 15:34     ` Shakeel Butt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).