[PATCH RFC 09/12] mm/vmalloc: collapse busy-tree find-then-unlink into a single mas_erase
Pranjal Arya
pranjal.arya at oss.qualcomm.com
Sat Jun 13 10:19:51 PDT 2026
find_unlink_vmap_area() previously walked the busy tree once (via
find_vmap_area_busy_locked() / __find_vmap_area_mt) and then erased
via a second walker (unlink_vmap_area_busy_locked). Two independent
maple-tree descents, one per call.
maple_tree exposes mas_erase() which combines lookup and erase in
one descent. Replace the find+unlink pair with a single mas_erase()
walker.
Signed-off-by: Pranjal Arya <pranjal.arya at oss.qualcomm.com>
---
mm/vmalloc.c | 18 ++++++++++++++++--
1 file changed, 16 insertions(+), 2 deletions(-)
diff --git a/mm/vmalloc.c b/mm/vmalloc.c
index 1b73001e197e..463127d5ce58 100644
--- a/mm/vmalloc.c
+++ b/mm/vmalloc.c
@@ -3122,10 +3122,24 @@ static struct vmap_area *find_unlink_vmap_area(unsigned long addr)
do {
vn = &vmap_nodes[i];
+ /*
+ * Combine the lookup and removal into a single maple-tree
+ * descent. mas_erase() positions the state at @addr and clears
+ * the slot in one pass, returning the previously stored VA.
+ * This saves the second mas_store(NULL) the original
+ * find_vmap_area_busy_locked + unlink_vmap_area_busy_locked
+ * pair issued, halving the busy-tree maple work per vfree.
+ */
spin_lock(&vn->busy.lock);
- va = find_vmap_area_busy_locked(addr, vn);
+ if (likely(vn->busy.mt_enabled)) {
+ MA_STATE(mas, &vn->busy.mt, addr, addr);
+
+ va = mas_erase(&mas);
+ } else {
+ va = NULL;
+ }
if (va)
- unlink_vmap_area_busy_locked(va, vn);
+ INIT_LIST_HEAD(&va->list);
spin_unlock(&vn->busy.lock);
if (va)
--
2.34.1
More information about the maple-tree
mailing list