Skip to contentSkip to conversation

driver core: use NUMA_NO_NODE during device_initialize

PATCH In review Max Gurtovoy 3 participants 6 messages Oct 4, 2021 – Oct 11, 2021

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v3 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 v2:
- code conventions changes for patch 2/2 (Krzysztof)
- added Reviewed-by signatures for patch 2/2 (Stefan, Krzysztof)

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 15986cc2fe5e..a705b85656df 100644
@@ -2874,7 +2874,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 v3 2/2 PCI/sysfs: use NUMA_NO_NODE macro

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

---
 drivers/pci/pci-sysfs.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/pci/pci-sysfs.c +4 -2
index 7fb5cd17cc98..f807b92afa6c 100644
@@ -81,8 +81,10 @@ 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));
+	if (dev_to_node(dev) == NUMA_NO_NODE)
+		mask = cpu_online_mask;
+	else
+		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
#2 lore raw

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

Hi Max!

Quoted 29 lines

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

---
 drivers/pci/pci-sysfs.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/pci/pci-sysfs.c +4 -2
index 7fb5cd17cc98..f807b92afa6c 100644
@@ -81,8 +81,10 @@ 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));
+	if (dev_to_node(dev) == NUMA_NO_NODE)
+		mask = cpu_online_mask;
+	else
+		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

Thank you!

Krzysztof

#3 lore raw

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

In reply to Max Gurtovoy
Quoted 6 lines · Max Gurtovoy

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

These two patches are independent, so I applied this patch only to pci/sysfs for v5.16, thanks!

I assume Greg will take the drivers/base patch.

Quoted 24 lines
---
 drivers/pci/pci-sysfs.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/pci/pci-sysfs.c +4 -2
index 7fb5cd17cc98..f807b92afa6c 100644
@@ -81,8 +81,10 @@ 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));
+	if (dev_to_node(dev) == NUMA_NO_NODE)
+		mask = cpu_online_mask;
+	else
+		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
#4 lore raw

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

Quoted 11 lines · Bjorn Helgaas
Quoted 6 lines · Max Gurtovoy

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

These two patches are independent, so I applied this patch only to pci/sysfs for v5.16, thanks!

I assume Greg will take the drivers/base patch.

I saw both patches in his git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core.git driver-core-next

So I guess there is no need for taking it separately, right Greg ?

Quoted 24 lines
Quoted 24 lines
---
  drivers/pci/pci-sysfs.c | 6 ++++--
  1 file changed, 4 insertions(+), 2 deletions(-)
drivers/pci/pci-sysfs.c +4 -2
index 7fb5cd17cc98..f807b92afa6c 100644
@@ -81,8 +81,10 @@ 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));
+	if (dev_to_node(dev) == NUMA_NO_NODE)
+		mask = cpu_online_mask;
+	else
+		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
#5 lore raw

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

Quoted 12 lines · Max Gurtovoy
Quoted 10 lines · Bjorn Helgaas
Quoted 6 lines · Max Gurtovoy

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

These two patches are independent, so I applied this patch only to pci/sysfs for v5.16, thanks!

Quoted 7 lines
Quoted 1 line

I assume Greg will take the drivers/base patch.

I saw both patches in his
git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core.git
driver-core-next

So I guess there is no need for taking it separately, right Greg ?

No problem, I dropped the pci-sysfs.c patch. Thanks for letting me know!

Quoted 23 lines
Quoted 23 lines
Quoted 23 lines
---
  drivers/pci/pci-sysfs.c | 6 ++++--
  1 file changed, 4 insertions(+), 2 deletions(-)
drivers/pci/pci-sysfs.c +4 -2
index 7fb5cd17cc98..f807b92afa6c 100644
@@ -81,8 +81,10 @@ 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));
+	if (dev_to_node(dev) == NUMA_NO_NODE)
+		mask = cpu_online_mask;
+	else
+		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