Received: by 10.213.65.68 with SMTP id h4csp3831497imn; Tue, 3 Apr 2018 11:21:13 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+zwLbHiM0/wWK0sq4paRG+Tnf5rXFnmumUs70BPIUHLTonU9pdG6Deen5dY/ttpdBX01Lk X-Received: by 10.98.16.28 with SMTP id y28mr8373821pfi.122.1522779673691; Tue, 03 Apr 2018 11:21:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522779673; cv=none; d=google.com; s=arc-20160816; b=iacp511l18px9OJbgy2RWtaEbtHjFH0zeqEe2+oLvFGIA3d/N4Oa53oTfIM1xtGNM/ bNwalDWfbCVHQCY4RVoA5zM5dauv+PgDLoB9mfOxAsdsh/mqy5hXj1qJQFYQYv+qkww7 OhhWJFbBAOICuDBrCT2DRm2jnIdRlFAoqW4j0+3Ul+meIhy8YwnErZWLfIReH3oHU+7k G/MeJE4HWyo72s1yJlzUUPz7pAoXLKX08EXPUEdME4wPOytBXZJfVrx7giKWEQCrq+X/ dRFQRl2GIkFtZNb8gTckSAn81JyXO8cvavWJOZ5yTy0ppkR2c/tByXIaYYU1Wu6SDZx8 qFjw== 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:to:from:dkim-signature:arc-authentication-results; bh=So6j9ukeJrzzU5VMfM+cU++CPiDFCfYlHkdG69cFRzE=; b=RsVtseGFe58f5cRwOYUdmyQYkUWIKCMZBKytStPhhdos0HEj59PWHhAw9BfLv+GS+h CV/pWlwkqbjlOFmuBBZcI/Svy+MzIRYbKI0iHdXzI5/2E4jH0D9aiV6gZatYDhQiuUsV 5f9lDlboGIWgVsnNZkcG1mdFug41wE1OSZFlYLIxb1JFDfl2+6NSX5I+l2S+tIjwgvAV QaWQrQxLliLYk4fQiAlYVv/6Zi2T/2Q9PIXHQAbjJVy73DqhV+DagDcEDS2C9I2YTdmW zeMnAgY4CIGqekjaA87d01CuxQLyBS2d89kNDdf7+CYaSp5GGmMhAuvtP1cy37CFnMMq YxCw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2017-10-26 header.b=CBW0HG5Y; 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=oracle.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n10-v6si3302052plp.388.2018.04.03.11.21.00; Tue, 03 Apr 2018 11:21:13 -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=@oracle.com header.s=corp-2017-10-26 header.b=CBW0HG5Y; 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=oracle.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752973AbeDCSSP (ORCPT + 99 others); Tue, 3 Apr 2018 14:18:15 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:52726 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752132AbeDCSSN (ORCPT ); Tue, 3 Apr 2018 14:18:13 -0400 Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.22/8.16.0.22) with SMTP id w33IGtnr171295; Tue, 3 Apr 2018 18:17:49 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id : in-reply-to : references; s=corp-2017-10-26; bh=So6j9ukeJrzzU5VMfM+cU++CPiDFCfYlHkdG69cFRzE=; b=CBW0HG5Y7P+L0mTeeZQyH0D4GV9kiCZMa+SRtyKQMI7uyG8fYgJ5sO9WHDLRptQY8O8t da9noLbnaWQAABwNzx9QgI4EM9mucflf6qMsYEqEpD/O2bZetACDii385g4SqALYBazA wu4sZk8o0Ea/pcpFaRfNFT7OsNPES4QczPbiGIZGF7QNWVXAZOe1qHufz/BkoqMeajeR KBqh60uRXeM0j8ZRJjyzjzfgxTyiVJ35mvW12162XhviDcfBtg7CvS3YFQVpnVyspvMS McR7TFZhLNAN41pJasJsH7ZddF76c1MgbEo2XWfddebityHUSqBEcyxxecK0cM+ttPAk zQ== Received: from aserv0022.oracle.com (aserv0022.oracle.com [141.146.126.234]) by userp2120.oracle.com with ESMTP id 2h4erm01q9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 03 Apr 2018 18:17:48 +0000 Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by aserv0022.oracle.com (8.14.4/8.14.4) with ESMTP id w33IGvl3021456 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 3 Apr 2018 18:16:57 GMT Received: from abhmp0017.oracle.com (abhmp0017.oracle.com [141.146.116.23]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id w33IGuk7008045; Tue, 3 Apr 2018 18:16:56 GMT Received: from localhost.localdomain (/98.216.35.41) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 03 Apr 2018 11:16:56 -0700 From: Pavel Tatashin To: steven.sistare@oracle.com, daniel.m.jordan@oracle.com, akpm@linux-foundation.org, mgorman@techsingularity.net, mhocko@suse.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org, gregkh@linuxfoundation.org, vbabka@suse.cz, bharata@linux.vnet.ibm.com, tglx@linutronix.de, mingo@redhat.com, hpa@zytor.com, x86@kernel.org, dan.j.williams@intel.com, kirill.shutemov@linux.intel.com, bhe@redhat.com, alexander.levin@microsoft.com Subject: [v6 5/6] mm/memory_hotplug: don't read nid from struct page during hotplug Date: Tue, 3 Apr 2018 14:16:42 -0400 Message-Id: <20180403181643.28127-6-pasha.tatashin@oracle.com> X-Mailer: git-send-email 2.16.3 In-Reply-To: <20180403181643.28127-1-pasha.tatashin@oracle.com> References: <20180403181643.28127-1-pasha.tatashin@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=8852 signatures=668697 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=800 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1711220000 definitions=main-1804030185 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org register_mem_sect_under_node is careful to check the node id of each pfn in the memblock range to handle configurations with interleaving nodes. This is not really needed for the memory hotplug because hotadded ranges are bound to a single NUMA node. We simply cannot handle interleaving NUMA nodes in the same memblock currently and there are no signs that anybody would want anything like that in future. That would require much more refactoring. This is a preparatory patch for later patches. Signed-off-by: Pavel Tatashin Reviewed-by: Ingo Molnar --- drivers/base/memory.c | 4 ++-- drivers/base/node.c | 22 +++++++++++++++------- include/linux/memory.h | 2 +- include/linux/node.h | 4 ++-- mm/memory_hotplug.c | 2 +- 5 files changed, 21 insertions(+), 13 deletions(-) diff --git a/drivers/base/memory.c b/drivers/base/memory.c index deb3f029b451..79fcd2bae96b 100644 --- a/drivers/base/memory.c +++ b/drivers/base/memory.c @@ -712,7 +712,7 @@ static int add_memory_block(int base_section_nr) * need an interface for the VM to add new memory regions, * but without onlining it. */ -int register_new_memory(int nid, struct mem_section *section) +int hotplug_memory_register(int nid, struct mem_section *section) { int ret = 0; struct memory_block *mem; @@ -731,7 +731,7 @@ int register_new_memory(int nid, struct mem_section *section) } if (mem->section_count == sections_per_block) - ret = register_mem_sect_under_node(mem, nid); + ret = register_mem_sect_under_node(mem, nid, false); out: mutex_unlock(&mem_sysfs_mutex); return ret; diff --git a/drivers/base/node.c b/drivers/base/node.c index ee090ab9171c..d7cfc8d8a5c5 100644 --- a/drivers/base/node.c +++ b/drivers/base/node.c @@ -397,7 +397,8 @@ static int __ref get_nid_for_pfn(unsigned long pfn) } /* register memory section under specified node if it spans that node */ -int register_mem_sect_under_node(struct memory_block *mem_blk, int nid) +int register_mem_sect_under_node(struct memory_block *mem_blk, int nid, + bool check_nid) { int ret; unsigned long pfn, sect_start_pfn, sect_end_pfn; @@ -423,11 +424,18 @@ int register_mem_sect_under_node(struct memory_block *mem_blk, int nid) continue; } - page_nid = get_nid_for_pfn(pfn); - if (page_nid < 0) - continue; - if (page_nid != nid) - continue; + /* + * We need to check if page belongs to nid only for the boot + * case, during hotplug we know that all pages in the memory + * block belong to the same node. + */ + if (check_nid) { + page_nid = get_nid_for_pfn(pfn); + if (page_nid < 0) + continue; + if (page_nid != nid) + continue; + } ret = sysfs_create_link_nowarn(&node_devices[nid]->dev.kobj, &mem_blk->dev.kobj, kobject_name(&mem_blk->dev.kobj)); @@ -502,7 +510,7 @@ int link_mem_sections(int nid, unsigned long start_pfn, unsigned long nr_pages) mem_blk = find_memory_block_hinted(mem_sect, mem_blk); - ret = register_mem_sect_under_node(mem_blk, nid); + ret = register_mem_sect_under_node(mem_blk, nid, true); if (!err) err = ret; diff --git a/include/linux/memory.h b/include/linux/memory.h index f71e732c77b2..9f8cd856ca1e 100644 --- a/include/linux/memory.h +++ b/include/linux/memory.h @@ -109,7 +109,7 @@ extern int register_memory_notifier(struct notifier_block *nb); extern void unregister_memory_notifier(struct notifier_block *nb); extern int register_memory_isolate_notifier(struct notifier_block *nb); extern void unregister_memory_isolate_notifier(struct notifier_block *nb); -extern int register_new_memory(int, struct mem_section *); +int hotplug_memory_register(int nid, struct mem_section *section); #ifdef CONFIG_MEMORY_HOTREMOVE extern int unregister_memory_section(struct mem_section *); #endif diff --git a/include/linux/node.h b/include/linux/node.h index 4ece0fee0ffc..41f171861dcc 100644 --- a/include/linux/node.h +++ b/include/linux/node.h @@ -67,7 +67,7 @@ extern void unregister_one_node(int nid); extern int register_cpu_under_node(unsigned int cpu, unsigned int nid); extern int unregister_cpu_under_node(unsigned int cpu, unsigned int nid); extern int register_mem_sect_under_node(struct memory_block *mem_blk, - int nid); + int nid, bool check_nid); extern int unregister_mem_sect_under_nodes(struct memory_block *mem_blk, unsigned long phys_index); @@ -97,7 +97,7 @@ static inline int unregister_cpu_under_node(unsigned int cpu, unsigned int nid) return 0; } static inline int register_mem_sect_under_node(struct memory_block *mem_blk, - int nid) + int nid, bool check_nid) { return 0; } diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c index 565048f496f7..477e183a4ac7 100644 --- a/mm/memory_hotplug.c +++ b/mm/memory_hotplug.c @@ -279,7 +279,7 @@ static int __meminit __add_section(int nid, unsigned long phys_start_pfn, if (!want_memblock) return 0; - return register_new_memory(nid, __pfn_to_section(phys_start_pfn)); + return hotplug_memory_register(nid, __pfn_to_section(phys_start_pfn)); } /* -- 2.16.3