From patchwork Wed Sep 5 21:13:34 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Duyck X-Patchwork-Id: 10589465 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 AC5AC5A4 for ; Wed, 5 Sep 2018 21:13:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 99D722ABB0 for ; Wed, 5 Sep 2018 21:13:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8E2632AC1F; Wed, 5 Sep 2018 21:13:38 +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 20F582ABB0 for ; Wed, 5 Sep 2018 21:13:38 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1ABB36B7530; Wed, 5 Sep 2018 17:13:37 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 1821B6B7531; Wed, 5 Sep 2018 17:13:37 -0400 (EDT) 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 098546B7532; Wed, 5 Sep 2018 17:13:37 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pf1-f197.google.com (mail-pf1-f197.google.com [209.85.210.197]) by kanga.kvack.org (Postfix) with ESMTP id C30CA6B7530 for ; Wed, 5 Sep 2018 17:13:36 -0400 (EDT) Received: by mail-pf1-f197.google.com with SMTP id v9-v6so4622237pff.4 for ; Wed, 05 Sep 2018 14:13:36 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:subject:from:to:cc:date :message-id:in-reply-to:references:user-agent:mime-version :content-transfer-encoding; bh=qtZLT2M6XG6IyUs6kQVBDxV5Cznym29hpwromAFKuTs=; b=LDCc21MVpNg7SrlFnY4Qg8bA/UC8y5oIna4Ojg8g2JKz91shxMN1ccwj4wnfiYbWBT kIK8ooyTiXYuut0tyECAZcr8QStVFrDzmP1mz/eNPNKhL7oHLkjGMQ2TKQ+NXaBfl/GO 64hqg1IFR/VBqkvTkulldZFaUQ50GUnvgTAm2eLjOfMmsSBql/2zXJKpgTpdpT6RKdDD b+MZVGfXk3sSX//JfubH/ml3QSzvIL+l3B03hMBtm9Z8AT82j62MUbH2cQERltGVPOlp IO+ElRfOQf/7ICSJQhfeNsCRlcTSXX70HIKxm4jBtc0PL5SOp0aig6UAo1pWAnDvrDt8 esEA== X-Gm-Message-State: APzg51Dn+I7Tzs7OMeWo0CoT9CUXEJc6NikldJJ0uNavbzPiWi5O9sEU vXx4DLC6vTQjwtSoLgBwjnepyjtpO4T+qqVUQBWClz4a7giREwsqg06HVKTyK13fy+xpMc+s/8/ p3kVglw8iGxlJ4gYZAK9GDSUlyfjRVZJvLgPCqggdi7zokdSjrSdVs3EviGeM4k/ClNzM/+N9jp Im0TVKEG7UcznUb6ETMjmUknPVrGqFO3cV6jdxGU657DTHhg6k5xU0AWFqMWRG56nydEbDynKDi vydnI+ZPz9Ud0CK0qW0lHX1zDRPbuJyb1KF5fk55rAJGD7PSmsXq12JahW1gvhKPua62zBBJyCw 9we25VlqhTv3GDsh5PcFsgpDJ3eihwvYfrW7ajAPPZ08zO91FioDehbL9sBtle0at9wWwvRAEG9 H X-Received: by 2002:a17:902:c7:: with SMTP id a65-v6mr27360685pla.264.1536182016487; Wed, 05 Sep 2018 14:13:36 -0700 (PDT) X-Received: by 2002:a17:902:c7:: with SMTP id a65-v6mr27360652pla.264.1536182015837; Wed, 05 Sep 2018 14:13:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536182015; cv=none; d=google.com; s=arc-20160816; b=N+4kk+Gy0pQ8UsIRPG1nDk2O8zrmizW9gWxouQgLvpgJsXjUFJmzsIpGw3Ae08UwDn cNLlwUrvw9Lmqv6mIaQ9FF2ZKwGawWzr1hOHuXBjgbOTVl8K0dhqAlZ2PQqaj8oRD4Mx 0TNy2sDsHXur7DBXN+BHsQ0KzZV5qDRXq4HeCfHdNe/C+s4RNGJK6tKCxBpneb2bv53n GVxQISB+HME8H+m+mfXqDy11dA/D1l+60SR90QMcCrK5oB9gs8ztnRXPD9mBjtPzXLIr XEDs5Dio58t9HeneSecNytgR8+zwPV1KKHHvLoT7OYfrBdYeOUsz9Y0I2/c+3u84A9VT LFTw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:user-agent:references :in-reply-to:message-id:date:cc:to:from:subject:dkim-signature; bh=qtZLT2M6XG6IyUs6kQVBDxV5Cznym29hpwromAFKuTs=; b=Vtamp8qC6ecPlPj7sqDgHAlMcED1JX/hvR99iFAugXXJsJpcPOnfhJw11ZZx0LAbIW m06R5uAjSToSHXN52sGPh6qjHMYm0IUbbKogBZDXTySQkhdhKCrcWAVONla7fUEV+1ys Wek2LMCrwQgABtvC2cQSDRoMCkiwFFzuclst5HzpHANiwMQlZfn9fYYolAvvBAm8CCMf T8ERwR5upGlI4p2bolmONcbhKwNG+x7jxvzuaMV93C2QatI5KBI4AZFv0QWCrNKoN4yU HrbxfC0TgK+AzLK7P2m9wMOgdW90XqXMYJm91BTygy0tfykazzut4jpcWU7Zq366AmDa SC2Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=PCmXW5Zb; spf=pass (google.com: domain of alexander.duyck@gmail.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=alexander.duyck@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 g16-v6sor607633pgg.427.2018.09.05.14.13.35 for (Google Transport Security); Wed, 05 Sep 2018 14:13:35 -0700 (PDT) Received-SPF: pass (google.com: domain of alexander.duyck@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=PCmXW5Zb; spf=pass (google.com: domain of alexander.duyck@gmail.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=alexander.duyck@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=subject:from:to:cc:date:message-id:in-reply-to:references :user-agent:mime-version:content-transfer-encoding; bh=qtZLT2M6XG6IyUs6kQVBDxV5Cznym29hpwromAFKuTs=; b=PCmXW5ZbDuMnh4HmI+ZPOyS2bhYg+gRI8VlKuZl/2Ag5x5Sj7gjwFpYj2uhDzg0og8 9GIER6wxBvz67jxWM+1aRDAYF7ETfQ9TpiXfL5XGVaTg3nxIVACgIqQp02uobov1blpx MoH2gAcvcLEm1ORyNttzMCMBHZ4OPz0F47CIdPqRQWYWAvK7UVzgbowOoimwNA3oxTQJ KxtPPJp45aJw0OU5qKmi3NyRLg1EI8G4jFLxT4YkWBlyveD30QkWuU9uyj7Am1h6wGt2 NHwZUYOIiY6JNp7Euzyj0C4cuTJ73W28E9X+JC9CZHcq+QuBaQwZuropGo5OKQaGHIPu i+cg== X-Google-Smtp-Source: ANB0VdYyQruNYAtz2t+A0n+/XIhhDjINyfL74FX8J0goc8LPTaYFYfSAJnOxJDq+ED9a996cwwsbOQ== X-Received: by 2002:a65:62d8:: with SMTP id m24-v6mr23864849pgv.307.1536182015456; Wed, 05 Sep 2018 14:13:35 -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 q25-v6sm3805544pfh.113.2018.09.05.14.13.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 05 Sep 2018 14:13:34 -0700 (PDT) Subject: [PATCH v2 2/2] mm: Create non-atomic version of SetPageReserved for init use From: Alexander Duyck To: linux-mm@kvack.org, linux-kernel@vger.kernel.org Cc: alexander.h.duyck@intel.com, pavel.tatashin@microsoft.com, mhocko@suse.com, dave.hansen@intel.com, akpm@linux-foundation.org, mingo@kernel.org, kirill.shutemov@linux.intel.com Date: Wed, 05 Sep 2018 14:13:34 -0700 Message-ID: <20180905211334.3286.84435.stgit@localhost.localdomain> In-Reply-To: <20180905211041.3286.19083.stgit@localhost.localdomain> References: <20180905211041.3286.19083.stgit@localhost.localdomain> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 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 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. 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 --- include/linux/page-flags.h | 1 + mm/page_alloc.c | 13 +++++++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/include/linux/page-flags.h b/include/linux/page-flags.h index 0e95ca63375a..daee3ea2d1ed 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 05e983f42316..f2602021032f 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -1231,7 +1231,8 @@ 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 at init time */ + __SetPageReserved(page); } } } @@ -5517,8 +5518,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