Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp212292imm; Tue, 24 Jul 2018 17:27:27 -0700 (PDT) X-Google-Smtp-Source: AAOMgpcxv+/IzOtwfaMK5xr//XFy4QmUIAa9vY4xEBKwbv6Ji0MCoZCvUMOnn0vBZTuJBJUIJrC6 X-Received: by 2002:a17:902:d88d:: with SMTP id b13-v6mr18989112plz.314.1532478447368; Tue, 24 Jul 2018 17:27:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532478447; cv=none; d=google.com; s=arc-20160816; b=ODs6QWTXpubTfNfZwkS7mZM1t7z4HeWrp9/YcE353Rivn7LOmFC2UzeLBxf9jcrXsn hkvaBop2Uaq/nq0FBKDCJTMFDa07cYcVgHFWyraYdYWPoepu75qKdKmS6fBrd2OK+zQ+ W8sYDY+K4+iqDDPvvHbC/cqp9TS7tlp5lmtvHGSZB/TIARBm9WL05JBOmkmkpTYgwnZS JNHiknHnulY7wANwc1xDgzq0ExyuRJP2gKkfkbqO42GOWr/2gEX9o82tGqjhRKrpzwub k3p3xNZPgcWVnT+aAT4l5dQeEzB1r6aonfRx8tr/DPKKv/ot5cIJkkYWmFSLzR+T2XDX Ipow== 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=GiLkvI8Rp3OQo1+Ryx+tNZlttGtHfZulAZ/cM6I2/6Y=; b=MFy/7hmAWfdKtVFJ7cHiKXr+vq+/NzAIhCJCOulwRtslCgYZCJe5iyxDfW+3WXty+B iscBESJR3ElBtaQE5FDYCIeszB9aQgC8xdbqng+1WHnhbLk0PxuWDio3AEP3H/UhICcl N9fxVjaWEyBq+0OpqPo3uuQ5W97gGpGhXXJ3Crj0cU6YZ0IVhIoeC+upuY9t63Ac0Zfr 0l4eaad1ZeadZKbRoUbLjxaMV01w+9bZhflHFgfonKgT5HPBiElXYZLSGk/x4mo4eu8/ h+i7B9rhVBVtmcNotcWq/GE+dgxfLxqJKHw/b+/p1VzK5KZcOV8kLQyzEqzFccq8z+oT WveQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=VPFq6wjj; 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 d130-v6si12734025pgc.189.2018.07.24.17.27.12; Tue, 24 Jul 2018 17:27:27 -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-2018-07-02 header.b=VPFq6wjj; 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 S2388575AbeGYBfW (ORCPT + 99 others); Tue, 24 Jul 2018 21:35:22 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:34910 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388495AbeGYBfW (ORCPT ); Tue, 24 Jul 2018 21:35:22 -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 w6P0O5Uq119841; Wed, 25 Jul 2018 00:25:50 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-2018-07-02; bh=GiLkvI8Rp3OQo1+Ryx+tNZlttGtHfZulAZ/cM6I2/6Y=; b=VPFq6wjj6HC3TyWIxOtTQlEht/S1fAm1umaLHyOrqa1ryEWJcg42S3BwFYeySC8bp1jY 9VJVoqrmIDFQg97jFTzoB5T2Ze/JzYWhqNeRZCM2z6bPdJ1jDKa2pFT19fUIHS4YxMLN duWdpjcm4ysQEmNjRH72gInuIca2wYJ2AbNKHSaH5yrO+EMwnEUI8R6OA+gQXeWqL/pR JzmdlegPtfeXZpesVfdEL9ejDin98DNJn4sMg0jhKZqIO5bwdRlFU2yiAf9RHzPG7gZ9 GBs0himAaB0CFj4gb+v4Cpwn8apN3TBShBdBVy0CIXPgOrOGRhv+IjbifMyUEdYYmMkX Cw== Received: from userv0022.oracle.com (userv0022.oracle.com [156.151.31.74]) by userp2120.oracle.com with ESMTP id 2kbwfpu969-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 25 Jul 2018 00:25:50 +0000 Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by userv0022.oracle.com (8.14.4/8.14.4) with ESMTP id w6P0PmwF004846 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 25 Jul 2018 00:25:49 GMT Received: from abhmp0003.oracle.com (abhmp0003.oracle.com [141.146.116.9]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id w6P0PmCk003387; Wed, 25 Jul 2018 00:25:48 GMT Received: from localhost.localdomain (/73.69.118.222) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 24 Jul 2018 16:55:29 -0700 From: Pavel Tatashin To: steven.sistare@oracle.com, daniel.m.jordan@oracle.com, linux-kernel@vger.kernel.org, akpm@linux-foundation.org, kirill.shutemov@linux.intel.com, mhocko@suse.com, linux-mm@kvack.org, dan.j.williams@intel.com, jack@suse.cz, jglisse@redhat.com, jrdr.linux@gmail.com, bhe@redhat.com, gregkh@linuxfoundation.org, vbabka@suse.cz, richard.weiyang@gmail.com, dave.hansen@intel.com, rientjes@google.com, mingo@kernel.org, osalvador@techadventures.net, pasha.tatashin@oracle.com, abdhalee@linux.vnet.ibm.com, mpe@ellerman.id.au Subject: [PATCH 2/3] mm: calculate deferred pages after skipping mirrored memory Date: Tue, 24 Jul 2018 19:55:19 -0400 Message-Id: <20180724235520.10200-3-pasha.tatashin@oracle.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180724235520.10200-1-pasha.tatashin@oracle.com> References: <20180724235520.10200-1-pasha.tatashin@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=8964 signatures=668706 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1806210000 definitions=main-1807250002 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org update_defer_init() should be called only when struct page is about to be initialized. Because it counts number of initialized struct pages, but there we may skip struct pages if there is some mirrored memory. So move, update_defer_init() after checking for mirrored memory. Also, rename update_defer_init() to defer_init() and reverse the return boolean to emphasize that this is a boolean function, that tells that the reset of memmap initialization should be deferred. Make this function self-contained: do not pass number of already initialized pages in this zone by using static counters. Signed-off-by: Pavel Tatashin --- mm/page_alloc.c | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/mm/page_alloc.c b/mm/page_alloc.c index cea749b26394..86c678cec6bd 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -306,24 +306,28 @@ static inline bool __meminit early_page_uninitialised(unsigned long pfn) } /* - * Returns false when the remaining initialisation should be deferred until + * Returns true when the remaining initialisation should be deferred until * later in the boot cycle when it can be parallelised. */ -static inline bool update_defer_init(pg_data_t *pgdat, - unsigned long pfn, unsigned long zone_end, - unsigned long *nr_initialised) +static inline bool defer_init(int nid, unsigned long pfn, unsigned long end_pfn) { + static unsigned long prev_end_pfn, nr_initialised; + + if (prev_end_pfn != end_pfn) { + prev_end_pfn = end_pfn; + nr_initialised = 0; + } + /* Always populate low zones for address-constrained allocations */ - if (zone_end < pgdat_end_pfn(pgdat)) - return true; - (*nr_initialised)++; - if ((*nr_initialised > pgdat->static_init_pgcnt) && - (pfn & (PAGES_PER_SECTION - 1)) == 0) { - pgdat->first_deferred_pfn = pfn; + if (end_pfn < pgdat_end_pfn(NODE_DATA(nid))) return false; + nr_initialised++; + if ((nr_initialised > NODE_DATA(nid)->static_init_pgcnt) && + (pfn & (PAGES_PER_SECTION - 1)) == 0) { + NODE_DATA(nid)->first_deferred_pfn = pfn; + return true; } - - return true; + return false; } #else static inline bool early_page_uninitialised(unsigned long pfn) @@ -331,11 +335,9 @@ static inline bool early_page_uninitialised(unsigned long pfn) return false; } -static inline bool update_defer_init(pg_data_t *pgdat, - unsigned long pfn, unsigned long zone_end, - unsigned long *nr_initialised) +static inline bool defer_init(int nid, unsigned long pfn, unsigned long end_pfn) { - return true; + return false; } #endif @@ -5462,9 +5464,7 @@ void __meminit memmap_init_zone(unsigned long size, int nid, unsigned long zone, struct vmem_altmap *altmap) { unsigned long end_pfn = start_pfn + size; - pg_data_t *pgdat = NODE_DATA(nid); unsigned long pfn; - unsigned long nr_initialised = 0; struct page *page; #ifdef CONFIG_HAVE_MEMBLOCK_NODE_MAP struct memblock_region *r = NULL, *tmp; @@ -5492,8 +5492,6 @@ void __meminit memmap_init_zone(unsigned long size, int nid, unsigned long zone, continue; if (!early_pfn_in_nid(pfn, nid)) continue; - if (!update_defer_init(pgdat, pfn, end_pfn, &nr_initialised)) - break; #ifdef CONFIG_HAVE_MEMBLOCK_NODE_MAP /* @@ -5516,6 +5514,8 @@ void __meminit memmap_init_zone(unsigned long size, int nid, unsigned long zone, } } #endif + if (defer_init(nid, pfn, end_pfn)) + break; not_early: page = pfn_to_page(pfn); -- 2.18.0