Skip to content

madvise anon_name cleanups

Vlastimil Babka linux-mm lkml 2 versions – Applied

Status from this message: [merged mm-stable] mm-madvise-use-standard-madvise-locking-in-madvise_set_anon_name.patch removed from -mm tree

Get series with b4
b4 am [email protected] change-id 20250623-anon_name_cleanup-e89b687038ed

Versions newest first

  1. v2 Latest4 patches 20 repliesApplied 4/4
  2. v1 RFC2 patches 10 repliesSuperseded

Changes in v2 from the cover letter

- Refactor madvise_update_vma() to select between vma_modify_flags() and vma_modify_flags_name() based on Lorenzo's suggestion. This should
also address Suren's concerns.
- Reduce the code move from kernel/sys.c to code handling PR_SET_VMA_ANON_NAME, per Lorenzo.
- Added patches 3, 4 to unify mm locking.
- Link to v1: https://patch.msgid.link/[email protected]

Patches in v2 All 4 applied

#Subject and filesSizeRepliesApplied
1/4mm, madvise: simplify anon_name handlingmm/madvise.c+13 -247 repliesApplied
2/4mm, madvise: extract mm code from prctl_set_vma() to mm/madvise.cinclude/linux/mm.h kernel/sys.c mm/madvise.c+58 -583 repliesApplied
3/4mm, madvise: move madvise_set_anon_name() down the filemm/madvise.c+32 -325 repliesApplied
4/4mm, madvise: use standard madvise locking in madvise_set_anon_name()mm/madvise.c+9 -45 repliesApplied

Reviews trailers per patch

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

PatchDavid HildenbrandSuren BaghdasaryanLorenzo Stoakes
1/4A-b R-b R-b
2/4A-b R-b R-b
3/4A-b R-b R-b
4/4A-b R-b R-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes. Scroll the table sideways for all 3 reviewers.

Read the v2 thread

Cover letter [PATCH v2 0/4] madvise anon_name cleanups

While reviewing Lorenzo's madvise cleanups I've noticed that we can handle anon_name in madvise code much better, so sending that as patch
1. Initially I wanted to do first move the existing logic from madvise_vma_behavior() to madvise_update_vma() as a separate patch before the actual simplification but that would require adding anon_vma_name_put() in error handling paths only to be removed again, so it's a single patch to avoid churn.

It's also an opportunity to move some mm code from prctl under mm, hence patch 2. After code moving preparation in patch 3, also unify madvise lock handling for madvise_set_anon_name() in patch 4.

Based on mm-new.

Taking the RFC off as concerns from RFC should be addressed, but not without risk as patches 3+4 are new. Due to rewrite of patch 1 I didn't keep Suren's R-b (but thanks!).

---
Changes in v2:
- Refactor madvise_update_vma() to select between vma_modify_flags() and vma_modify_flags_name() based on Lorenzo's suggestion. This should
also address Suren's concerns.
- Reduce the code move from kernel/sys.c to code handling PR_SET_VMA_ANON_NAME, per Lorenzo.
- Added patches 3, 4 to unify mm locking.
- Link to v1: https://patch.msgid.link/[email protected]

---
Vlastimil Babka (4):
mm, madvise: simplify anon_name handling
mm, madvise: extract mm code from prctl_set_vma() to mm/madvise.c mm, madvise: move madvise_set_anon_name() down the file mm, madvise: use standard madvise locking in madvise_set_anon_name()

 include/linux/mm.h |  14 ++---
 kernel/sys.c       |  50 +----------------
 mm/madvise.c       | 154 ++++++++++++++++++++++++++++++++++-------------------
 3 files changed, 106 insertions(+), 112 deletions(-)

---
base-commit: 4216fd45fc9156da0ee33fcb25cc0a5265049e32
change-id: 20250623-anon_name_cleanup-e89b687038ed

Best regards,

Signature · 1 line
Vlastimil Babka <[email protected]>