Skip to content

memcg: nmi-safe kmem charging

Shakeel Butt bpf cgroups linux-mm lkml 4 versions – Applied

Status from this message: [merged mm-stable] memcg-make-memcg_rstat_updated-nmi-safe.patch removed from -mm tree

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v4 Latest5 patches 3 repliesApplied 5/5
  2. v35 patches 2 repliesSuperseded
  3. v25 patches 8 repliesSuperseded
Earlier versions · 1
VersionPostedPatchesRepliesStatus
v14 patches13 repliesSuperseded

Changes in v4 from the cover letter

- Use internal config symbols for nmi unsafe configs as suggested by Johannes.

Patches in v4 All 5 applied

#Subject and filesSizeRepliesApplied
1/5memcg: disable kmem charging in nmi for unsupported archinit/Kconfig mm/memcontrol.c+10 -01 replyApplied
2/5memcg: nmi safe memcg stats for specific archsinclude/linux/memcontrol.h init/Kconfig mm/memcontrol.c+66 -00 repliesApplied
3/5memcg: add nmi-safe update for MEMCG_KMEMmm/memcontrol.c+19 -20 repliesApplied
4/5memcg: nmi-safe slab stats updatesmm/memcontrol.c+33 -30 repliesApplied
5/5memcg: make memcg_rstat_updated nmi safemm/memcontrol.c+9 -70 repliesApplied

Reviews trailers per patch

All 5 patches have a Reviewed-by or Acked-by.

PatchVlastimil Babka
1/5A-b
2/5A-b
3/5A-b
4/5A-b
5/5A-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v4 thread

Cover letter [PATCH v4 0/5] memcg: nmi-safe kmem charging

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 v3:
- Use internal config symbols for nmi unsafe configs as suggested by Johannes.

Changes since v2:
- Rearrange in_nmi() check as suggested by Vlastimil
- Fix commit messag of patch 5 as suggested by Vlastimil

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(-)
Signature · 1 line
2.47.1