drivers/base/node: fold node register and unregister functions
Subsystems (7)
v2 cover drivers/base/node: fold node register and unregister functions
This change came from the discussion in [1]. It consists of two patches:
The first patch merges register_one_node() and register_node(), leaving a single register_node() function.
The second patch merges unregister_one_node() and unregister_node(), leaving a single unregister_node() function.
There is no functional change in these patches.
[1] https://lore.kernel.org/all/[email protected]/
---
v1 -> v2
- Changed commit description
- Removed extern from the function declarations of register_node() and unregister_node().
v1 - https://lore.kernel.org/all/[email protected]/
Donet Tom (2):
drivers/base/node: Fold register_node() into register_one_node() drivers/base/node: Fold unregister_node() into unregister_one_node()
arch/powerpc/platforms/pseries/pci_dlpar.c | 2 +- arch/x86/mm/numa.c | 4 +- drivers/base/node.c | 90 +++++++++------------- include/linux/node.h | 10 +-- mm/memory_hotplug.c | 8 +- mm/mm_init.c | 2 +- 6 files changed, 49 insertions(+), 67 deletions(-)
Signature · 1 line
2.47.1
PATCH v2 1/2 drivers/base/node: Fold register_node() into register_one_node()
The function register_node() is only called from register_one_node(). This patch folds register_node() into its only caller and renames register_one_node() to register_node().
This reduces unnecessary indirection and simplifies the code structure. No functional changes are introduced.
--- arch/powerpc/platforms/pseries/pci_dlpar.c | 2 +- arch/x86/mm/numa.c | 4 +- drivers/base/node.c | 52 +++++++++------------- include/linux/node.h | 4 +- mm/memory_hotplug.c | 4 +- mm/mm_init.c | 2 +- 6 files changed, 28 insertions(+), 40 deletions(-)
arch/powerpc/platforms/pseries/pci_dlpar.c +1 -1
@@ -29,7 +29,7 @@ struct pci_controller *init_phb_dynamic(struct device_node *dn) nid =of_node_to_nid (dn);if (likely ((nid) >=0 )) {if (!node_online (nid)) { -if (register_one_node (nid)) { +if (register_node (nid)) {pr_err ("PCI: Failed to register node %d\n" , nid); }else {update_numa_distance (dn);
arch/x86/mm/numa.c +2 -2
@@ -262,7 +262,7 @@ void __init init_gi_nodes(void)* bringup_nonboot_cpus * cpu_up * __try_online_node -* register_one_node +* register_node * because node_subsys is not initialized yet. * TODO remove dependency on node_online */
@@ -303,7 +303,7 @@ void __init init_cpu_to_node(void)* bringup_nonboot_cpus * cpu_up * __try_online_node -* register_one_node +* register_node * because node_subsys is not initialized yet. * TODO remove dependency on node_online */
drivers/base/node.c +20 -32
81 lines not on this page · raw message
include/linux/node.h +2 -2
@@ -176,7 +176,7 @@ static inline int hotplug_node_notifier(notifier_fn_t fn, int pri)#ifdef CONFIG_NUMA extern void node_dev_init (void );/* Core of the node registration - only memory hotplug should use this */ -extern int register_one_node (int nid); +int register_node (int nid);extern void unregister_one_node (int nid);extern int register_cpu_under_node (unsigned int cpu,unsigned int nid);extern int unregister_cpu_under_node (unsigned int cpu,unsigned int nid);
@@ -189,7 +189,7 @@ extern int register_memory_node_under_compute_node(unsigned int mem_nid,static inline void node_dev_init (void ) { } -static inline int register_one_node (int nid) +static inline int register_node (int nid) {return 0 ; }
mm/memory_hotplug.c +2 -2
@@ -1311,7 +1311,7 @@ static int __try_online_node(int nid, bool set_node_online)if (set_node_online) {node_set_online (nid); - ret =register_one_node (nid); + ret =register_node (nid);BUG_ON (ret); } out:
@@ -1542,7 +1542,7 @@ int add_memory_resource(int nid, struct resource *res, mhp_t mhp_flags) goto error_memblock_remove;if (ret) {node_set_online (nid); - ret =register_one_node (nid); + ret =register_node (nid);if (WARN_ON (ret)) {node_set_offline (nid); goto error_memblock_remove;
mm/mm_init.c +1 -1
@@ -1909,7 +1909,7 @@ void __init free_area_init(unsigned long *max_zone_pfn)free_area_init_node (nid);/* -* No sysfs hierarchy will be created via register_one_node() +* No sysfs hierarchy will be created via register_node() *for memory-less node because here it's not marked as N_MEMORY *and won't be set online later. The benefit is userspace *program won't be confused by sysfs files/directories of
Signature · 1 line
2.47.1
PATCH v2 2/2 drivers/base/node: Fold unregister_node() into unregister_one_node()
In reply to Donet TomThe function unregister_node() is only called from unregister_one_node(). This patch folds unregister_node() into its only caller and renames unregister_one_node() to unregister_node().
This reduces unnecessary indirection and simplifies the code structure. No functional changes are introduced.
--- drivers/base/node.c | 38 +++++++++++++++++--------------------- include/linux/node.h | 6 ++---- mm/memory_hotplug.c | 4 ++-- 3 files changed, 21 insertions(+), 27 deletions(-)
drivers/base/node.c +17 -21
@@ -676,23 +676,6 @@ static void node_device_release(struct device *dev)kfree (to_node (dev)); } -/** -* unregister_node - unregister a node device -* @node: node going away -* -* Unregisters a node device @node. All the devices on the node must be -* unregistered before calling this function. -*/ -void unregister_node (struct node *node) -{ -hugetlb_unregister_node (node); -compaction_unregister_node (node); -reclaim_unregister_node (node); -node_remove_accesses (node); -node_remove_caches (node); -device_unregister (&node->dev); -} -struct node *node_devices[MAX_NUMNODES ];/*
@@ -924,13 +907,26 @@ int register_node(int nid)return error; } - -void unregister_one_node (int nid) +/** +* unregister_node - unregister a node device +* @nid: nid of the node going away +* +* Unregisters the node device at node id @nid. All the devices on the +* node must be unregistered before calling this function. +*/ +void unregister_node (int nid) { -if (!node_devices[nid]) +struct node *node = node_devices[nid]; + +if (!node)return ; -unregister_node (node_devices[nid]); +hugetlb_unregister_node (node); +compaction_unregister_node (node); +reclaim_unregister_node (node); +node_remove_accesses (node); +node_remove_caches (node); +device_unregister (&node->dev); node_devices[nid] =NULL ; }
include/linux/node.h +2 -4
@@ -132,8 +132,6 @@ static inline void register_memory_blocks_under_nodes(void) }#endif -extern void unregister_node (struct node *node); -struct node_notify {int nid; };
@@ -177,7 +175,7 @@ static inline int hotplug_node_notifier(notifier_fn_t fn, int pri)extern void node_dev_init (void );/* Core of the node registration - only memory hotplug should use this */ int register_node (int nid); -extern void unregister_one_node (int nid); +void unregister_node (int nid);extern int register_cpu_under_node (unsigned int cpu,unsigned int nid);extern int unregister_cpu_under_node (unsigned int cpu,unsigned int nid);extern void unregister_memory_block_under_nodes (struct memory_block *mem_blk);
@@ -193,7 +191,7 @@ static inline int register_node(int nid) {return 0 ; } -static inline int unregister_one_node (int nid) +static inline int unregister_node (int nid) {return 0 ; }
mm/memory_hotplug.c +2 -2
@@ -1596,7 +1596,7 @@ int add_memory_resource(int nid, struct resource *res, mhp_t mhp_flags) error:if (new_node) {node_set_offline (nid); -unregister_one_node (nid); +unregister_node (nid); } error_memblock_remove:if (IS_ENABLED (CONFIG_ARCH_KEEP_MEMBLOCK ))
@@ -2201,7 +2201,7 @@ void try_offline_node(int nid)* node now. */ node_set_offline (nid); -unregister_one_node (nid); +unregister_node (nid); }EXPORT_SYMBOL (try_offline_node);
Signature · 1 line
2.47.1
kernel test robot
build botRe: [PATCH v2 1/2] drivers/base/node: Fold register_node() into register_one_node()
In reply to Donet Tomkernel test robot noticed the following build warnings:
Hi Donet,
kernel test robot noticed the following build warnings:
[auto build test WARNING on akpm-mm/mm-everything]
[also build test WARNING on powerpc/fixes linus/master v6.18-rc1 next-20251014]
[cannot apply to driver-core/driver-core-testing driver-core/driver-core-next driver-core/driver-core-linus powerpc/next tip/x86/mm rppt-memblock/for-next rppt-memblock/fixes] [If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Donet-Tom/drivers-base-node-Fold-register_node-into-register_one_node/20251015-000850 base: https://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm.git mm-everything patch link: https://lore.kernel.org/r/910853c9dd61f7a2190a56cba101e73e9c6859be.1760097207.git.donettom%40linux.ibm.com patch subject: [PATCH v2 1/2] drivers/base/node: Fold register_node() into register_one_node() config: s390-randconfig-001-20251015 (https://download.01.org/0day-ci/archive/20251015/[email protected]/config) compiler: s390-linux-gcc (GCC) 12.5.0 reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20251015/[email protected]/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All warnings (new ones prefixed by >>):
>> Warning: drivers/base/node.c:889 function parameter 'nid' not described in 'register_node'
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
Re: [PATCH v2 1/2] drivers/base/node: Fold register_node() into register_one_node()
Quoted 8 lines · kernel test robot
Hi Donet,
kernel test robot noticed the following build warnings:
[auto build test WARNING on akpm-mm/mm-everything]
[also build test WARNING on powerpc/fixes linus/master v6.18-rc1 next-20251014]
[cannot apply to driver-core/driver-core-testing driver-core/driver-core-next driver-core/driver-core-linus powerpc/next tip/x86/mm rppt-memblock/for-next rppt-memblock/fixes] [If your patch is applied to the wrong git tree, kindly drop us a note.
This patch is based on the mm-new branch. It is not applying cleanly on target branch because the target branches are missing some patches that are present in mm-new.
Quoted 19 lines
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]url: https://github.com/intel-lab-lkp/linux/commits/Donet-Tom/drivers-base-node-Fold-register_node-into-register_one_node/20251015-000850 base: https://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm.git mm-everything patch link: https://lore.kernel.org/r/910853c9dd61f7a2190a56cba101e73e9c6859be.1760097207.git.donettom%40linux.ibm.com patch subject: [PATCH v2 1/2] drivers/base/node: Fold register_node() into register_one_node() config: s390-randconfig-001-20251015 (https://download.01.org/0day-ci/archive/20251015/[email protected]/config) compiler: s390-linux-gcc (GCC) 12.5.0 reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20251015/[email protected]/reproduce)If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/All warnings (new ones prefixed by >>):
Quoted 1 line
Quoted 1 line
Warning:
drivers/base/node.c:889function parameter 'nid' not described in 'register_node'
Re: [PATCH v2 1/2] drivers/base/node: Fold register_node() into register_one_node()
In reply to Donet TomQuoted 10 lines · Donet Tom
The function
register_node()is only called fromregister_one_node(). This patch foldsregister_node()into its only caller and renamesregister_one_node()toregister_node().This reduces unnecessary indirection and simplifies the code structure. No functional changes are introduced.
Signed-off-by Donet Tom <[email protected]>---
[...]
drivers/base/node.c void register_memory_blocks_under_node_hotplug(int nid, unsigned long start_pfn, · line 886
Quoted 12 lines
/**
*unregister_node- unregister a node device
* @node: node going awaydrivers/base/node.c +3
-1@@ -907,7 +880,13 @@ void register_memory_blocks_under_node_hotplug(int nid, unsigned long start_pfn, }#endif /* CONFIG_MEMORY_HOTPLUG */ -int register_one_node (int nid) +/** +* register_node - Initialize and register the node device. +* @nid - Node number to use when creating the device.
I assume that should be "@nid: ..." to silence the warning.
Signature · 3 lines
Cheers David / dhildenb
Re: [PATCH v2 1/2] drivers/base/node: Fold register_node() into register_one_node()
In reply to Donet TomQuoted 9 lines · On Tue, 14 Oct 2025 21:09:16 +0530 Donet Tom <[email protected]> wrote:
The function
register_node()is only called fromregister_one_node(). This patch foldsregister_node()into its only caller and renamesregister_one_node()toregister_node().This reduces unnecessary indirection and simplifies the code structure. No functional changes are introduced.
Signed-off-by Donet Tom <[email protected]>
Thanks,
SJ
[...]
Re: [PATCH v2 2/2] drivers/base/node: Fold unregister_node() into unregister_one_node()
In reply to Donet TomQuoted 10 lines · On Tue, 14 Oct 2025 21:09:17 +0530 Donet Tom <[email protected]> wrote:
The function
unregister_node()is only called fromunregister_one_node(). This patch foldsunregister_node()into its only caller and renamesunregister_one_node()tounregister_node().This reduces unnecessary indirection and simplifies the code structure. No functional changes are introduced.
Signed-off-by Donet Tom <[email protected]>
Quoted 35 lines
--- drivers/base/node.c | 38 +++++++++++++++++--------------------- include/linux/node.h | 6 ++---- mm/memory_hotplug.c | 4 ++-- 3 files changed, 21 insertions(+), 27 deletions(-)drivers/base/node.c +0
-17@@ -676,23 +676,6 @@ static void node_device_release(struct device *dev)kfree (to_node (dev)); } -/** -* unregister_node - unregister a node device -* @node: node going away -* -* Unregisters a node device @node. All the devices on the node must be -* unregistered before calling this function. -*/ -void unregister_node (struct node *node) -{ -hugetlb_unregister_node (node); -compaction_unregister_node (node); -reclaim_unregister_node (node); -node_remove_accesses (node); -node_remove_caches (node); -device_unregister (&node->dev); -} -struct node *node_devices[MAX_NUMNODES ];/*
drivers/base/node.c int register_node(int nid) · line 914
Quoted 10 lines
drivers/base/node.c +5
-2@@ -924,13 +907,26 @@ int register_node(int nid)return error; } - -void unregister_one_node (int nid) +/** +* unregister_node - unregister a node device +* @nid: nid of the node going away +* +* Unregisters the node device at node id @nid. All the devices on the
Nit. Why two spaces before "@nid"?
[...]
Thanks,
SJ
Re: [PATCH v2 2/2] drivers/base/node: Fold unregister_node() into unregister_one_node()
Quoted 50 lines · SeongJae Park
Quoted 10 lines · On Tue, 14 Oct 2025 21:09:17 +0530 Donet Tom<[email protected]> wrote:
The function
unregister_node()is only called fromunregister_one_node(). This patch foldsunregister_node()into its only caller and renamesunregister_one_node()tounregister_node().This reduces unnecessary indirection and simplifies the code structure. No functional changes are introduced.
Acked-by David Hildenbrand<[email protected]>Signed-off-by Donet Tom<[email protected]>Acked-by SeongJae Park<[email protected]>Quoted 36 lines
--- drivers/base/node.c | 38 +++++++++++++++++--------------------- include/linux/node.h | 6 ++---- mm/memory_hotplug.c | 4 ++-- 3 files changed, 21 insertions(+), 27 deletions(-)drivers/base/node.c +0
-17@@ -676,23 +676,6 @@ static void node_device_release(struct device *dev)kfree (to_node (dev)); } -/** -* unregister_node - unregister a node device -* @node: node going away -* -* Unregisters a node device @node. All the devices on the node must be -* unregistered before calling this function. -*/ -void unregister_node (struct node *node) -{ -hugetlb_unregister_node (node); -compaction_unregister_node (node); -reclaim_unregister_node (node); -node_remove_accesses (node); -node_remove_caches (node); -device_unregister (&node->dev); -} -struct node *node_devices[MAX_NUMNODES ];/* @@ -924,13 +907,26 @@ int register_node(int nid)
Quoted 10 lines
drivers/base/node.c int register_node(int nid) · line 914
Quoted 9 lines
drivers/base/node.c +5
-2return error; } - -void unregister_one_node (int nid) +/** +* unregister_node - unregister a node device +* @nid: nid of the node going away +* +* Unregisters the node device at node id @nid. All the devices on the Nit. Why two spaces before "@nid"?
Thank you for pointing this out.
Andrew could you please help apply the below fixlet on top of this patch?
From 0d0345847ad33607c7ebae3798ef37ff16a20fd0 Mon Sep 17 00:00:00 2001
From: Donet Tom<[email protected]> Date: Fri, 17 Oct 2025 10:27:54 +0530
Subject: [PATCH] [fixlet] drivers/base/node: Remove extra space in description
This patch removes an extra space before @nid and "All".
drivers/base/node.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
drivers/base/node.c +0 -0
@@ -911,7 +911,7 @@ int register_node(int nid)
* unregister_node - unregister a node device
* @nid: nid of the node going away
*
- * Unregisters the node device at node id @nid. All the devices on the
+ * Unregisters the node device at node id @nid. All the devices on the
* node must be unregistered before calling this function. */
void unregister_node(int nid)
--
2.51.0
Quoted 6 lines
[...]
Thanks,
SJ
Re: [PATCH v2 1/2] drivers/base/node: Fold register_node() into register_one_node()
In reply to David HildenbrandQuoted 13 lines · David Hildenbrand
Quoted 10 lines · Donet Tom
The function
register_node()is only called fromregister_one_node(). This patch foldsregister_node()into its only caller and renamesregister_one_node()toregister_node().This reduces unnecessary indirection and simplifies the code structure. No functional changes are introduced.
Signed-off-by Donet Tom <[email protected]>---
[...]
Quoted 16 lines
drivers/base/node.c void · line 887
Quoted 12 lines
/**
*unregister_node- unregister a node device
* @node: node going awaydrivers/base/node.c +3
-0@@ -907,7 +880,13 @@ void register_memory_blocks_under_node_hotplug(int nid, unsigned long start_pfn, } #endif /* CONFIG_MEMORY_HOTPLUG */ -int register_one_node(int nid) +/** +* register_node - Initialize and register the node device. +* @nid - Node number to use when creating the device. I assume that should be "@nid: ..." to silence the warning.
Thank you, David, for pointing this out. Andrew has already applied the fix.