Re: [PATCH v2 2/3] mm,memory_hotplug: Implement numa node notifier

From: Oscar Salvador
Date: Wed Apr 09 2025 - 12:58:43 EST


On Wed, Apr 09, 2025 at 09:44:52PM +0800, kernel test robot wrote:
> Hi Oscar,
>
> kernel test robot noticed the following build errors:
...
> >> drivers/base/node.c:115:5: error: redefinition of 'register_node_notifier'
> 115 | int register_node_notifier(struct notifier_block *nb)
> | ^
> include/linux/memory.h:172:19: note: previous definition is here
> 172 | static inline int register_node_notifier(struct notifier_block *nb)
> | ^
> >> drivers/base/node.c:121:6: error: redefinition of 'unregister_node_notifier'
> 121 | void unregister_node_notifier(struct notifier_block *nb)
> | ^
> include/linux/memory.h:176:20: note: previous definition is here
> 176 | static inline void unregister_node_notifier(struct notifier_block *nb)
> | ^
> >> drivers/base/node.c:127:5: error: redefinition of 'node_notify'
> 127 | int node_notify(unsigned long val, void *v)
> | ^
> include/linux/memory.h:179:19: note: previous definition is here
> 179 | static inline int node_notify(unsigned long val, void *v)
> | ^
> 3 errors generated.

Ah, I see. When CONFIG_MEMORY_HOTPLUG=n those come into play.
That is not a problem for the memory-notify thing because drivers/base/memory.c
gets compiled IFF CONFIG_MEMORY_HOTPLUG=y.
I am thinking two ways to fix this:

1) Move the code for node-notify to drivers/base/memory.c
2) Surround those functions within a
#ifdef CONFIG_MEMORY_HOTPLUG
...
#endif

Thoughts? I lean towards option #2 as it looks cleaner to me:

diff --git a/drivers/base/node.c b/drivers/base/node.c
index 182c71dfb5b8..3b084d71888a 100644
--- a/drivers/base/node.c
+++ b/drivers/base/node.c
@@ -110,6 +110,7 @@ static const struct attribute_group *node_access_node_groups[] = {
NULL,
};

+#ifdef CONFIG_MEMORY_HOTPLUG
static BLOCKING_NOTIFIER_HEAD(node_chain);

int register_node_notifier(struct notifier_block *nb)
@@ -128,6 +129,7 @@ int node_notify(unsigned long val, void *v)
{
return blocking_notifier_call_chain(&node_chain, val, v);
}
+#endif

static void node_remove_accesses(struct node *node)
{



--
Oscar Salvador
SUSE Labs