From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 832104C6EE1; Mon, 20 Apr 2026 13:33:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776691987; cv=none; b=MxiKWyT6RySz8vAx6j5zca+Mxn6FTBNuVahGIL/+PygJkZglkmhE60kcTyaZt7itk0Wjtzoo0eiUOlX9JdZQOhaJXH9J+/8880ZyXaMQcr6HqVZc9OKstxUCPHFVZvMjywsGvOYMM2UewHAXsNZwkWiRMfWtbMsLnUP6h1KedQc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776691987; c=relaxed/simple; bh=pK12f6q5oeb+RebTQ+UHcQfgWWgF9bfbHEcqRvl8bL4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=IIZZGbt1o6NlWzCC3AMWcfOk0hbb+TTWfsC3UQKxqbA0hxXlV1TVr25f0dQP3jaOzxc82AX3wgR5m+lV2W/AkKMkhSsPQI7OosFXmUoAhMMxZAKyuat+6FN06eQne5GHqFja/Q20kWthfwPGo6edRR4O9R0mXfnBbkAUl9bfJ6Y= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=KPJf+gBq; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="KPJf+gBq" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 90931C2BCB8; Mon, 20 Apr 2026 13:33:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1776691987; bh=pK12f6q5oeb+RebTQ+UHcQfgWWgF9bfbHEcqRvl8bL4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KPJf+gBqzWqktm8TS0Ra7e9O/L+fsjkATwdkMnNLoW6lAUYYOk5b4UNZrCwt3iyL2 h7jAyU6o+qgZ+zUamW8/fTCPhUAZh0lFy4gFAtNE7TohzWEH2SZvxpWOp2ckUdTp8l wE7Kf2m07sryHwhX/+s0VakeHCOdIeArEjQ771b/t/T11Ue8ul/TpqTlMBibmQ/5ff 0BH9W++aqczpnCUbgUgoGAAn4solYHijjk3avIewaf5WQscPbhS8Dpwn+4mSMlbs53 WPqwLDIIA4BpTPtPuvlP82YWobW3NFqswxTj4aaNHzRt9cnHItxCJxE6YKJi26NWmg XYzW/bRHE3eVQ== From: Sasha Levin To: patches@lists.linux.dev, stable@vger.kernel.org Cc: Long Li , Michael Kelley , Wei Liu , Sasha Levin , kys@microsoft.com, haiyangz@microsoft.com, decui@microsoft.com, lpieralisi@kernel.org, kwilczynski@kernel.org, mani@kernel.org, bhelgaas@google.com, mikelley@microsoft.com, linux-hyperv@vger.kernel.org, linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH AUTOSEL 6.18] PCI: hv: Set default NUMA node to 0 for devices without affinity info Date: Mon, 20 Apr 2026 09:21:41 -0400 Message-ID: <20260420132314.1023554-307-sashal@kernel.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260420132314.1023554-1-sashal@kernel.org> References: <20260420132314.1023554-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore X-stable-base: Linux 6.18.23 Content-Transfer-Encoding: 8bit From: Long Li [ Upstream commit 7b3b1e5a87b2f5e35c52b5386d7c327be869454f ] When hv_pci_assign_numa_node() processes a device that does not have HV_PCI_DEVICE_FLAG_NUMA_AFFINITY set or has an out-of-range virtual_numa_node, the device NUMA node is left unset. On x86_64, the uninitialized default happens to be 0, but on ARM64 it is NUMA_NO_NODE (-1). Tests show that when no NUMA information is available from the Hyper-V host, devices perform best when assigned to node 0. With NUMA_NO_NODE the kernel may spread work across NUMA nodes, which degrades performance on Hyper-V, particularly for high-throughput devices like MANA. Always set the device NUMA node to 0 before the conditional NUMA affinity check, so that devices get a performant default when the host provides no NUMA information, and behavior is consistent on both x86_64 and ARM64. Fixes: 999dd956d838 ("PCI: hv: Add support for protocol 1.3 and support PCI_BUS_RELATIONS2") Signed-off-by: Long Li Reviewed-by: Michael Kelley Signed-off-by: Wei Liu Signed-off-by: Sasha Levin --- LLM Generated explanations, may be completely bogus: Error: Failed to generate final synthesis drivers/pci/controller/pci-hyperv.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/pci/controller/pci-hyperv.c b/drivers/pci/controller/pci-hyperv.c index 146b43981b278..28b1572974879 100644 --- a/drivers/pci/controller/pci-hyperv.c +++ b/drivers/pci/controller/pci-hyperv.c @@ -2486,6 +2486,14 @@ static void hv_pci_assign_numa_node(struct hv_pcibus_device *hbus) if (!hv_dev) continue; + /* + * If the Hyper-V host doesn't provide a NUMA node for the + * device, default to node 0. With NUMA_NO_NODE the kernel + * may spread work across NUMA nodes, which degrades + * performance on Hyper-V. + */ + set_dev_node(&dev->dev, 0); + if (hv_dev->desc.flags & HV_PCI_DEVICE_FLAG_NUMA_AFFINITY && hv_dev->desc.virtual_numa_node < num_possible_nodes()) /* -- 2.53.0