mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 0/3] mm/vmalloc: minor cleanups
@ 2026-09-14  3:33 Ye Liu
  2026-09-14  3:34 ` [PATCH 1/3] mm/vmalloc: group xa_init with vbq field initializations Ye Liu
                   ` (2 more replies)
  0 siblings, 3 replies; 13+ messages in thread
From: Ye Liu @ 2026-09-14  3:33 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>
---
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,
-- 
Ye Liu <ye.liu@linux.dev>


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

* [PATCH 1/3] mm/vmalloc: group xa_init with vbq field initializations
  2026-09-14  3:33 [PATCH 0/3] mm/vmalloc: minor cleanups Ye Liu
@ 2026-09-14  3:34 ` Ye Liu
  2026-09-14 16:57   ` Uladzislau Rezki
  2026-09-15  3:52   ` Dev Jain
  2026-09-14  3:34 ` [PATCH 2/3] mm/vmalloc: extract vmap_insert_free_area helper Ye Liu
  2026-09-14  3:34 ` [PATCH 3/3] mm/vmalloc: extract show_busy_info from vmalloc_info_show Ye Liu
  2 siblings, 2 replies; 13+ messages in thread
From: Ye Liu @ 2026-09-14  3:34 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>
---
 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] 13+ messages in thread

* [PATCH 2/3] mm/vmalloc: extract vmap_insert_free_area helper
  2026-09-14  3:33 [PATCH 0/3] mm/vmalloc: minor cleanups Ye Liu
  2026-09-14  3:34 ` [PATCH 1/3] mm/vmalloc: group xa_init with vbq field initializations Ye Liu
@ 2026-09-14  3:34 ` Ye Liu
  2026-09-14 17:02   ` Uladzislau Rezki
  2026-09-14  3:34 ` [PATCH 3/3] mm/vmalloc: extract show_busy_info from vmalloc_info_show Ye Liu
  2 siblings, 1 reply; 13+ messages in thread
From: Ye Liu @ 2026-09-14  3:34 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>
---
 mm/vmalloc.c | 41 ++++++++++++++++++-----------------------
 1 file changed, 18 insertions(+), 23 deletions(-)

diff --git a/mm/vmalloc.c b/mm/vmalloc.c
index 117483dd048c..797933ba9451 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] 13+ messages in thread

* [PATCH 3/3] mm/vmalloc: extract show_busy_info from vmalloc_info_show
  2026-09-14  3:33 [PATCH 0/3] mm/vmalloc: minor cleanups Ye Liu
  2026-09-14  3:34 ` [PATCH 1/3] mm/vmalloc: group xa_init with vbq field initializations Ye Liu
  2026-09-14  3:34 ` [PATCH 2/3] mm/vmalloc: extract vmap_insert_free_area helper Ye Liu
@ 2026-09-14  3:34 ` Ye Liu
  2026-09-14 17:10   ` Uladzislau Rezki
  2026-09-15  4:23   ` Dev Jain
  2 siblings, 2 replies; 13+ messages in thread
From: Ye Liu @ 2026-09-14  3:34 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>
---
 mm/vmalloc.c | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/mm/vmalloc.c b/mm/vmalloc.c
index 797933ba9451..7638845377f5 100644
--- a/mm/vmalloc.c
+++ b/mm/vmalloc.c
@@ -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;
 }
 

-- 
2.25.1


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

* Re: [PATCH 1/3] mm/vmalloc: group xa_init with vbq field initializations
  2026-09-14  3:34 ` [PATCH 1/3] mm/vmalloc: group xa_init with vbq field initializations Ye Liu
@ 2026-09-14 16:57   ` Uladzislau Rezki
  2026-09-15  3:52   ` Dev Jain
  1 sibling, 0 replies; 13+ messages in thread
From: Uladzislau Rezki @ 2026-09-14 16:57 UTC (permalink / raw)
  To: Ye Liu; +Cc: Andrew Morton, Uladzislau Rezki, linux-mm, linux-kernel, Ye Liu

On Mon, Sep 14, 2026 at 11:34:00AM +0800, Ye Liu wrote:
> 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>
> ---
>  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
> 
LGTM:

Reviewed-by: Uladzislau Rezki (Sony) <urezki@gmail.com>

--
Uladzislau Rezki

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

* Re: [PATCH 2/3] mm/vmalloc: extract vmap_insert_free_area helper
  2026-09-14  3:34 ` [PATCH 2/3] mm/vmalloc: extract vmap_insert_free_area helper Ye Liu
@ 2026-09-14 17:02   ` Uladzislau Rezki
  2026-09-15  2:25     ` Ye Liu
  0 siblings, 1 reply; 13+ messages in thread
From: Uladzislau Rezki @ 2026-09-14 17:02 UTC (permalink / raw)
  To: Ye Liu; +Cc: Andrew Morton, Uladzislau Rezki, linux-mm, linux-kernel, Ye Liu

On Mon, Sep 14, 2026 at 11:34:01AM +0800, Ye Liu wrote:
> 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>
> ---
>  mm/vmalloc.c | 41 ++++++++++++++++++-----------------------
>  1 file changed, 18 insertions(+), 23 deletions(-)
> 
> diff --git a/mm/vmalloc.c b/mm/vmalloc.c
> index 117483dd048c..797933ba9451 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) {
>
This line gets removed and then re-added below because of removing space
after (unsigned long). Maybe it is better to keep that space.

> -			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
> 
LGTM:

Reviewed-by: Uladzislau Rezki (Sony) <urezki@gmail.com>

--
Uladzislau Rezki

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

* Re: [PATCH 3/3] mm/vmalloc: extract show_busy_info from vmalloc_info_show
  2026-09-14  3:34 ` [PATCH 3/3] mm/vmalloc: extract show_busy_info from vmalloc_info_show Ye Liu
@ 2026-09-14 17:10   ` Uladzislau Rezki
  2026-09-15  2:26     ` Ye Liu
  2026-09-15  4:38     ` Andrew Morton
  2026-09-15  4:23   ` Dev Jain
  1 sibling, 2 replies; 13+ messages in thread
From: Uladzislau Rezki @ 2026-09-14 17:10 UTC (permalink / raw)
  To: Ye Liu; +Cc: Andrew Morton, Uladzislau Rezki, linux-mm, linux-kernel, Ye Liu

On Mon, Sep 14, 2026 at 11:34:02AM +0800, Ye Liu wrote:
> 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>
> ---
>  mm/vmalloc.c | 14 ++++++++++----
>  1 file changed, 10 insertions(+), 4 deletions(-)
> 
> diff --git a/mm/vmalloc.c b/mm/vmalloc.c
> index 797933ba9451..7638845377f5 100644
> --- a/mm/vmalloc.c
> +++ b/mm/vmalloc.c
> @@ -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;
>
Is setting counters setting to NULL odd here?

Other than that, LGTM:

Reviewed-by: Uladzislau Rezki (Sony) <urezki@gmail.com>

--
Uladzislau Rezki

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

* Re: [PATCH 2/3] mm/vmalloc: extract vmap_insert_free_area helper
  2026-09-14 17:02   ` Uladzislau Rezki
@ 2026-09-15  2:25     ` Ye Liu
  2026-09-15  3:48       ` Dev Jain
  0 siblings, 1 reply; 13+ messages in thread
From: Ye Liu @ 2026-09-15  2:25 UTC (permalink / raw)
  To: Uladzislau Rezki; +Cc: Andrew Morton, linux-mm, linux-kernel, Ye Liu



在 2026/9/15 01:02, Uladzislau Rezki 写道:
> On Mon, Sep 14, 2026 at 11:34:01AM +0800, Ye Liu wrote:
>> 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>
>> ---
>>  mm/vmalloc.c | 41 ++++++++++++++++++-----------------------
>>  1 file changed, 18 insertions(+), 23 deletions(-)
>>
>> diff --git a/mm/vmalloc.c b/mm/vmalloc.c
>> index 117483dd048c..797933ba9451 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) {
>>
> 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.
> 
>> -			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
>>
> LGTM:
> 
> Reviewed-by: Uladzislau Rezki (Sony) <urezki@gmail.com>
> 
> --
> Uladzislau Rezki

-- 
Thanks,
Ye Liu


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

* Re: [PATCH 3/3] mm/vmalloc: extract show_busy_info from vmalloc_info_show
  2026-09-14 17:10   ` Uladzislau Rezki
@ 2026-09-15  2:26     ` Ye Liu
  2026-09-15  4:38     ` Andrew Morton
  1 sibling, 0 replies; 13+ messages in thread
From: Ye Liu @ 2026-09-15  2:26 UTC (permalink / raw)
  To: Uladzislau Rezki; +Cc: Andrew Morton, linux-mm, linux-kernel, Ye Liu



在 2026/9/15 01:10, Uladzislau Rezki 写道:
> On Mon, Sep 14, 2026 at 11:34:02AM +0800, Ye Liu wrote:
>> 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>
>> ---
>>  mm/vmalloc.c | 14 ++++++++++----
>>  1 file changed, 10 insertions(+), 4 deletions(-)
>>
>> diff --git a/mm/vmalloc.c b/mm/vmalloc.c
>> index 797933ba9451..7638845377f5 100644
>> --- a/mm/vmalloc.c
>> +++ b/mm/vmalloc.c
>> @@ -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;
>>
> Is setting counters setting to NULL odd here?
> 
I would remove '= NULL'.
> Other than that, LGTM:
> 
> Reviewed-by: Uladzislau Rezki (Sony) <urezki@gmail.com>
> 
> --
> Uladzislau Rezki

-- 
Thanks,
Ye Liu


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

* Re: [PATCH 2/3] mm/vmalloc: extract vmap_insert_free_area helper
  2026-09-15  2:25     ` Ye Liu
@ 2026-09-15  3:48       ` Dev Jain
  0 siblings, 0 replies; 13+ messages in thread
From: Dev Jain @ 2026-09-15  3:48 UTC (permalink / raw)
  To: Ye Liu, Uladzislau Rezki; +Cc: Andrew Morton, linux-mm, linux-kernel, Ye Liu



On 15/09/26 7:55 am, Ye Liu wrote:
> 
> 
> 在 2026/9/15 01:02, Uladzislau Rezki 写道:
>> On Mon, Sep 14, 2026 at 11:34:01AM +0800, Ye Liu wrote:
>>> 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>
>>> ---
>>>  mm/vmalloc.c | 41 ++++++++++++++++++-----------------------
>>>  1 file changed, 18 insertions(+), 23 deletions(-)
>>>
>>> diff --git a/mm/vmalloc.c b/mm/vmalloc.c
>>> index 117483dd048c..797933ba9451 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) {
>>>
>> 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.


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

Reviewed-by: Dev Jain <dev.jain@arm.com>


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

* Re: [PATCH 1/3] mm/vmalloc: group xa_init with vbq field initializations
  2026-09-14  3:34 ` [PATCH 1/3] mm/vmalloc: group xa_init with vbq field initializations Ye Liu
  2026-09-14 16:57   ` Uladzislau Rezki
@ 2026-09-15  3:52   ` Dev Jain
  1 sibling, 0 replies; 13+ messages in thread
From: Dev Jain @ 2026-09-15  3:52 UTC (permalink / raw)
  To: Ye Liu, Andrew Morton, Uladzislau Rezki; +Cc: linux-mm, linux-kernel, Ye Liu



On 14/09/26 9:04 am, Ye Liu wrote:
> 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>
> ---

LGTM

Reviewed-by: Dev Jain <dev.jain@arm.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);
>  	}
>  
>  	/*
> 


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

* Re: [PATCH 3/3] mm/vmalloc: extract show_busy_info from vmalloc_info_show
  2026-09-14  3:34 ` [PATCH 3/3] mm/vmalloc: extract show_busy_info from vmalloc_info_show Ye Liu
  2026-09-14 17:10   ` Uladzislau Rezki
@ 2026-09-15  4:23   ` Dev Jain
  1 sibling, 0 replies; 13+ messages in thread
From: Dev Jain @ 2026-09-15  4:23 UTC (permalink / raw)
  To: Ye Liu, Andrew Morton, Uladzislau Rezki; +Cc: linux-mm, linux-kernel, Ye Liu



On 14/09/26 9:04 am, Ye Liu wrote:
> 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>
> ---
>  mm/vmalloc.c | 14 ++++++++++----
>  1 file changed, 10 insertions(+), 4 deletions(-)
> 
> diff --git a/mm/vmalloc.c b/mm/vmalloc.c
> index 797933ba9451..7638845377f5 100644
> --- a/mm/vmalloc.c
> +++ b/mm/vmalloc.c
> @@ -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;

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

Apart from that LGTM

Reviewed-by: Dev Jain <dev.jain@arm.com>


>  
>  	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;
>  }
>  
> 


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

* Re: [PATCH 3/3] mm/vmalloc: extract show_busy_info from vmalloc_info_show
  2026-09-14 17:10   ` Uladzislau Rezki
  2026-09-15  2:26     ` Ye Liu
@ 2026-09-15  4:38     ` Andrew Morton
  1 sibling, 0 replies; 13+ messages in thread
From: Andrew Morton @ 2026-09-15  4:38 UTC (permalink / raw)
  To: Uladzislau Rezki; +Cc: Ye Liu, linux-mm, linux-kernel, Ye Liu

On Mon, 14 Sep 2026 19:10:37 +0200 Uladzislau Rezki <urezki@gmail.com> wrote:

> On Mon, Sep 14, 2026 at 11:34:02AM +0800, Ye Liu wrote:
> > 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>
> > ---
> >  mm/vmalloc.c | 14 ++++++++++----
> >  1 file changed, 10 insertions(+), 4 deletions(-)
> > 
> > diff --git a/mm/vmalloc.c b/mm/vmalloc.c
> > index 797933ba9451..7638845377f5 100644
> > --- a/mm/vmalloc.c
> > +++ b/mm/vmalloc.c
> > @@ -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;
> >
> 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).

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

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

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-14  3:33 [PATCH 0/3] mm/vmalloc: minor cleanups Ye Liu
2026-09-14  3:34 ` [PATCH 1/3] mm/vmalloc: group xa_init with vbq field initializations Ye Liu
2026-09-14 16:57   ` Uladzislau Rezki
2026-09-15  3:52   ` Dev Jain
2026-09-14  3:34 ` [PATCH 2/3] mm/vmalloc: extract vmap_insert_free_area helper Ye Liu
2026-09-14 17:02   ` Uladzislau Rezki
2026-09-15  2:25     ` Ye Liu
2026-09-15  3:48       ` Dev Jain
2026-09-14  3:34 ` [PATCH 3/3] mm/vmalloc: extract show_busy_info from vmalloc_info_show Ye Liu
2026-09-14 17:10   ` Uladzislau Rezki
2026-09-15  2:26     ` Ye Liu
2026-09-15  4:38     ` Andrew Morton
2026-09-15  4:23   ` Dev Jain

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®