ANBZ: #18841
Memory hotplug is a serial process that adds memory to Linux in the
granularity of memory blocks. We identified two memory initialization
functions that consume significant time when onling memory blocks:
- `__init_single_page`: initialize the struct page
- `__free_pages_core`: add page to the buddy allocator
We attempted to execute these two functions in parallel during the
process of hotplugging a memory block. The experimental results showed
that when the memory block size was 1GB, the hotplug speed was
increased by approximately 200%. However, when the memory block size
was 128MB, which is the more commonly used size, the hotplug speed
was even worse than that of serial execution.
Therefore, how to improve the hotplug speed when the memory block size
is 128MB remains a challenge.
Here is my idea:
- Defer the execution of these two functions and their associated
processs to the final phase of the entire hotplug process, so
that the hotplug speed will no longer be limited by the memory
block size.
- Perform parallel execution in the final phase, as previous
implementations have proven that this can accelerate the hotplug
process.
We introduce the new online function, `deferred_online_memory`, for
deferring the actual online process of memory blocks.
Additionally, we have added a command-line argument,
parallel_hotplug_ratio, which sets the ratio of parallel workers to
the number of CPUs on the node. When parallel_hotplug_ratio is 0,
the memory online process will no longer be deferred.
Signed-off-by: Yang Rong <youngrong@linux.alibaba.com>
Reviewed-by: Baolin Wang <baolin.wang@linux.alibaba.com>
Link: https://gitee.com/anolis/cloud-kernel/pulls/4622