From: longli@linuxonhyperv.com
To: linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-hyperv@vger.kernel.org, paekkaladevi@microsoft.com
Cc: Long Li <longli@microsoft.com>
Subject: [PATCH] PCI: hv: Fix NUMA node assignment when kernel boots with parameters affecting NUMA topology
Date: Thu, 6 Jan 2022 15:20:28 -0800 [thread overview]
Message-ID: <1641511228-12415-1-git-send-email-longli@linuxonhyperv.com> (raw)
From: Long Li <longli@microsoft.com>
When the kernel boots with parameters restricting the number of cpus or NUMA
nodes, e.g. maxcpus=X or numa=off, the vPCI driver should only set to the NUMA
node to a value that is valid in the current running kernel.
Signed-off-by: Long Li <longli@microsoft.com>
---
drivers/pci/controller/pci-hyperv.c | 17 +++++++++++++++--
1 file changed, 15 insertions(+), 2 deletions(-)
diff --git a/drivers/pci/controller/pci-hyperv.c b/drivers/pci/controller/pci-hyperv.c
index fc1a29acadbb..8686343eff4c 100644
--- a/drivers/pci/controller/pci-hyperv.c
+++ b/drivers/pci/controller/pci-hyperv.c
@@ -1835,8 +1835,21 @@ static void hv_pci_assign_numa_node(struct hv_pcibus_device *hbus)
if (!hv_dev)
continue;
- if (hv_dev->desc.flags & HV_PCI_DEVICE_FLAG_NUMA_AFFINITY)
- set_dev_node(&dev->dev, hv_dev->desc.virtual_numa_node);
+ if (hv_dev->desc.flags & HV_PCI_DEVICE_FLAG_NUMA_AFFINITY) {
+ int cpu;
+ bool found_node = false;
+
+ for_each_possible_cpu(cpu)
+ if (cpu_to_node(cpu) ==
+ hv_dev->desc.virtual_numa_node) {
+ found_node = true;
+ break;
+ }
+
+ if (found_node)
+ set_dev_node(&dev->dev,
+ hv_dev->desc.virtual_numa_node);
+ }
put_pcichild(hv_dev);
}
--
2.25.1
next reply other threads:[~2022-01-06 23:21 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-01-06 23:20 longli [this message]
2022-01-07 15:34 ` [PATCH] PCI: hv: Fix NUMA node assignment when kernel boots with parameters affecting NUMA topology Michael Kelley (LINUX)
2022-01-07 20:31 ` Long Li
2022-01-10 16:12 ` Michael Kelley (LINUX)
2022-01-13 0:59 ` Long Li
2022-01-16 21:18 ` Michael Kelley (LINUX)
2022-01-18 22:44 ` Long Li
2022-01-18 22:59 ` Michael Kelley (LINUX)
2022-01-18 23:20 ` Long Li
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1641511228-12415-1-git-send-email-longli@linuxonhyperv.com \
--to=longli@linuxonhyperv.com \
--cc=linux-hyperv@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=longli@microsoft.com \
--cc=paekkaladevi@microsoft.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).