Skip to content

mm/execmem: fixes and cleanups for the ROX cache

Mike Rapoport (Microsoft) linux-input linux-mm lkml stable 1 version Applied

Status from this message: [merged mm-stable] mm-execmem-use-cleanup-infrastructure-in-rox-cache-functions.patch removed from -mm tree

Get series with b4
b4 am [email protected] change-id 20260903-execmem-rox-cache-pmd-v1-ab97da2c4364

Versions newest first

  1. v1 Latest5 patches 0 repliesApplied 5/5

Patches in v1 All 5 applied

#Subject and filesSizeRepliesApplied
1/5mm/execmem: free ROX cache chunks only when they span an entire vm areamm/execmem.c+3 -10 repliesApplied
2/5mm/execmem: handle potential allocation errors in the maple treemm/execmem.c+22 -100 repliesApplied
3/5mm/execmem: make sure ROX cache always contains multiples of PMD_SIZEinclude/linux/vmalloc.h mm/execmem.c mm/vmalloc.c+62 -300 repliesApplied
4/5mm/vmalloc: add DEFINE_FREE() for vfree()drivers/hid/hid-core.c include/linux/vmalloc.h+5 -20 repliesApplied
5/5mm/execmem: use cleanup infrastructure in ROX cache functionsmm/execmem.c+10 -220 repliesApplied

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [PATCH 0/5] mm/execmem: fixes and cleanups for the ROX cache

Sashiko review of the ROX cache refill path asked what happens when the PMD_SIZE allocation fails there. Pulling that thread uncovered a bit more than the fallback.

Patch 1 fixes a real bug, although rare bug: execmem_cache_clean() can free a chunk that is still partially in use, because a PMD sized and PMD aligned free range in the middle of a larger chunk looks exactly like a chunk that nobody uses.

Patch 2 handles maple tree allocation failures in the cache. They are unlikely, but silently dropping an area from the tree is not a great way to deal with them.

Patch 3 deals with the fallback that started all this. The cache exists to keep the direct map free of unnecessary splits, and the fallback happily filled it with base page mapped areas that could never be freed from the cache again. Ask vmalloc for a huge mapping or nothing, and serve whatever does not fit outside the cache.

Patches 4 and 5 convert the ROX cache to scope based cleanup.

The series was tested on x86 with module load/unload cycles, with PTDUMP confirming that the cache is using 2M mappings, and with nohugevmalloc to exercise the uncached fallback.

---
Mike Rapoport (Microsoft) (5):
mm/execmem: free ROX cache chunks only when they span an entire vm area mm/execmem: handle potential allocation errors in the maple tree mm/execmem: make sure ROX cache always contains multiples of PMD_SIZE mm/vmalloc: add DEFINE_FREE() for vfree()
mm/execmem: use cleanup infrastructure in ROX cache functions

 drivers/hid/hid-core.c  |   4 +-
 include/linux/vmalloc.h |   4 ++
 mm/execmem.c            | 124 ++++++++++++++++++++++++++++--------------------
 mm/vmalloc.c            |  15 +++++-
 4 files changed, 92 insertions(+), 55 deletions(-)

---
base-commit: 8499b4645c7f199707510461779f82d85732e742
change-id: 20260903-execmem-rox-cache-pmd-v1-ab97da2c4364
prerequisite-change-id: 20260816-execmem-set-vm-perms-v0-2-bae847a4f64f:v3
prerequisite-patch-id: 4d8c7989581fd5f4aaa2e315bfc903a9f0aadedc
prerequisite-patch-id: 211c002f2501d5aad7dea733fc6273c76bed910f
prerequisite-patch-id: a328539ba621866e4a63b39ab72a54dbfb3ed0a1
prerequisite-patch-id: 991f843051a913188e0cb671f3e8768682f895e5
prerequisite-patch-id: c05688baf37b3e80a57fe85d351f997f017acea2
prerequisite-patch-id: 36038f3f55748416fe56dc990d3836f70e851f59

--
Sincerely yours,
Mike.