mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v2 0/3] mm/vmalloc: minor cleanups
@ 2026-09-15  2:43 Ye Liu
  2026-09-15  2:43 ` [PATCH v2 1/3] mm/vmalloc: group xa_init with vbq field initializations Ye Liu
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Ye Liu @ 2026-09-15  2:43 UTC (permalink / raw)
  To: Andrew Morton, Uladzislau Rezki; +Cc: linux-mm, linux-kernel, Ye Liu

Small cleanup series for mm/vmalloc.c, no functional changes:

- Group xa_init() with the other vmap_block_queue field initializations
  in vmalloc_init(), instead of after the unrelated vfree_deferred setup.

- Extract vmap_insert_free_area() helper to deduplicate the allocate-
  and-insert pattern that appeared both inside the loop body and after
  the loop in vmap_init_free_space().

- Extract show_busy_info() from vmalloc_info_show(), mirroring the
  existing show_purge_info() pattern, so the top-level show function
  only orchestrates the two data sources.

Signed-off-by: Ye Liu <liuye@kylinos.cn>
---
Changes in v2:
- Patch2: Keep space after (unsigned long) cast per Uladzislau's review.
- Patch3: Drop the NULL initialization of counters in show_busy_info. 
- Link to v1: https://lore.kernel.org/r/20260914-vmalloc_study-v1-0-526f68559706@linux.dev

---
Ye Liu (3):
      mm/vmalloc: group xa_init with vbq field initializations
      mm/vmalloc: extract vmap_insert_free_area helper
      mm/vmalloc: extract show_busy_info from vmalloc_info_show

 mm/vmalloc.c | 56 +++++++++++++++++++++++++++++---------------------------
 1 file changed, 29 insertions(+), 27 deletions(-)
---
base-commit: 68142f986ff04b2b70b31db00f719bf690f64a9a
change-id: 20260914-vmalloc_study-b3fe7c738f2a

Best regards,
-- 
Ye Liu <ye.liu@linux.dev>


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

* [PATCH v2 1/3] mm/vmalloc: group xa_init with vbq field initializations
  2026-09-15  2:43 [PATCH v2 0/3] mm/vmalloc: minor cleanups Ye Liu
@ 2026-09-15  2:43 ` Ye Liu
  2026-09-15  2:43 ` [PATCH v2 2/3] mm/vmalloc: extract vmap_insert_free_area helper Ye Liu
  2026-09-15  2:43 ` [PATCH v2 3/3] mm/vmalloc: extract show_busy_info from vmalloc_info_show Ye Liu
  2 siblings, 0 replies; 4+ messages in thread
From: Ye Liu @ 2026-09-15  2:43 UTC (permalink / raw)
  To: Andrew Morton, Uladzislau Rezki; +Cc: linux-mm, linux-kernel, Ye Liu

From: Ye Liu <liuye@kylinos.cn>

Move xa_init() next to the other vbq field initializations instead of
after the unrelated vfree_deferred setup.

Signed-off-by: Ye Liu <liuye@kylinos.cn>
Reviewed-by: Uladzislau Rezki (Sony) <urezki@gmail.com>
---
 mm/vmalloc.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/mm/vmalloc.c b/mm/vmalloc.c
index 859e6d2d57a3..117483dd048c 100644
--- a/mm/vmalloc.c
+++ b/mm/vmalloc.c
@@ -5585,10 +5585,11 @@ void __init vmalloc_init(void)
 		vbq = &per_cpu(vmap_block_queue, i);
 		spin_lock_init(&vbq->lock);
 		INIT_LIST_HEAD(&vbq->free);
+		xa_init(&vbq->vmap_blocks);
+
 		p = &per_cpu(vfree_deferred, i);
 		init_llist_head(&p->list);
 		INIT_WORK(&p->wq, delayed_vfree_work);
-		xa_init(&vbq->vmap_blocks);
 	}
 
 	/*

-- 
2.25.1


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

* [PATCH v2 2/3] mm/vmalloc: extract vmap_insert_free_area helper
  2026-09-15  2:43 [PATCH v2 0/3] mm/vmalloc: minor cleanups Ye Liu
  2026-09-15  2:43 ` [PATCH v2 1/3] mm/vmalloc: group xa_init with vbq field initializations Ye Liu
@ 2026-09-15  2:43 ` Ye Liu
  2026-09-15  2:43 ` [PATCH v2 3/3] mm/vmalloc: extract show_busy_info from vmalloc_info_show Ye Liu
  2 siblings, 0 replies; 4+ messages in thread
From: Ye Liu @ 2026-09-15  2:43 UTC (permalink / raw)
  To: Andrew Morton, Uladzislau Rezki; +Cc: linux-mm, linux-kernel, Ye Liu

From: Ye Liu <liuye@kylinos.cn>

The allocation and insertion of a free vmap_area is duplicated
between the loop body and the tail of vmap_init_free_space.  Factor
it into a small helper so the main function only deals with computing
the free gaps between busy regions.

Signed-off-by: Ye Liu <liuye@kylinos.cn>
Reviewed-by: Uladzislau Rezki (Sony) <urezki@gmail.com>
---
 mm/vmalloc.c | 41 ++++++++++++++++++-----------------------
 1 file changed, 18 insertions(+), 23 deletions(-)

diff --git a/mm/vmalloc.c b/mm/vmalloc.c
index 117483dd048c..973d15ef4f3e 100644
--- a/mm/vmalloc.c
+++ b/mm/vmalloc.c
@@ -5433,11 +5433,23 @@ module_init(proc_vmalloc_init);
 
 #endif
 
+static void __init vmap_insert_free_area(unsigned long start, unsigned long end)
+{
+	struct vmap_area *free = kmem_cache_zalloc(vmap_area_cachep, GFP_NOWAIT);
+
+	if (!WARN_ON_ONCE(!free)) {
+		free->va_start = start;
+		free->va_end = end;
+		insert_vmap_area_augment(free, NULL,
+					 &free_vmap_area_root,
+					 &free_vmap_area_list);
+	}
+}
+
 static void __init vmap_init_free_space(void)
 {
 	unsigned long vmap_start = 1;
 	const unsigned long vmap_end = ULONG_MAX;
-	struct vmap_area *free;
 	struct vm_struct *busy;
 
 	/*
@@ -5447,32 +5459,15 @@ static void __init vmap_init_free_space(void)
 	 *  |<--------------------------------->|
 	 */
 	for (busy = vmlist; busy; busy = busy->next) {
-		if ((unsigned long) busy->addr - vmap_start > 0) {
-			free = kmem_cache_zalloc(vmap_area_cachep, GFP_NOWAIT);
-			if (!WARN_ON_ONCE(!free)) {
-				free->va_start = vmap_start;
-				free->va_end = (unsigned long) busy->addr;
-
-				insert_vmap_area_augment(free, NULL,
-					&free_vmap_area_root,
-						&free_vmap_area_list);
-			}
-		}
+		if ((unsigned long) busy->addr - vmap_start > 0)
+			vmap_insert_free_area(vmap_start,
+					      (unsigned long) busy->addr);
 
 		vmap_start = (unsigned long) busy->addr + busy->size;
 	}
 
-	if (vmap_end - vmap_start > 0) {
-		free = kmem_cache_zalloc(vmap_area_cachep, GFP_NOWAIT);
-		if (!WARN_ON_ONCE(!free)) {
-			free->va_start = vmap_start;
-			free->va_end = vmap_end;
-
-			insert_vmap_area_augment(free, NULL,
-				&free_vmap_area_root,
-					&free_vmap_area_list);
-		}
-	}
+	if (vmap_end - vmap_start > 0)
+		vmap_insert_free_area(vmap_start, vmap_end);
 }
 
 static void vmap_init_nodes(void)

-- 
2.25.1


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

* [PATCH v2 3/3] mm/vmalloc: extract show_busy_info from vmalloc_info_show
  2026-09-15  2:43 [PATCH v2 0/3] mm/vmalloc: minor cleanups Ye Liu
  2026-09-15  2:43 ` [PATCH v2 1/3] mm/vmalloc: group xa_init with vbq field initializations Ye Liu
  2026-09-15  2:43 ` [PATCH v2 2/3] mm/vmalloc: extract vmap_insert_free_area helper Ye Liu
@ 2026-09-15  2:43 ` Ye Liu
  2 siblings, 0 replies; 4+ messages in thread
From: Ye Liu @ 2026-09-15  2:43 UTC (permalink / raw)
  To: Andrew Morton, Uladzislau Rezki; +Cc: linux-mm, linux-kernel, Ye Liu

From: Ye Liu <liuye@kylinos.cn>

Extract the busy vmap area iteration into show_busy_info, mirroring
the existing show_purge_info pattern.

Signed-off-by: Ye Liu <liuye@kylinos.cn>
Reviewed-by: Uladzislau Rezki (Sony) <urezki@gmail.com>
---
 mm/vmalloc.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/mm/vmalloc.c b/mm/vmalloc.c
index 973d15ef4f3e..e09d6c8c8b35 100644
--- a/mm/vmalloc.c
+++ b/mm/vmalloc.c
@@ -5345,7 +5345,7 @@ static void show_purge_info(struct seq_file *m)
 	}
 }
 
-static int vmalloc_info_show(struct seq_file *m, void *p)
+static void show_busy_info(struct seq_file *m)
 {
 	struct vmap_node *vn;
 	struct vmap_area *va;
@@ -5415,12 +5415,18 @@ static int vmalloc_info_show(struct seq_file *m, void *p)
 		spin_unlock(&vn->busy.lock);
 	}
 
+	if (IS_ENABLED(CONFIG_NUMA))
+		kfree(counters);
+}
+
+static int vmalloc_info_show(struct seq_file *m, void *p)
+{
+	show_busy_info(m);
+
 	/*
 	 * As a final step, dump "unpurged" areas.
 	 */
 	show_purge_info(m);
-	if (IS_ENABLED(CONFIG_NUMA))
-		kfree(counters);
 	return 0;
 }
 

-- 
2.25.1


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

end of thread, other threads:[~2026-09-15  2:43 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-15  2:43 [PATCH v2 0/3] mm/vmalloc: minor cleanups Ye Liu
2026-09-15  2:43 ` [PATCH v2 1/3] mm/vmalloc: group xa_init with vbq field initializations Ye Liu
2026-09-15  2:43 ` [PATCH v2 2/3] mm/vmalloc: extract vmap_insert_free_area helper Ye Liu
2026-09-15  2:43 ` [PATCH v2 3/3] mm/vmalloc: extract show_busy_info from vmalloc_info_show Ye Liu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®