From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1030894AbdEWPQA (ORCPT ); Tue, 23 May 2017 11:16:00 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:43983 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965034AbdEWPP5 (ORCPT ); Tue, 23 May 2017 11:15:57 -0400 To: linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org Cc: Benjamin Herrenschmidt , Paul Mackerras , Michael Ellerman , Reza Arbab , Thomas Gleixner , Bharata B Rao , Balbir Singh , Michael Bringmann , Shailendra Singh , "Aneesh Kumar K.V" , Sebastian Andrzej Siewior From: Michael Bringmann Subject: [Patch 2/2]: powerpc/hotplug/mm: Fix hot-add memory node assoc Organization: IBM Linux Technology Center Date: Tue, 23 May 2017 10:15:44 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-TM-AS-GCONF: 00 x-cbid: 17052315-0024-0000-0000-0000167C6912 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00007106; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000212; SDB=6.00864526; UDB=6.00429177; IPR=6.00644305; BA=6.00005369; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00015553; XFM=3.00000015; UTC=2017-05-23 15:15:49 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17052315-0025-0000-0000-00004B09E542 Message-Id: <3bb44d92-b2ff-e197-4bdf-ec6d588d6dab@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2017-05-23_04:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=0 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1703280000 definitions=main-1705230079 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Removing or adding memory via the PowerPC hotplug interface shows anomalies in the association between memory and nodes. The code was updated to initialize more possible nodes to make them available to subsequent DLPAR hotplug-memory operations, even if they are not needed at boot time. Signed-off-by: Michael Bringmann --- arch/powerpc/mm/numa.c | 44 ++++++++++++++++++++++++++++++++------------ 1 file changed, 32 insertions(+), 12 deletions(-) diff --git a/arch/powerpc/mm/numa.c b/arch/powerpc/mm/numa.c index 15c2dd5..3d58c1f 100644 --- a/arch/powerpc/mm/numa.c +++ b/arch/powerpc/mm/numa.c @@ -870,7 +870,7 @@ void __init dump_numa_cpu_topology(void) } /* Initialize NODE_DATA for a node on the local memory */ -static void __init setup_node_data(int nid, u64 start_pfn, u64 end_pfn) +static void setup_node_data(int nid, u64 start_pfn, u64 end_pfn) { u64 spanned_pages = end_pfn - start_pfn; const size_t nd_size = roundup(sizeof(pg_data_t), SMP_CACHE_BYTES); @@ -878,23 +878,41 @@ static void __init setup_node_data(int nid, u64 start_pfn, u64 end_pfn) void *nd; int tnid; - nd_pa = memblock_alloc_try_nid(nd_size, SMP_CACHE_BYTES, nid); - nd = __va(nd_pa); + if (!node_data[nid]) { + nd_pa = memblock_alloc_try_nid(nd_size, SMP_CACHE_BYTES, nid); + nd = __va(nd_pa); - /* report and initialize */ - pr_info(" NODE_DATA [mem %#010Lx-%#010Lx]\n", - nd_pa, nd_pa + nd_size - 1); - tnid = early_pfn_to_nid(nd_pa >> PAGE_SHIFT); - if (tnid != nid) - pr_info(" NODE_DATA(%d) on node %d\n", nid, tnid); + node_data[nid] = nd; + memset(NODE_DATA(nid), 0, sizeof(pg_data_t)); + NODE_DATA(nid)->node_id = nid; + + /* report and initialize */ + pr_info(" NODE_DATA [mem %#010Lx-%#010Lx]\n", + nd_pa, nd_pa + nd_size - 1); + tnid = early_pfn_to_nid(nd_pa >> PAGE_SHIFT); + if (tnid != nid) + pr_info(" NODE_DATA(%d) on node %d\n", nid, tnid); + } else { + nd_pa = (u64) node_data[nid]; + nd = __va(nd_pa); + } - node_data[nid] = nd; - memset(NODE_DATA(nid), 0, sizeof(pg_data_t)); - NODE_DATA(nid)->node_id = nid; NODE_DATA(nid)->node_start_pfn = start_pfn; NODE_DATA(nid)->node_spanned_pages = spanned_pages; } +static void setup_nodes(void) +{ + int i, l = 32 /* MAX_NUMNODES */; + + for (i = 0; i < l; i++) { + if (!node_possible(i)) { + setup_node_data(i, 0, 0); + node_set(i, node_possible_map); + } + } +} + void __init initmem_init(void) { int nid, cpu; @@ -914,6 +932,8 @@ void __init initmem_init(void) */ nodes_and(node_possible_map, node_possible_map, node_online_map); + setup_nodes(); + for_each_online_node(nid) { unsigned long start_pfn, end_pfn;