Re: [PATCH 2/3] mm/vmalloc: extract vmap_insert_free_area helper
From: Dev Jain
Date: Mon Sep 14 2026 - 23:53:26 EST
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@xxxxxxxxxx>
>>>
>>> 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@xxxxxxxxxx>
>>> ---
>>> 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@xxxxxxx>