x86/PCI: Use the only online node for root buses with no _PXM
RFC PATCH 1/1 x86/PCI: Use the only online node for root buses with no _PXM
When a host bridge has no _PXM and the Northbridge fallback finds nothing either, pci_acpi_root_get_node() leaves every root bus at NUMA_NO_NODE. With exactly one node online that isn't really unknown, there's only one possible answer.
Seen on an ASRock B760M-ITX/D4 (i9-14900KF). nvidia-fs calls pcibus_to_node() directly and warns "error retrieving numa node" four times per boot, once for the GPU and once per NVMe. Rewriting the per-device numa_node attribute from udev doesn't help, since pcibus_to_node() reads the bus value set at enumeration.
Fall back to first_online_node when num_online_nodes() == 1. Systems with more than one node are unaffected.
With this applied the warnings are gone over four boots. I didn't observe pcibus_to_node() itself at the call site, there's no sysfs file for it.
---
Only user I've got is the out-of-tree nvidia-fs, hence the RFC. The single-node condition is the same reasoning as Bjorn's 2019 "PCI: Warn about host bridge device when its numa node is NO_NODE" change. Fine to drop this if callers are expected to cope with NUMA_NO_NODE.
arch/x86/pci/acpi.c | 7 +++++++ 1 file changed, 7 insertions(+)
arch/x86/pci/acpi.c +7 -0
@@ -463,6 +463,13 @@ static int pci_acpi_root_get_node(struct acpi_pci_root *root)if (node !=NUMA_NO_NODE && !node_online (node)) node =NUMA_NO_NODE ; +/* +* One online node means there's only one possible answer, so don't +* leave the bus at NUMA_NO_NODE just because firmware didn't say. +*/ +if (node ==NUMA_NO_NODE &&num_online_nodes () ==1 ) + node = first_online_node; +return node; }
[email protected]
AI reviewThank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider: - [Medium] x86/pci: num_online_nodes() check breaks NUMA locality for offline nodes - [Low] x86/pci: faking…
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [Medium] x86/pci: num_online_nodes() check breaks NUMA locality for offline nodes
- [Low] x86/pci: faking NUMA locality to suppress out-of-tree module warnings --
commit 8ab24ac3406319565e845067f7c37f528237c0fa
Author: Ferran <[email protected]>
x86/PCI: Use the only online node for root buses with no _PXM
When a host bridge has no _PXM and the Northbridge fallback finds nothing either, pci_acpi_root_get_node() leaves every root bus at NUMA_NO_NODE. This patch forces the node to first_online_node when there is exactly one node online.
Quoted 5 lines
arch/x86/pci/acpi.c +0
-0
arch/x86/pci/acpi.c static int pci_acpi_root_get_node(struct acpi_pci_root *root) · line 471
Quoted 9 lines
arch/x86/pci/acpi.c +6
-0@@ -463,6 +463,13 @@ static int pci_acpi_root_get_node(struct acpi_pci_root *root)if (node !=NUMA_NO_NODE && !node_online (node)) node =NUMA_NO_NODE ; +/* +* One online node means there's only one possible answer, so don't +* leave the bus at NUMA_NO_NODE just because firmware didn't say. +*/ +if (node ==NUMA_NO_NODE &&num_online_nodes () ==1 ) + node = first_online_node;
[Severity: Medium]
Could this num_online_nodes() check incorrectly bind a root bus on an offline node to the first online node?
During system boot or PCI enumeration on multi-node setups where a subset of nodes are temporarily offline, num_online_nodes() could evaluate to 1. This overrides the NUMA_NO_NODE state with first_online_node.
When the offline node is brought online, would this permanent binding cause cross-node memory allocations and latency?
Would checking num_possible_nodes() == 1 or nr_node_ids == 1 be safer here to avoid corrupting topology on hotplug systems?
[Severity: Low]
Is it appropriate to advertise node 0 instead of NUMA_NO_NODE for root buses lacking _PXM?
The commit message states this change is to accommodate the out-of-tree nvidia-fs driver. NUMA_NO_NODE (-1) is the architecturally correct state when hardware/ACPI lacks proximity data, and core subsystems handle it gracefully.
Should hardware topology be faked in the core kernel to work around an out-of-tree driver?
Quoted 3 lines
arch/x86/pci/acpi.c +1
-0+return node; }
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1