From patchwork Mon Sep 10 23:43:48 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Duyck X-Patchwork-Id: 10594909 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 03B396CB for ; Mon, 10 Sep 2018 23:43:51 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E641C291BB for ; Mon, 10 Sep 2018 23:43:50 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D9FFF291F4; Mon, 10 Sep 2018 23:43:50 +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=-2.8 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from ml01.01.org (ml01.01.org [198.145.21.10]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 87C4D291BB for ; Mon, 10 Sep 2018 23:43:50 +0000 (UTC) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 70F3721127CBA; Mon, 10 Sep 2018 16:43:50 -0700 (PDT) X-Original-To: linux-nvdimm@lists.01.org Delivered-To: linux-nvdimm@lists.01.org Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=2607:f8b0:4864:20::642; helo=mail-pl1-x642.google.com; envelope-from=alexander.duyck@gmail.com; receiver=linux-nvdimm@lists.01.org Received: from mail-pl1-x642.google.com (mail-pl1-x642.google.com [IPv6:2607:f8b0:4864:20::642]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id B22702112500D for ; Mon, 10 Sep 2018 16:43:49 -0700 (PDT) Received: by mail-pl1-x642.google.com with SMTP id w14-v6so10440202plp.6 for ; Mon, 10 Sep 2018 16:43:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:from:to:cc:date:message-id:in-reply-to:references :user-agent:mime-version:content-transfer-encoding; bh=lhFr3T5RF4ix/HN80RMUA8xymXKjrz1rlCqR/lwO+vo=; b=M5jUdHnplNrgx3jtLSwG+/FiSgIS5lu66K/26ReK6zbipcdAmf2HbSKpXwL++aiju+ BBPLh+5tfixgC9jksDYNDyOzwlV9qKrTrb3wq1Avw2EtcbsmSbb5ib0kltUcSCuZkk1L tUJM4vwwtCW1eWbbOxG5/eM08A/nR81VfKIwm1GYNN9jiWxeqdtUkTee2LITfK3kV+oX bQyuH29EMKTNsd9GC774DuOq9xIPkqxxgsQSh26nIvJHbXrSG0u2q385g0pcmvaJKEfQ 9nFUXSV5uLTUIsICYY0eagbcIS8YZ9EPAqXl4PMy2TeTZ2GAVKo9jxcEUWk3UUtKBzn5 PotA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:from:to:cc:date:message-id:in-reply-to :references:user-agent:mime-version:content-transfer-encoding; bh=lhFr3T5RF4ix/HN80RMUA8xymXKjrz1rlCqR/lwO+vo=; b=USlR+CgduexaddmypvSB3QnAKjVjgfzQbIWroRj8NEjEModAa+kG+8WXy8pchXbzff 14jtBrjDni4aQay3MPVBL2kdj084KkDCLTE7tfvWonn/6FD2vt/gadVmCDf2BiUmS1iD nuUqpF4mVrPaSDLPZ3T+GFcni5loeZwpamkp6dU4KD1IqS23egY6cz0RhueIoq6LO/No EO1GfYAI5+jrFuuZ60Q23NVCcLqT7h9bEWwAvXb/ahEJKlSYKdhl513Mb2t2idduOObY un7nm8/ljfipeU+n34vv4au8dykx8yYJ0TDkrcwhhvjV1yPHW3bTcREFA6QsjEZYiIte UPUw== X-Gm-Message-State: APzg51D/mt0alWcsQORLgoONy7ukNVcv3iCcLAXEAmKmnIzTly9p8qso UlDFCreX0AbCvHqkyL3Oh/4= X-Google-Smtp-Source: ANB0VdZ9nofLh3IK/Vq5oODEvu42HmX3XMswWPrs5u5Htg1ryZEmW2HxTof/tUVek3Nw+LtN1MGgcw== X-Received: by 2002:a17:902:344:: with SMTP id 62-v6mr24533133pld.164.1536623029274; Mon, 10 Sep 2018 16:43:49 -0700 (PDT) Received: from localhost.localdomain (static-50-53-21-37.bvtn.or.frontiernet.net. [50.53.21.37]) by smtp.gmail.com with ESMTPSA id v20-v6sm33973962pfk.12.2018.09.10.16.43.48 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 10 Sep 2018 16:43:48 -0700 (PDT) Subject: [PATCH 2/4] mm: Create non-atomic version of SetPageReserved for init use From: Alexander Duyck To: linux-mm@kvack.org, linux-kernel@vger.kernel.org, linux-nvdimm@lists.01.org Date: Mon, 10 Sep 2018 16:43:48 -0700 Message-ID: <20180910234348.4068.92164.stgit@localhost.localdomain> In-Reply-To: <20180910232615.4068.29155.stgit@localhost.localdomain> References: <20180910232615.4068.29155.stgit@localhost.localdomain> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-BeenThere: linux-nvdimm@lists.01.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Linux-nvdimm developer list." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: pavel.tatashin@microsoft.com, mhocko@suse.com, dave.hansen@intel.com, jglisse@redhat.com, akpm@linux-foundation.org, mingo@kernel.org, kirill.shutemov@linux.intel.com Errors-To: linux-nvdimm-bounces@lists.01.org Sender: "Linux-nvdimm" X-Virus-Scanned: ClamAV using ClamSMTP From: Alexander Duyck It doesn't make much sense to use the atomic SetPageReserved at init time when we are using memset to clear the memory and manipulating the page flags via simple "&=" and "|=" operations in __init_single_page. This patch adds a non-atomic version __SetPageReserved that can be used during page init and shows about a 10% improvement in initialization times on the systems I have available for testing. On those systems I saw initialization times drop from around 35 seconds to around 32 seconds to initialize a 3TB block of persistent memory. I tried adding a bit of documentation based on commit ("mm, memory_hotplug: do not associate hotadded memory to zones until online"). Ideally the reserved flag should be set earlier since there is a brief window where the page is initialization via __init_single_page and we have not set the PG_Reserved flag. I'm leaving that for a future patch set as that will require a more significant refactor. Acked-by: Michal Hocko Signed-off-by: Alexander Duyck Reviewed-by: Pavel Tatashin --- include/linux/page-flags.h | 1 + mm/page_alloc.c | 17 +++++++++++++++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/include/linux/page-flags.h b/include/linux/page-flags.h index d00216cf00f8..1b1f8e0378ae 100644 --- a/include/linux/page-flags.h +++ b/include/linux/page-flags.h @@ -300,6 +300,7 @@ static inline void page_init_poison(struct page *page, size_t size) PAGEFLAG(Reserved, reserved, PF_NO_COMPOUND) __CLEARPAGEFLAG(Reserved, reserved, PF_NO_COMPOUND) + __SETPAGEFLAG(Reserved, reserved, PF_NO_COMPOUND) PAGEFLAG(SwapBacked, swapbacked, PF_NO_TAIL) __CLEARPAGEFLAG(SwapBacked, swapbacked, PF_NO_TAIL) __SETPAGEFLAG(SwapBacked, swapbacked, PF_NO_TAIL) diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 89d2a2ab3fe6..a9b095a72fd9 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -1231,7 +1231,12 @@ void __meminit reserve_bootmem_region(phys_addr_t start, phys_addr_t end) /* Avoid false-positive PageTail() */ INIT_LIST_HEAD(&page->lru); - SetPageReserved(page); + /* + * no need for atomic set_bit because the struct + * page is not visible yet so nobody should + * access it yet. + */ + __SetPageReserved(page); } } } @@ -5517,8 +5522,16 @@ void __meminit memmap_init_zone(unsigned long size, int nid, unsigned long zone, not_early: page = pfn_to_page(pfn); __init_single_page(page, pfn, zone, nid); + + /* + * Mark page reserved as it will need to wait for onlining + * phase for it to be fully associated with a zone. + * + * We can use the non-atomic __set_bit operation for setting + * the flag as we are still initializing the pages. + */ if (context == MEMMAP_HOTPLUG) - SetPageReserved(page); + __SetPageReserved(page); /* * Mark the block movable so that blocks are reserved for