Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp929349pxb; Fri, 21 Jan 2022 06:30:18 -0800 (PST) X-Google-Smtp-Source: ABdhPJyMsYI/9955xB8RqEnltO2KLV4xBiVg1X7GDeq8g1AK1TMAhPvBPre8Q+3aJFf/UvuJDce2 X-Received: by 2002:a63:7148:: with SMTP id b8mr3174949pgn.616.1642775418626; Fri, 21 Jan 2022 06:30:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1642775418; cv=none; d=google.com; s=arc-20160816; b=Thw7aLi9F2SkYoN8JiUtvQtwXhwHOrbd7ojMtyfrc0hsnX423dxLknv/ZcTtZDw0Eq 0F2dKkOalu3bbgsMVj0eeAaOh+ocKjfWMWNH84aGMovFF0veBNMiavmzjyKwsLTxF10U WcPl05Q2TyKi+BlHzCl32ERS7Q7qulq7JqKUcD+oveqq8vKmig03Dyn1RMyH/Q4ojoVm PVnw4sgv5cPgOQ8czjhOxOLGuJj9fz7Wl2iEKOEmeQoAKpMr/51uvwG4bm+S6LY11rk+ Wfx6rtvHsm0hHG5X9AfL0VTn6AqvuqdXB75O5tM479rwt16Eug4CPjC6fr5NREIjuZP2 tGBQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:subject:cc:to:from :dkim-signature:dkim-filter; bh=wjkIeI5Gu3gvLdHM1LQSKa2r2Zn13qiiFCxWtUIlO6g=; b=0dWP6wWqfe1lVwNrgVMCO3jxBztdnK3bPLa3ILOjbgsO5k5GGABhbOeLXHurRGcREH uRDs0w5JvBYblF0TIqHU0go/zS9iVO+dYCN1rGRlccjv+q8eUKetd7pCXMAP8Uh4MuHn HA4T6g8mCjWNnJK8zynFVrmp1EKQi23MaMleeQHteDasu3CS+cs8BuJTwrJ8rYNXNmso 6u3ik7IR5QF5iXoeEp3sdBaFqzpuDATAlTVh0e1VWMJ4Im/XAR2Q5Xg+tbAbEYdsyFcd 9egMsz0rFTYqaXpLvVVoNCjpZrMsrMcwg19P+T859S/0Ygq9dL1dkRN+u9Wy34ykUDWI Jg+g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxonhyperv.com header.s=default header.b=Zx4DOsdq; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxonhyperv.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id z8si6171096pfh.245.2022.01.21.06.30.06; Fri, 21 Jan 2022 06:30:18 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxonhyperv.com header.s=default header.b=Zx4DOsdq; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxonhyperv.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1351062AbiASCpq (ORCPT + 99 others); Tue, 18 Jan 2022 21:45:46 -0500 Received: from linux.microsoft.com ([13.77.154.182]:57306 "EHLO linux.microsoft.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344162AbiASCpm (ORCPT ); Tue, 18 Jan 2022 21:45:42 -0500 Received: by linux.microsoft.com (Postfix, from userid 1004) id 0974220B9270; Tue, 18 Jan 2022 18:45:42 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 0974220B9270 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxonhyperv.com; s=default; t=1642560342; bh=wjkIeI5Gu3gvLdHM1LQSKa2r2Zn13qiiFCxWtUIlO6g=; h=From:To:Cc:Subject:Date:From; b=Zx4DOsdq+SgaWZp1+46YZiMi5Xk67C+0pfjN0RYoxl5g1wu7rEnxvRqH0NuwXFWwp igW/bDWZAGKodrUHBUMvV+7Fg56H7AWiDBbm9tTzQoRJmIvHV6TXx0WrlSPFHEuY5b nqOw76QUGMogzolUXmzaNZunj5hVBfL+EZMsT3zc= 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 Subject: [Patch v2] PCI: hv: Fix NUMA node assignment when kernel boots with custom NUMA topology Date: Tue, 18 Jan 2022 18:45:29 -0800 Message-Id: <1642560329-5012-1-git-send-email-longli@linuxonhyperv.com> X-Mailer: git-send-email 1.8.3.1 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Long Li When kernel boots with a NUMA topology with some NUMA nodes offline, the PCI driver should only set an online NUMA node on the device. This can happen during KDUMP where some NUMA nodes are not made online by the KDUMP kernel. This patch also fixes the case where kernel is booting with "numa=off". Signed-off-by: Long Li Change from v1: Use numa_map_to_online_node() to assign a node to device (suggested by Michael Kelly ) --- drivers/pci/controller/pci-hyperv.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/drivers/pci/controller/pci-hyperv.c b/drivers/pci/controller/pci-hyperv.c index 6c9efeefae1b..c7519add6f13 100644 --- a/drivers/pci/controller/pci-hyperv.c +++ b/drivers/pci/controller/pci-hyperv.c @@ -2130,7 +2130,15 @@ static void hv_pci_assign_numa_node(struct hv_pcibus_device *hbus) continue; if (hv_dev->desc.flags & HV_PCI_DEVICE_FLAG_NUMA_AFFINITY) - set_dev_node(&dev->dev, hv_dev->desc.virtual_numa_node); + /* + * The kernel may boot with some NUMA nodes offline + * (e.g. in a KDUMP kernel) or with NUMA disabled via + * "numa=off". In those cases, adjust the host provided + * NUMA node to a valid NUMA node used by the kernel. + */ + set_dev_node(&dev->dev, + numa_map_to_online_node( + hv_dev->desc.virtual_numa_node)); put_pcichild(hv_dev); } -- 2.25.1