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

From: David Hildenbrand
Date: Mon May 05 2025 - 03:39:04 EST


On 05.05.25 09:28, Oscar Salvador wrote:
On Mon, May 05, 2025 at 09:16:48AM +0200, David Hildenbrand wrote:
memory hotplug code never calls register_one_node(), unless I am missing
something.

During add_memory_resource(), we call __try_online_node(nid, false), meaning
we skip register_one_node().

The only caller of __try_online_node(nid, true) is try_online_node(), called
from CPU hotplug code, and I *guess* that is not required.

Well, I guess this is because we need to link the cpus to the node.
register_one_node() has two jobs: 1) register cpus belonging to the node
and 2) register memory-blocks belonging to the node (if any).

Ah, via __register_one_node() ...

I would assume that an offline node

(1) has no memory
(2) has no CPUs

When we *hotplug* either memory or CPUs, and we first online the node, there is nothing to register. Because if there would be something, the node would already be online.

In particular, try_offline_node() will only offline a node if

(A) No present pages: No pages are spanned anymore. This includes
offline memory blocks.
(B) No present CPUs.

But maybe there is some case that I am missing ...

--
Cheers,

David / dhildenb