From patchwork Thu Nov 22 09:48:07 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Yang X-Patchwork-Id: 10693761 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9F27B13AD for ; Thu, 22 Nov 2018 09:48:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9051A2C93D for ; Thu, 22 Nov 2018 09:48:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 843622C949; Thu, 22 Nov 2018 09:48:19 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 17A6A2C93D for ; Thu, 22 Nov 2018 09:48:19 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 15CA26B2ADA; Thu, 22 Nov 2018 04:48:18 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 0E34D6B2ADB; Thu, 22 Nov 2018 04:48:18 -0500 (EST) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id ED6646B2ADC; Thu, 22 Nov 2018 04:48:17 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pf1-f199.google.com (mail-pf1-f199.google.com [209.85.210.199]) by kanga.kvack.org (Postfix) with ESMTP id A40256B2ADA for ; Thu, 22 Nov 2018 04:48:17 -0500 (EST) Received: by mail-pf1-f199.google.com with SMTP id i19-v6so2681600pfi.21 for ; Thu, 22 Nov 2018 01:48:17 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:from:to:cc:subject:date :message-id; bh=2ndPbdnsDWE7P6qHvkqFi3NkBUepb0jGVr16ZluFA78=; b=mCIXCqqu01O+Y2m+GG29ySa+h7GR6dVw7sKCw7Sa8KQatX3ksXAFfBf8x9Rvqp8Dy2 v2R9SMyLtFNIBPtlq2JLmq9pfVa6G3etJ44X/6N2rqfSDCtc+o3zB9Er716OdC6qqFMM R8RZigJNlQlOvLU+6ww6XXZuzgxiHuao7Bxhneh8KRi9pJrxxlSqXF+hNrZx1+Rpg1v4 W0/ceDAsNzHw9iJnONgcK1MvVSO2AYITIQqB4I8R0KaCkLkLm8w/aH169OiZp0bX+hjM W4irH3rpHmDcOAHVOupXWFvXT6vldlH7YBZSqEg8EFTwzHTaIoHsmar4pSlzd1xX1P6h D/pA== X-Gm-Message-State: AA+aEWYRlivVGvaFD2StHGdpCw5nnovlRSbRW7u46xxPaAUuN5p4Gzdd l5/WGrv9CJ59IqepevPam62uIehUsx1620lknE8kpJUhHFgGvaT6pG1qfz0GXwtQ/IJzBGS5i0C D6ugyhrctRgFZ8hNfmihGFll7jdDcqoAa8SLm21zwf6iDBBlnu27pLk2nkIXSrZtXakyScEmAvo MSnqVfntruFNRdXdnGioe9Kn402fFJRB8AfyQ0wVR9OLP7u8zMVg8SHfO6MoNJRy5hHwuyR4c2U JvIbKzeD8DuMZwXn44QABFcIKyS2QSes2L5Ob1MrRxp6GECKvupyuqpV8s5/f96YEMx1k5qzEFC IeHJmOLazGm2RKEEMqlmsCHtS+LnTlLotujBbEqIIxjg7BXUciBzP8+1T5lLLGzSEay8j7T0AXl 2 X-Received: by 2002:a63:5518:: with SMTP id j24mr9239617pgb.208.1542880097169; Thu, 22 Nov 2018 01:48:17 -0800 (PST) X-Received: by 2002:a63:5518:: with SMTP id j24mr9239584pgb.208.1542880096314; Thu, 22 Nov 2018 01:48:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542880096; cv=none; d=google.com; s=arc-20160816; b=zRHDFTey3yi5+nIOLbOKePr01Tpt+O9F45hLwmwbByBWdj2Y5Ii0al/NIYh2xXZBGA /Yw5t5/1qEXr541AbdGbMBiM6hMHX9lhAVzX6HD06VJdbpQeLLYAMnSNNX4wp981OlQl gw5MtZnwEcS5nFD31OJDzSJfqTrsIkCO2kQWM0s3dCEsaqIigwU9pakDOS6lnl7kTEXz rAxu9YA8ofgs/JZCgt0CUMxHU2Fjpui04Gc8xhq3HCOUqHzp6Pz5nXgKfprep18UEwjk CzffJCLWHt+zLsTtRDdu0uGo9gVLhZi7eDjkVk+xqbi1xUsLdKAk92FDT41ZV5nHEcHc 9cCg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=message-id:date:subject:cc:to:from:dkim-signature; bh=2ndPbdnsDWE7P6qHvkqFi3NkBUepb0jGVr16ZluFA78=; b=iFtsyldH54n7j9yOIqhWhfNt3FaTQUfoyQeiL3aar9wUucRlrpnOXqf5ow0MNMZL8+ gC8kWflifQm4UXyW3NroDT06WvXISlBnpbeWraQcC9eWs7tnxWgmZQd0yrrT+pT+G/Un dJdNzA7MF16A7u36wxRNgpgEecm+JA3OIi/07pROpJcSwHpSbmSrgfNbEPEeBSJ0MrUk 3pW5Z5uX7Xdk09djVVrwOX4GwqGXveHZ+23+TxakMKFBr/U3OxMphQARTB6E5o878B0l J6/F0VHxiagePyNU/PsUXgiisRvAi4sQ9itRlIWNO59bpufuyNREGyybmtNvKWLBDtMQ NQpg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=QOL6vPeo; spf=pass (google.com: domain of richard.weiyang@gmail.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=richard.weiyang@gmail.com; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id 3-v6sor5663201plz.28.2018.11.22.01.48.16 for (Google Transport Security); Thu, 22 Nov 2018 01:48:16 -0800 (PST) Received-SPF: pass (google.com: domain of richard.weiyang@gmail.com designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=QOL6vPeo; spf=pass (google.com: domain of richard.weiyang@gmail.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=richard.weiyang@gmail.com; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=2ndPbdnsDWE7P6qHvkqFi3NkBUepb0jGVr16ZluFA78=; b=QOL6vPeonPLa9j7rsi0OP8LoJ6E1kNq3ydprGNbc4l/Yx+CKGc+FONdHfG43HmerRq Fpt91Zb6Tsi1c0mZAkAoxqumE+0iWahU2SoGkgNDvinY9F4jPb9VhPo2RthxfPiOxf1x iQkWDUeT5QkY0+PZ33HV4FUZCgmSPE0jjq7TTg0jgq3gm8B284kQ37iSr8X9cb3bA0TY szbrWIZfaRLKTKEAYswmQ5404lrNhQHHe6baD8v6iBtfVJv3fzoHMT89LqZnEzWhnQvg sysHqRUds2ZfuweysSs7eO4zdsdFd37FLezMnbPu8lU7VZJ6ghgeElcFCr8t4g5DIzzs iNaw== X-Google-Smtp-Source: AFSGD/V5RVFCGg03A2xrPTXd8sLmodjlSYv4F8ik7zOJx6+Yxe67Wit4g0xcgX+ikjMcTPQUOUzRaw== X-Received: by 2002:a17:902:bd0b:: with SMTP id p11-v6mr10475089pls.35.1542880095880; Thu, 22 Nov 2018 01:48:15 -0800 (PST) Received: from localhost ([185.92.221.13]) by smtp.gmail.com with ESMTPSA id y89sm9018500pfa.136.2018.11.22.01.48.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 22 Nov 2018 01:48:15 -0800 (PST) From: Wei Yang To: osalvador@suse.de Cc: akpm@linux-foundation.org, linux-mm@kvack.org, Wei Yang Subject: [PATCH] mm: check nr_initialised with PAGES_PER_SECTION directly in defer_init() Date: Thu, 22 Nov 2018 17:48:07 +0800 Message-Id: <20181122094807.6985-1-richard.weiyang@gmail.com> X-Mailer: git-send-email 2.15.1 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP When DEFERRED_STRUCT_PAGE_INIT is configured, only the first section of each node's highest zone is initialized before defer stage. static_init_pgcnt is used to store the number of pages like this: pgdat->static_init_pgcnt = min_t(unsigned long, PAGES_PER_SECTION, pgdat->node_spanned_pages); because we don't want to overflow zone's range. But this is not necessary, since defer_init() is called like this: memmap_init_zone() for pfn in [start_pfn, end_pfn) defer_init(pfn, end_pfn) In case (pgdat->node_spanned_pages < PAGES_PER_SECTION), the loop would stop before calling defer_init(). BTW, comparing PAGES_PER_SECTION with node_spanned_pages is not correct, since nr_initialised is zone based instead of node based. Even node_spanned_pages is bigger than PAGES_PER_SECTION, its highest zone would have pages less than PAGES_PER_SECTION. Signed-off-by: Wei Yang Signed-off-by: Wei Yang Signed-off-by: Andrew Morton Reviewed-by: Alexander Duyck --- include/linux/mmzone.h | 2 -- mm/page_alloc.c | 13 ++++++------- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h index ae7a830a21eb..68d7b558924b 100644 --- a/include/linux/mmzone.h +++ b/include/linux/mmzone.h @@ -692,8 +692,6 @@ typedef struct pglist_data { * is the first PFN that needs to be initialised. */ unsigned long first_deferred_pfn; - /* Number of non-deferred pages */ - unsigned long static_init_pgcnt; #endif /* CONFIG_DEFERRED_STRUCT_PAGE_INIT */ #ifdef CONFIG_TRANSPARENT_HUGEPAGE diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 76e12179cd5e..b542d82400cf 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -326,8 +326,13 @@ defer_init(int nid, unsigned long pfn, unsigned long end_pfn) /* Always populate low zones for address-constrained allocations */ if (end_pfn < pgdat_end_pfn(NODE_DATA(nid))) return false; + + /* + * We start only with one section of pages, more pages are added as + * needed until the rest of deferred pages are initialized. + */ nr_initialised++; - if ((nr_initialised > NODE_DATA(nid)->static_init_pgcnt) && + if ((nr_initialised > PAGES_PER_SECTION) && (pfn & (PAGES_PER_SECTION - 1)) == 0) { NODE_DATA(nid)->first_deferred_pfn = pfn; return true; @@ -6451,12 +6456,6 @@ static void __ref alloc_node_mem_map(struct pglist_data *pgdat) { } #ifdef CONFIG_DEFERRED_STRUCT_PAGE_INIT static inline void pgdat_set_deferred_range(pg_data_t *pgdat) { - /* - * We start only with one section of pages, more pages are added as - * needed until the rest of deferred pages are initialized. - */ - pgdat->static_init_pgcnt = min_t(unsigned long, PAGES_PER_SECTION, - pgdat->node_spanned_pages); pgdat->first_deferred_pfn = ULONG_MAX; } #else