Re: [PATCH v8] mm/vmalloc: Eliminated the lock contention from twice to once

From: Andrew Morton
Date: Thu Mar 07 2024 - 15:11:21 EST


On Wed, 6 Mar 2024 21:14:40 -0500 rulinhuang <rulin.huang@xxxxxxxxx> wrote:

> When allocating a new memory area where the mapping address range is
> known, it is observed that the vmap_node->busy.lock is acquired twice.
>
> The first acquisition occurs in the alloc_vmap_area() function when
> inserting the vm area into the vm mapping red-black tree. The second
> acquisition occurs in the setup_vmalloc_vm() function when updating the
> properties of the vm, such as flags and address, etc.
>
> Combine these two operations together in alloc_vmap_area(), which
> improves scalability when the vmap_node->busy.lock is contended.
> By doing so, the need to acquire the lock twice can also be eliminated
> to once.
>
> With the above change, tested on intel sapphire rapids
> platform(224 vcpu), a 4% performance improvement is
> gained on stress-ng/pthread(https://github.com/ColinIanKing/stress-ng),
> which is the stress test of thread creations.
>

Thanks. We're late in -rc7 so I'll queue this up for merging in the
next merge window.