Skip to contentSkip to conversation

mm/vmalloc: minor cleanups

PATCH Superseded Ye Liu 4 participants 14 messages Sep 14 – Sep 15

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Ye Liu

author
#0 lore raw

cover mm/vmalloc: minor cleanups

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.

---
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 | 58 ++++++++++++++++++++++++++++++----------------------------
 1 file changed, 30 insertions(+), 28 deletions(-)

---
base-commit: 68142f986ff04b2b70b31db00f719bf690f64a9a
change-id: 20260914-vmalloc_study-b3fe7c738f2a

Best regards,

Signature · 1 line
Ye Liu <[email protected]>
author
#1 lore raw

PATCH 1/3 mm/vmalloc: group xa_init with vbq field initializations

From: Ye Liu <[email protected]>

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

---
 mm/vmalloc.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
mm/vmalloc.c +2 -1
index 859e6d2d57a3..117483dd048c 100644
@@ -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);
 	}
 
 	/*
Signature · 1 line
2.25.1
maintainer Reviewed-by on v1 1/3
#2 lore raw

Re: [PATCH 1/3] mm/vmalloc: group xa_init with vbq field initializations

Quoted 31 lines · Ye Liu

From: Ye Liu <[email protected]>

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

---
 mm/vmalloc.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
mm/vmalloc.c +2 -1
index 859e6d2d57a3..117483dd048c 100644
@@ -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);
 	}
 
 	/*
Signature · 2 lines
-- 
2.25.1

LGTM:

--
Uladzislau Rezki

Reviewed-by on v1 1/3
#3 lore raw

Re: [PATCH 1/3] mm/vmalloc: group xa_init with vbq field initializations

In reply to Ye Liu
Quoted 7 lines · Ye Liu

From: Ye Liu <[email protected]>

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

---

LGTM

Quoted 21 lines
 mm/vmalloc.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
mm/vmalloc.c +2 -1
index 859e6d2d57a3..117483dd048c 100644
@@ -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);
 	}
 
 	/*
author
#4 lore raw

PATCH 2/3 mm/vmalloc: extract vmap_insert_free_area helper

In reply to Ye Liu

From: Ye Liu <[email protected]>

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.

---
 mm/vmalloc.c | 41 ++++++++++++++++++-----------------------
 1 file changed, 18 insertions(+), 23 deletions(-)
mm/vmalloc.c +18 -23
index 117483dd048c..797933ba9451 100644
@@ -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)
Signature · 1 line
2.25.1
maintainer Reviewed-by on v1 2/3
#5 lore raw

Re: [PATCH 2/3] mm/vmalloc: extract vmap_insert_free_area helper

Quoted 42 lines · Ye Liu

From: Ye Liu <[email protected]>

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.

---
 mm/vmalloc.c | 41 ++++++++++++++++++-----------------------
 1 file changed, 18 insertions(+), 23 deletions(-)
mm/vmalloc.c +13 -1
index 117483dd048c..797933ba9451 100644
@@ -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;
 
 	/*

mm/vmalloc.c static void __init vmap_init_free_space(void) · line 5462

Quoted 5 lines
mm/vmalloc.c +0 -1
@@ -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) {
 

This line gets removed and then re-added below because of removing space after (unsigned long). Maybe it is better to keep that space.

Quoted 32 lines
mm/vmalloc.c +5 -21
-			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);
 }
 
Quoted 5 lines

static void vmap_init_nodes(void)

Signature · 1 line
2.25.1

LGTM:

--
Uladzislau Rezki

author
#6 lore raw

Re: [PATCH 2/3] mm/vmalloc: extract vmap_insert_free_area helper

Quoted 41 lines · Uladzislau Rezki
Quoted 40 lines · Ye Liu

From: Ye Liu <[email protected]>

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.

---
 mm/vmalloc.c | 41 ++++++++++++++++++-----------------------
 1 file changed, 18 insertions(+), 23 deletions(-)
mm/vmalloc.c +13 -1
index 117483dd048c..797933ba9451 100644
@@ -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;
 
Quoted 9 lines

mm/vmalloc.c static void __init vmap_init_free_space(void) · line 5462

Quoted 7 lines
mm/vmalloc.c +0 -1
 	/*
@@ -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) {
 

This line gets removed and then re-added below because of removing space after (unsigned long). Maybe it is better to keep that space.

However, the '{' is still there, but I'll add a space anyway.

Quoted 44 lines
Quoted 33 lines
mm/vmalloc.c +5 -21
-			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);
 }
 
Quoted 5 lines

static void vmap_init_nodes(void)

Signature · 1 line
2.25.1

LGTM:

--
Uladzislau Rezki

Signature · 2 lines
Thanks,
Ye Liu
Reviewed-by
#7 lore raw

Re: [PATCH 2/3] mm/vmalloc: extract vmap_insert_free_area helper

Quoted 53 lines · Ye Liu
Quoted 41 lines · Uladzislau Rezki
Quoted 40 lines · Ye Liu

From: Ye Liu <[email protected]>

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.

---
 mm/vmalloc.c | 41 ++++++++++++++++++-----------------------
 1 file changed, 18 insertions(+), 23 deletions(-)
mm/vmalloc.c +13 -1
index 117483dd048c..797933ba9451 100644
@@ -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;
 
Quoted 9 lines

mm/vmalloc.c static void __init vmap_init_free_space(void) · line 5462

Quoted 7 lines
mm/vmalloc.c +0 -1
 	/*
@@ -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) {
 

This line gets removed and then re-added below because of removing space after (unsigned long). Maybe it is better to keep that space.

Quoted 1 line

However, the '{' is still there, but I'll add a space anyway.

Just mentioning in the commit message "while at it, drop redundant whitespace in "(unsigned long) busy->addr" should suffice.

author
#8 lore raw

PATCH 3/3 mm/vmalloc: extract show_busy_info from vmalloc_info_show

In reply to Ye Liu

From: Ye Liu <[email protected]>

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

---
 mm/vmalloc.c | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)
mm/vmalloc.c +10 -4
index 797933ba9451..7638845377f5 100644
@@ -5345,12 +5345,12 @@ 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;
 	struct vm_struct *v;
-	unsigned int *counters;
+	unsigned int *counters = NULL;
 
 	if (IS_ENABLED(CONFIG_NUMA))
 		counters = kmalloc_array(nr_node_ids, sizeof(unsigned int), GFP_KERNEL);
@@ -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;
 }
 
Signature · 1 line
2.25.1
maintainer Reviewed-by on v1 3/3
#9 lore raw

Re: [PATCH 3/3] mm/vmalloc: extract show_busy_info from vmalloc_info_show

Quoted 17 lines · Ye Liu

From: Ye Liu <[email protected]>

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

---
 mm/vmalloc.c | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)
mm/vmalloc.c +0 -0
index 797933ba9451..7638845377f5 100644
@@ -5345,12 +5345,12 @@ static void show_purge_info(struct seq_file *m)
 	}
 }

mm/vmalloc.c static void show_purge_info(struct seq_file *m) · line 5354

Quoted 10 lines
mm/vmalloc.c +2 -2
 
-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;
 	struct vm_struct *v;
-	unsigned int *counters;
+	unsigned int *counters = NULL;
 

Is setting counters setting to NULL odd here?

Other than that, LGTM:

--
Uladzislau Rezki

author
#10 lore raw

Re: [PATCH 3/3] mm/vmalloc: extract show_busy_info from vmalloc_info_show

Quoted 19 lines · Uladzislau Rezki
Quoted 18 lines · Ye Liu

From: Ye Liu <[email protected]>

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

---
 mm/vmalloc.c | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)
mm/vmalloc.c +0 -0
index 797933ba9451..7638845377f5 100644
@@ -5345,12 +5345,12 @@ static void show_purge_info(struct seq_file *m)
 	}
 }
 
Quoted 11 lines

mm/vmalloc.c static void show_purge_info(struct seq_file *m) · line 5354

Quoted 9 lines
mm/vmalloc.c +2 -2
-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;
 	struct vm_struct *v;
-	unsigned int *counters;
+	unsigned int *counters = NULL;
 

Is setting counters setting to NULL odd here?

I would remove '= NULL'.

Quoted 6 lines

Other than that, LGTM:

--
Uladzislau Rezki

Signature · 2 lines
Thanks,
Ye Liu
maintainer
#11 lore raw

Re: [PATCH 3/3] mm/vmalloc: extract show_busy_info from vmalloc_info_show

In reply to Uladzislau Rezki
Quoted 19 lines · On Mon, 14 Sep 2026 19:10:37 +0200 Uladzislau Rezki <[email protected]> wrote:
Quoted 18 lines · Ye Liu

From: Ye Liu <[email protected]>

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

---
 mm/vmalloc.c | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)
mm/vmalloc.c +0 -0
index 797933ba9451..7638845377f5 100644
@@ -5345,12 +5345,12 @@ static void show_purge_info(struct seq_file *m)
 	}
 }
 
Quoted 10 lines

mm/vmalloc.c static void show_purge_info(struct seq_file *m) · line 5354

Quoted 9 lines
mm/vmalloc.c +2 -2
-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;
 	struct vm_struct *v;
-	unsigned int *counters;
+	unsigned int *counters = NULL;
 

Is setting counters setting to NULL odd here?

static void show_busy_info(struct seq_file *m)

{
	...
	unsigned int *counters = NULL;

	if (IS_ENABLED(CONFIG_NUMA))
		counters = ...

	...

	if (IS_ENABLED(CONFIG_NUMA))
		kfree(counters);
	...
}

Presumably some dumb compiler or checker warned about kfree(uninitialized-val).

maintainer
#12 lore raw

Re: [PATCH 3/3] mm/vmalloc: extract show_busy_info from vmalloc_info_show

Quoted 47 lines · Andrew Morton
Quoted 19 lines · On Mon, 14 Sep 2026 19:10:37 +0200 Uladzislau Rezki <[email protected]> wrote:
Quoted 18 lines · Ye Liu

From: Ye Liu <[email protected]>

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

---
 mm/vmalloc.c | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)
mm/vmalloc.c +0 -0
index 797933ba9451..7638845377f5 100644
@@ -5345,12 +5345,12 @@ static void show_purge_info(struct seq_file *m)
 	}
 }
 
Quoted 10 lines

mm/vmalloc.c static void show_purge_info(struct seq_file *m) · line 5354

Quoted 9 lines
mm/vmalloc.c +2 -2
-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;
 	struct vm_struct *v;
-	unsigned int *counters;
+	unsigned int *counters = NULL;
 

Is setting counters setting to NULL odd here?

static void show_busy_info(struct seq_file *m)

{
	...
	unsigned int *counters = NULL;

	if (IS_ENABLED(CONFIG_NUMA))
		counters = ...

	...

	if (IS_ENABLED(CONFIG_NUMA))
		kfree(counters);
	...
}
Quoted 3 lines

Presumably some dumb compiler or checker warned about kfree(uninitialized-val).

Probably.

--
Uladzislau Rezki

Reviewed-by on v1 3/3
#13 lore raw

Re: [PATCH 3/3] mm/vmalloc: extract show_busy_info from vmalloc_info_show

In reply to Ye Liu
Quoted 16 lines · Ye Liu

From: Ye Liu <[email protected]>

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

---
 mm/vmalloc.c | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)
mm/vmalloc.c +0 -0
index 797933ba9451..7638845377f5 100644
@@ -5345,12 +5345,12 @@ static void show_purge_info(struct seq_file *m)
 	}

mm/vmalloc.c static void show_purge_info(struct seq_file *m) · line 5353

Quoted 10 lines
mm/vmalloc.c +2 -2
 }
 
-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;
 	struct vm_struct *v;
-	unsigned int *counters;
+	unsigned int *counters = NULL;

As pointed out by Uladzislau, setting to NULL is redundant.

Apart from that LGTM

Quoted 25 lines
mm/vmalloc.c +8 -2
 	if (IS_ENABLED(CONFIG_NUMA))
 		counters = kmalloc_array(nr_node_ids, sizeof(unsigned int), GFP_KERNEL);
@@ -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;
 }