Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp2478641imm; Mon, 28 May 2018 08:51:54 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqcDXes/Ai0lk6iFe8vA3Pefv581Q5uuFevIC46ypWmPE20mIVTK6jh+7UN+Dz6OMFGcIIk X-Received: by 2002:a17:902:5ac1:: with SMTP id g1-v6mr14157642plm.43.1527522714203; Mon, 28 May 2018 08:51:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527522714; cv=none; d=google.com; s=arc-20160816; b=EKY1IendgrXyLZd9hv4HMi5R1okT9xVm1hfjwkEeDHCfzZnPwdd3AmteJXfo/awvCI RKlhQ6GXKbHa7a1Eqi0STT8rOH19eSwIglriDPTLHACGyllY+2Qnr+coYvjp1TlQvhN7 Im0UiO5By0mhZ5S8CTAk93nWby425ePiVNQs9cobH+OG4049zIaZEiyNb9KGRwEgJg5S PZoVsV10YPlMqVnK0YvqObb/sXLMF0real/8d4Vc0Yua6u9ihSk4SPQL4HHjb6gQQQdG y85gojMPG7x05peV9wBBgh+zhCZUlO1o3LltY5KnrWlt2/w+0hlKfCc+mgrWCYuE4AHa 54mQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=VafzgF+ZwzMYF7H2lJLuIR+5afKzhAK3XljutLpnZa0=; b=yWbf6+2EyPh9ZA8tmyA284EaIDYR2Kc1Y9lun9otmLUg6UhhSD2jT6qCK29RxFl6nb 9066GUu59YAor2syCtJFwBbVVj88YX3RTd8EGtdJYpt5PD++wGTO94/YF8pBmWu0wMw+ YGEUzJytbpdlxdt/wkSjtFN0B8KrOZcaCXyaEF6C/d9MKq5eelkdfw9RrlGxsFEjigfL AUo2XrO1ZB25uku+PUB5jcf6ja4158E1Mb41NoGb5MBnCJT8rdzwPF/nT32t1bm9xTY7 j07M1GTv1I3eH6QSam80v7Yu2UJEzQg0MQaFUmRkvhyMZ0fxkzF4WKiM6xW2Vz/ONEm8 3kGQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=wbJTdgj/; 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 e18-v6si15367338pgv.160.2018.05.28.08.51.39; Mon, 28 May 2018 08:51:54 -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=wbJTdgj/; 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 S1035012AbeE1PvG (ORCPT + 99 others); Mon, 28 May 2018 11:51:06 -0400 Received: from mail.kernel.org ([198.145.29.99]:36308 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965345AbeE1KQK (ORCPT ); Mon, 28 May 2018 06:16:10 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 2A3862089E; Mon, 28 May 2018 10:16:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1527502569; bh=/mF+uTF5Sc/dQtiK7ycg9CIkZJH34Ujlw2P7zbtjVec=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=wbJTdgj/lJdojACxGJK4lWTk0zhpAGTDjGmNOFRGeJd2lUGSNYGfUeNtVMC7efY11 51y6X0hUqblG9PAERhH9TWiHHPxEj5/qIXPqF3VYf+90WxItBUeqbUUb4bwhWS3Xkv ZUW3xnZXwpaQQGrbeBjSkTp0mIir5fyGbw0mPHlI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Michael Bringmann , Nathan Fontenot , Michael Ellerman , Sasha Levin Subject: [PATCH 4.4 042/268] powerpc/numa: Use ibm,max-associativity-domains to discover possible nodes Date: Mon, 28 May 2018 12:00:16 +0200 Message-Id: <20180528100206.791672570@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180528100202.045206534@linuxfoundation.org> References: <20180528100202.045206534@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.4-stable review patch. If anyone has any objections, please let me know. ------------------ From: Michael Bringmann [ Upstream commit a346137e9142b039fd13af2e59696e3d40c487ef ] On powerpc systems which allow 'hot-add' of CPU or memory resources, it may occur that the new resources are to be inserted into nodes that were not used for these resources at bootup. In the kernel, any node that is used must be defined and initialized. These empty nodes may occur when, * Dedicated vs. shared resources. Shared resources require information such as the VPHN hcall for CPU assignment to nodes. Associativity decisions made based on dedicated resource rules, such as associativity properties in the device tree, may vary from decisions made using the values returned by the VPHN hcall. * memoryless nodes at boot. Nodes need to be defined as 'possible' at boot for operation with other code modules. Previously, the powerpc code would limit the set of possible nodes to those which have memory assigned at boot, and were thus online. Subsequent add/remove of CPUs or memory would only work with this subset of possible nodes. * memoryless nodes with CPUs at boot. Due to the previous restriction on nodes, nodes that had CPUs but no memory were being collapsed into other nodes that did have memory at boot. In practice this meant that the node assignment presented by the runtime kernel differed from the affinity and associativity attributes presented by the device tree or VPHN hcalls. Nodes that might be known to the pHyp were not 'possible' in the runtime kernel because they did not have memory at boot. This patch ensures that sufficient nodes are defined to support configuration requirements after boot, as well as at boot. This patch set fixes a couple of problems. * Nodes known to powerpc to be memoryless at boot, but to have CPUs in them are allowed to be 'possible' and 'online'. Memory allocations for those nodes are taken from another node that does have memory until and if memory is hot-added to the node. * Nodes which have no resources assigned at boot, but which may still be referenced subsequently by affinity or associativity attributes, are kept in the list of 'possible' nodes for powerpc. Hot-add of memory or CPUs to the system can reference these nodes and bring them online instead of redirecting to one of the set of nodes that were known to have memory at boot. This patch extracts the value of the lowest domain level (number of allocable resources) from the device tree property "ibm,max-associativity-domains" to use as the maximum number of nodes to setup as possibly available in the system. This new setting will override the instruction: nodes_and(node_possible_map, node_possible_map, node_online_map); presently seen in the function arch/powerpc/mm/numa.c:initmem_init(). If the "ibm,max-associativity-domains" property is not present at boot, no operation will be performed to define or enable additional nodes, or enable the above 'nodes_and()'. Signed-off-by: Michael Bringmann Reviewed-by: Nathan Fontenot Signed-off-by: Michael Ellerman Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- arch/powerpc/mm/numa.c | 37 ++++++++++++++++++++++++++++++++++--- 1 file changed, 34 insertions(+), 3 deletions(-) --- a/arch/powerpc/mm/numa.c +++ b/arch/powerpc/mm/numa.c @@ -951,6 +951,34 @@ static void __init setup_node_data(int n NODE_DATA(nid)->node_spanned_pages = spanned_pages; } +static void __init find_possible_nodes(void) +{ + struct device_node *rtas; + u32 numnodes, i; + + if (min_common_depth <= 0) + return; + + rtas = of_find_node_by_path("/rtas"); + if (!rtas) + return; + + if (of_property_read_u32_index(rtas, + "ibm,max-associativity-domains", + min_common_depth, &numnodes)) + goto out; + + for (i = 0; i < numnodes; i++) { + if (!node_possible(i)) { + setup_node_data(i, 0, 0); + node_set(i, node_possible_map); + } + } + +out: + of_node_put(rtas); +} + void __init initmem_init(void) { int nid, cpu; @@ -966,12 +994,15 @@ void __init initmem_init(void) memblock_dump_all(); /* - * Reduce the possible NUMA nodes to the online NUMA nodes, - * since we do not support node hotplug. This ensures that we - * lower the maximum NUMA node ID to what is actually present. + * Modify the set of possible NUMA nodes to reflect information + * available about the set of online nodes, and the set of nodes + * that we expect to make use of for this platform's affinity + * calculations. */ nodes_and(node_possible_map, node_possible_map, node_online_map); + find_possible_nodes(); + for_each_online_node(nid) { unsigned long start_pfn, end_pfn;