Skip to content
Commit aaab830a authored by rulinhuang's avatar rulinhuang Committed by Andrew Morton
Browse files

mm/vmalloc: eliminated the lock contention from twice to once

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.

Link: https://lkml.kernel.org/r/20240307021440.64967-1-rulin.huang@intel.com


Co-developed-by: default avatar"Chen, Tim C" <tim.c.chen@intel.com>
Signed-off-by: default avatar"Chen, Tim C" <tim.c.chen@intel.com>
Co-developed-by: default avatar"King, Colin" <colin.king@intel.com>
Signed-off-by: default avatar"King, Colin" <colin.king@intel.com>
Signed-off-by: default avatarrulinhuang <rulin.huang@intel.com>
Reviewed-by: default avatarBaoquan He <bhe@redhat.com>
Reviewed-by: default avatarUladzislau Rezki (Sony) <urezki@gmail.com>
Cc: Tim Chen <tim.c.chen@linux.intel.com>
Cc: Christoph Hellwig <hch@infradead.org>
Cc: Lorenzo Stoakes <lstoakes@gmail.com>
Cc: Wangyang Guo <wangyang.guo@intel.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
parent c8d36bc2
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment