Received: by 10.213.65.68 with SMTP id h4csp139024imn; Thu, 15 Mar 2018 20:34:43 -0700 (PDT) X-Google-Smtp-Source: AG47ELsiIFTGDRorUSO1ZhvqTj62ZAhfc+X8NRW8WXEdx4qW6GwkIDxCQ1G3u/Ykv9vcfKnndvF/ X-Received: by 2002:a17:902:71cf:: with SMTP id t15-v6mr355637plm.107.1521171283604; Thu, 15 Mar 2018 20:34:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521171283; cv=none; d=google.com; s=arc-20160816; b=pbF92En1c6hV1SUT5nW0pRTipZeQacCR3c3dN4FQ64YZ3viz0JjzWAT/93PYjcNsVX IW8planixRo3vMjOHHZzM55d2Jjz06/77aj0TCYIwFBp8cwtF26TwCkzGXsnXuixt6ga byPU80nLaB917s2+BaQHLcH6qvbOw3ggxxXQJjkRxu6/gw19XAGVZl+kW/Gvjnbd2Hdq LVaXsZP44TWHIkpH+5WR9+l71yLPll0FKhQJJldDX11ICn4jRxgWn+OPGZi6FsR3p/p5 fwbI74fNc5qV9dRipKJZ/w1Kc8/q28dmzj/c+EsmVqkWfGNc8LhnrV/QtSczOQgaB4Ad 0O2Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:message-id:date:cc:to:from:subject :arc-authentication-results; bh=mzhsQQ93tNEPyA3NiBRvviDTztXpAa+dTHHYwGGzOLQ=; b=gSyvOyE7Nw9Z/XKPJ6Ezye8Etlcrz1umK4pIkc9YC7CrONeDzFNxC4AmoN9XoDOzNn msEYij/nKXplt3yZJkg6MtN6tZLiOtZfKNzklhLfAiFoUSC0bcZh7MsAE3vYpd8psnlV 9Cv2RMUcHSG1WEAZ/9238sMOeilTLwzSexbpx5Cj5LZgmpo9k9OQdsu6WOWZAzZxbyFZ wFIm/+EvPo+Rp8ifyaItkrdFfBZBGT9OJxYEjnwbrQS3VQU9NBWG+dos9oCrbdVMkzru k4sqRhpHVXVChwIo+utHJXfn3imFbLV1IXP/q33pc/Lxv0WzojAZ+mZU6LSA0v6BcjGv 0LmA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g11si4323724pgq.320.2018.03.15.20.34.29; Thu, 15 Mar 2018 20:34:43 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932912AbeCPDRo (ORCPT + 99 others); Thu, 15 Mar 2018 23:17:44 -0400 Received: from mga14.intel.com ([192.55.52.115]:2730 "EHLO mga14.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751966AbeCPDRn (ORCPT ); Thu, 15 Mar 2018 23:17:43 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 15 Mar 2018 20:17:42 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.48,313,1517904000"; d="scan'208";a="39383405" Received: from dwillia2-desk3.jf.intel.com (HELO dwillia2-desk3.amr.corp.intel.com) ([10.54.39.16]) by orsmga001.jf.intel.com with ESMTP; 15 Mar 2018 20:17:42 -0700 Subject: [PATCH] acpi, numa: fix pxm to online numa node associations From: Dan Williams To: linux-nvdimm@lists.01.org Cc: stable@vger.kernel.org, Toshi Kani , "Rafael J. Wysocki" , linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org Date: Thu, 15 Mar 2018 20:08:37 -0700 Message-ID: <152116964416.8343.514895686858363582.stgit@dwillia2-desk3.amr.corp.intel.com> User-Agent: StGit/0.18-2-gc94f MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit 99759869faf1 "acpi: Add acpi_map_pxm_to_online_node()" added support for mapping a given proximity to its nearest, by SLIT distance, online node. However, it sometimes returns unexpected results due to the fact that it switches from comparing the PXM node to the last node that was closer than the current max. for_each_online_node(n) { dist = node_distance(node, n); if (dist < min_dist) { min_dist = dist; node = n; <---- from this point we're using the wrong node for node_distance() Fixes: 99759869faf1 ("acpi: Add acpi_map_pxm_to_online_node()") Cc: Cc: Toshi Kani Cc: Rafael J. Wysocki > Signed-off-by: Dan Williams --- Rafael, I can take this through the nvdimm tree with your ack. I have a few other nvdimm fixes pending for 4.16. drivers/acpi/numa.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/drivers/acpi/numa.c b/drivers/acpi/numa.c index 8ccaae3550d2..85167603b9c9 100644 --- a/drivers/acpi/numa.c +++ b/drivers/acpi/numa.c @@ -103,25 +103,27 @@ int acpi_map_pxm_to_node(int pxm) */ int acpi_map_pxm_to_online_node(int pxm) { - int node, n, dist, min_dist; + int node, min_node; node = acpi_map_pxm_to_node(pxm); if (node == NUMA_NO_NODE) node = 0; + min_node = node; if (!node_online(node)) { - min_dist = INT_MAX; + int min_dist = INT_MAX, dist, n; + for_each_online_node(n) { dist = node_distance(node, n); if (dist < min_dist) { min_dist = dist; - node = n; + min_node = n; } } } - return node; + return min_node; } EXPORT_SYMBOL(acpi_map_pxm_to_online_node);