Re: [PATCH v2 1/2] driver/base: Optimize memory block registration to reduce boot time

From: Donet Tom
Date: Thu May 01 2025 - 09:56:21 EST



On 4/30/25 1:08 PM, Oscar Salvador wrote:
On Mon, Apr 28, 2025 at 10:33:46PM +0530, Donet Tom wrote:
During node device initialization, `memory blocks` are registered under
each NUMA node. The `memory blocks` to be registered are identified using
the node’s start and end PFNs, which are obtained from the node's pg_data

Hi Donet,

Test Results on My system with 32TB RAM
=======================================
1. Boot time with CONFIG_DEFERRED_STRUCT_PAGE_INIT enabled.

Without this patch
------------------
Startup finished in 1min 16.528s (kernel)

With this patch
---------------
Startup finished in 17.236s (kernel) - 78% Improvement
That is pretty impressive.

+void register_memory_blocks_under_node_early(int nid)
+{
+ struct memblock_region *r;
+ unsigned long start_block_id;
+ unsigned long end_block_id;
+ struct memory_block *mem;
+ unsigned long block_id;
+
+ for_each_mem_region(r) {
+ if (r->nid == nid) {
+ start_block_id = phys_to_block_id(r->base);
+ end_block_id = phys_to_block_id(r->base + r->size - 1);
+
+ for (block_id = start_block_id; block_id <= end_block_id; block_id++) {
+ mem = find_memory_block_by_id(block_id);
+ if (!mem)
+ continue;
I would just mention what David already said here, reduce identation,
and maybe declare the variables where they are needed. It might be clearer.


Sure, I will change it.

+
+ do_register_memory_block_under_node(nid, mem, MEMINIT_EARLY);
+ put_device(&mem->dev);
I will comment on the "context" on patch#2.

+void register_memory_blocks_under_node_early(int nid);
static void ... ?

Yes, We can make it as static. I will add it in next version.


Thanks
Donet