Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp3718438imm; Mon, 8 Oct 2018 08:27:23 -0700 (PDT) X-Google-Smtp-Source: ACcGV620+yr1/UvHsOGiL5IDcMcs519kaPJ4CnVtQ9dlFXF5hhZmlVf8DTVh4NmgWWZlpSxPRZdg X-Received: by 2002:a17:902:bcc3:: with SMTP id o3-v6mr25047877pls.202.1539012443461; Mon, 08 Oct 2018 08:27:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539012443; cv=none; d=google.com; s=arc-20160816; b=HYILa0GGrDwlfP1Aq8Xi+S0TAEVuhSPu75cWjOKhugi/PWerwmF8AT8BNuRtWI4zzc dwlhw1XtKU8sD6uRKZ3QUQWAJnsD1arAAS2W0KHFSyVjjOn8k9qQ+FgZODy+bV948bJO fhhDTJ91M0GwSaV+eMq+I0HdT+mdA42XX3P6WoOEEwFsmiYXyqMcYBeX+3ZrpwBvzvap BXrvY6I5QqRCfemhlFIQ236pgJWLfHJiosZgxsRORgm6giXw5bIs6NWt4zTFhDDJxmgC fig0ovRvLEjyAASyLXNHa1P3gIjfssfVrjRbbg0WZpTCjRPsyK7oCzBOKsT1YrPGeZ1j 6k+A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=kBz0PQyXh+wQxBcbyYNZSZ2urZZNqJCH1TVJyQiDHjA=; b=xYo+RapPobZ0HBwyaUXM8fJpRG7GQ6Zg3+PoDIQ3UvDETJwhNNv+i7wj5U5cpgWsqJ GZkS3Ur8iVanXe61/fz5h2HY/AuK+mnrRmIXYQUghoeMLSfJraQwviVw/dvyCVLGuq2J GHyfRQJuwLeuupb8M16zKv5/V1mK7hEVl27ENO9bu02JzfFUHJYo+gqP/JfVXK+J8Lle l+p3GW1Ack0nIUl7i9yvWjeQzwL274DwdxtACl4m4s8okI/MqqLuGOEW4dd1sZ9aFOvO 8gy/JIVeGrcDjty0tFZvvjisTo8HysKJpfo5DW9uEoadm0nkZ0pxFyOPjTEra2ab9Uhg BPCA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=rjiFsfdj; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j7-v6si18392043pfc.0.2018.10.08.08.27.08; Mon, 08 Oct 2018 08:27:23 -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; dkim=pass header.i=@kernel.org header.s=default header.b=rjiFsfdj; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728153AbeJHWie (ORCPT + 99 others); Mon, 8 Oct 2018 18:38:34 -0400 Received: from mail.kernel.org ([198.145.29.99]:57232 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728114AbeJHWie (ORCPT ); Mon, 8 Oct 2018 18:38:34 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 93C252150F; Mon, 8 Oct 2018 15:26:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1539012379; bh=dErdjsP5SAPENzAiG8aXAmFnGAM3UHEYzdW6dYxW1xU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rjiFsfdjLcYT7+FKLZsv2iFNTqDdY5++rFZxoTOntGk3EhyXua0PY6DOQIJdxs8Ri 8+Uw/fq6DzgMK4WxfXQILzGZY2rXfsR64YNAX82+BCnleF9+STfRBlIwm/Jb2Tv7bX Emow3kjJ/QPpMgH8y8FaI44s16R6FQk9xu2WHO3M= From: Sasha Levin To: stable@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Srikar Dronamraju , Michael Ellerman , Sasha Levin Subject: [PATCH AUTOSEL 4.18 56/58] powerpc/numa: Use associativity if VPHN hcall is successful Date: Mon, 8 Oct 2018 11:25:21 -0400 Message-Id: <20181008152523.70705-56-sashal@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181008152523.70705-1-sashal@kernel.org> References: <20181008152523.70705-1-sashal@kernel.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Srikar Dronamraju [ Upstream commit 2483ef056f6e42f61cd266452e2841165dfe1b5c ] Currently associativity is used to lookup node-id even if the preceding VPHN hcall failed. However this can cause CPU to be made part of the wrong node, (most likely to be node 0). This is because VPHN is not enabled on KVM guests. With 2ea6263 ("powerpc/topology: Get topology for shared processors at boot"), associativity is used to set to the wrong node. Hence KVM guest topology is broken. For example : A 4 node KVM guest before would have reported. [root@localhost ~]# numactl -H available: 4 nodes (0-3) node 0 cpus: 0 1 2 3 node 0 size: 1746 MB node 0 free: 1604 MB node 1 cpus: 4 5 6 7 node 1 size: 2044 MB node 1 free: 1765 MB node 2 cpus: 8 9 10 11 node 2 size: 2044 MB node 2 free: 1837 MB node 3 cpus: 12 13 14 15 node 3 size: 2044 MB node 3 free: 1903 MB node distances: node 0 1 2 3 0: 10 40 40 40 1: 40 10 40 40 2: 40 40 10 40 3: 40 40 40 10 Would now report: [root@localhost ~]# numactl -H available: 4 nodes (0-3) node 0 cpus: 0 2 3 4 5 6 7 8 9 10 11 12 13 14 15 node 0 size: 1746 MB node 0 free: 1244 MB node 1 cpus: node 1 size: 2044 MB node 1 free: 2032 MB node 2 cpus: 1 node 2 size: 2044 MB node 2 free: 2028 MB node 3 cpus: node 3 size: 2044 MB node 3 free: 2032 MB node distances: node 0 1 2 3 0: 10 40 40 40 1: 40 10 40 40 2: 40 40 10 40 3: 40 40 40 10 Fix this by skipping associativity lookup if the VPHN hcall failed. Fixes: 2ea626306810 ("powerpc/topology: Get topology for shared processors at boot") Signed-off-by: Srikar Dronamraju Signed-off-by: Michael Ellerman Signed-off-by: Sasha Levin --- arch/powerpc/mm/numa.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/arch/powerpc/mm/numa.c b/arch/powerpc/mm/numa.c index b5a71baedbc2..59d07bd5374a 100644 --- a/arch/powerpc/mm/numa.c +++ b/arch/powerpc/mm/numa.c @@ -1204,7 +1204,9 @@ int find_and_online_cpu_nid(int cpu) int new_nid; /* Use associativity from first thread for all siblings */ - vphn_get_associativity(cpu, associativity); + if (vphn_get_associativity(cpu, associativity)) + return cpu_to_node(cpu); + new_nid = associativity_to_nid(associativity); if (new_nid < 0 || !node_possible(new_nid)) new_nid = first_online_node; -- 2.17.1