Skip to contentSkip to conversation

driver core: use NUMA_NO_NODE during device_initialize

PATCH Superseded Max Gurtovoy 3 participants 5 messages Oct 3, 2021 – Oct 4, 2021

Subsystems (2)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/2 driver core: use NUMA_NO_NODE during device_initialize

Don't use (-1) constant for setting initial device node. Instead, use the generic NUMA_NO_NODE definition to indicate that "no node id specified".

---

changes from v1:
- added patch 2/2 (Krzysztof)
- added Reviewed-by signature (Stefan)

---
 drivers/base/core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/base/core.c +1 -1
index e65dd803a453..2b4b46f6c676 100644
@@ -2838,7 +2838,7 @@ void device_initialize(struct device *dev)
 	spin_lock_init(&dev->devres_lock);
 	INIT_LIST_HEAD(&dev->devres_head);
 	device_pm_init(dev);
-	set_dev_node(dev, -1);
+	set_dev_node(dev, NUMA_NO_NODE);
 #ifdef CONFIG_GENERIC_MSI_IRQ
 	raw_spin_lock_init(&dev->msi_lock);
 	INIT_LIST_HEAD(&dev->msi_list);
Signature · 1 line
2.18.1
#1 lore raw

PATCH v2 2/2 PCI/sysfs: use NUMA_NO_NODE macro

Use the proper macro instead of hard-coded (-1) value.

---
 drivers/pci/pci-sysfs.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/pci/pci-sysfs.c +2 -2
index 7fb5cd17cc98..b21065222c87 100644
@@ -81,8 +81,8 @@ static ssize_t pci_dev_show_local_cpu(struct device *dev, bool list,
 	const struct cpumask *mask;
 
 #ifdef CONFIG_NUMA
-	mask = (dev_to_node(dev) == -1) ? cpu_online_mask :
-					  cpumask_of_node(dev_to_node(dev));
+	mask = (dev_to_node(dev) == NUMA_NO_NODE) ? cpu_online_mask :
+				cpumask_of_node(dev_to_node(dev));
 #else
 	mask = cpumask_of_pcibus(to_pci_dev(dev)->bus);
 #endif
Signature · 1 line
2.18.1
Reviewed-by on v2 2/2
#2 lore raw

Re: [PATCH v2 2/2] PCI/sysfs: use NUMA_NO_NODE macro

[+cc Bjorn as he has strong code formatting preference in the PCI tree]

Hi Max,

Quoted 4 lines

Use the proper macro instead of hard-coded (-1) value.

Thank you for taking care of this! Much appreciated!

Quoted 9 lines
---
 drivers/pci/pci-sysfs.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/pci/pci-sysfs.c +0 -0
index 7fb5cd17cc98..b21065222c87 100644

drivers/pci/pci-sysfs.c static ssize_t pci_dev_show_local_cpu(struct device *dev, bool list, · line 85

Quoted 7 lines
drivers/pci/pci-sysfs.c +2 -2
@@ -81,8 +81,8 @@ static ssize_t pci_dev_show_local_cpu(struct device *dev, bool list,
 	const struct cpumask *mask;
 
 #ifdef CONFIG_NUMA
-	mask = (dev_to_node(dev) == -1) ? cpu_online_mask :
-					  cpumask_of_node(dev_to_node(dev));
+	mask = (dev_to_node(dev) == NUMA_NO_NODE) ? cpu_online_mask :
+				cpumask_of_node(dev_to_node(dev));

Oh this somewhat awkward indentation we have with this ternary now, and so I wonder if either:

	mask = (dev_to_node(dev) == NUMA_NO_NODE) ?
		cpu_online_mask : cpumask_of_node(dev_to_node(dev));

Or, perhaps (yes, a few more lines):

	if (dev_to_node(dev) == NUMA_NO_NODE)
		mask = cpu_online_mask;
	else
		mask = cpumask_of_node(node);

Would be easier on the eyes, so to speak. What do you think (not a problem if you don't want to change anything, thoguh)?

Thank you!

Krzysztof

#3 lore raw

Re: [PATCH v2 2/2] PCI/sysfs: use NUMA_NO_NODE macro

Hi Max,

[...]

Quoted 12 lines

drivers/pci/pci-sysfs.c static ssize_t pci_dev_show_local_cpu(struct device *dev, bool list, · line 85

Quoted 5 lines

#ifdef CONFIG_NUMA

drivers/pci/pci-sysfs.c +2 -2
-	mask = (dev_to_node(dev) == -1) ? cpu_online_mask :
-					  cpumask_of_node(dev_to_node(dev));
+	mask = (dev_to_node(dev) == NUMA_NO_NODE) ? cpu_online_mask :
+				cpumask_of_node(dev_to_node(dev));

Oh this somewhat awkward indentation we have with this ternary now, and so I wonder if either:

	mask = (dev_to_node(dev) == NUMA_NO_NODE) ?
		cpu_online_mask : cpumask_of_node(dev_to_node(dev));
Quoted 6 lines

Or, perhaps (yes, a few more lines):

	if (dev_to_node(dev) == NUMA_NO_NODE)
		mask = cpu_online_mask;
	else
		mask = cpumask_of_node(node);

Doh! I should be cpumask_of_node(dev_to_node(dev)) in the above, of course. Apologies! Albeit, v3 you sent looks great! Thank you!

Krzysztof