From patchwork Wed Sep 5 21:13:28 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Duyck X-Patchwork-Id: 10589463 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 DF89413AC for ; Wed, 5 Sep 2018 21:13:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CC3352A6F0 for ; Wed, 5 Sep 2018 21:13:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C02CE2ABD3; Wed, 5 Sep 2018 21:13:32 +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 3F8D72A6F0 for ; Wed, 5 Sep 2018 21:13:32 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 443176B752E; Wed, 5 Sep 2018 17:13:31 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 3F2566B752F; Wed, 5 Sep 2018 17:13:31 -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 3090D6B7530; Wed, 5 Sep 2018 17:13:31 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pl1-f198.google.com (mail-pl1-f198.google.com [209.85.214.198]) by kanga.kvack.org (Postfix) with ESMTP id E66FC6B752E for ; Wed, 5 Sep 2018 17:13:30 -0400 (EDT) Received: by mail-pl1-f198.google.com with SMTP id d40-v6so4379310pla.14 for ; Wed, 05 Sep 2018 14:13:30 -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=FFB08YKorxcOMOwUtMi0I35BA7p13x7BDsSY6WAe3AI=; b=fGXzDbv0i6CQ8r20IOEZeyrh0qu70xromH8sNUUNg7PaahsPixoDJ4+5YbuBfnVX6t NW4X2z+w0+OdxNlQwDh8f0A7N5aMMJjIyjzbJbWMlOZXD5aAEJRlGtK5WctkcgTs5Hmg Mo+xs9c2PkxbPLZByQ670G3ikvxcIij2OTHM5XF5jHC9nY9KpIRWdAT9z9C+sW0iLZ1m Mf/e2w2+KKOqmKN11o+Ew3F/EmQC7/zai1VF6DgsIYG305avnQqq3lml/JwC6x3YJ+mJ JoPkT+f1s4VlhRx7xmx4O/eDW/MIrZuObC4f0FI/SyhZwvwpws/bYGO3+yyi97Ms/sM6 +pAg== X-Gm-Message-State: APzg51ADB2QD+9OlbAqCQF7WXViVvQIt2kxzXX/9TOXjCCSFm4WBqYsO YT5txuPg8b7xf07GRxXFx4sBFwNArdGQeAme5+a8LarXy6JE1mVJFFWZzim8gmc0QBbQQ6JhXGD 7GvdFvgCcw9Xxr/CHP8fMuMAf/kpwjOcM2mDP+uk7N6ClP+O7IDnVfMpRnVcKjQmLdnj/59h4b9 6gSUOY/CqohKKDvF320FjsuJqwJun98h9RRmzN2M48Khpc9yONUXxGTUwTlHKMJTOdqSJfzUgZk FANaiPlbHkRXvdEx3kS1pmRL5i8kzeNVtJOJWfccuMgvPm5HHobuHUKh2Y0cep4jVdmm3inMzKN OgL77TG+AUwXeyF0dhDRRVya2pgRLDO0Cxak4o3LraDQX2GEiSWu1gxphElRIFMQbx4yNS+2qyW m X-Received: by 2002:a62:d544:: with SMTP id d65-v6mr42530905pfg.107.1536182010609; Wed, 05 Sep 2018 14:13:30 -0700 (PDT) X-Received: by 2002:a62:d544:: with SMTP id d65-v6mr42530860pfg.107.1536182009757; Wed, 05 Sep 2018 14:13:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536182009; cv=none; d=google.com; s=arc-20160816; b=mXKGpo6oEPsOZguIblsQx7Nwy65hYAk3R0fZrMHMwxQ89R5tHnVWKQeM2+DwIbxZkV u9Dv5+HL4pnT+99T6ZyehLCfjYCQscJUAQppzEZh16dofaEo0FrdUxZMfdqOWHzzn+x+ fJQNOwR9+BlCP5bz2aBG2+jQ9a1sGWaxRyEcdXsgga4fIECo4jFywKYJCzNWb5euZ5xu 1JIMblje+BeBeHzS6E2gl8uS9nPnnPW45gw+9Tsq+tR0WnpsF8Hq/WeunFW7e4y44Xa0 pjBr0ezswTkAUJc5BPRVzl7TQBjPF0fXmKRql6x1+QexQ8OSCTPGtRv/EbJXiFbrk/RC trhw== 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=FFB08YKorxcOMOwUtMi0I35BA7p13x7BDsSY6WAe3AI=; b=KSBTvv51CPs97cT9XjiKTUo5uXELz5qIJRY+cjgmPwE5gHU1FflWCSYn/+cHJvG22k JayCSm5WYecMRImxQEKQjp1iiJvAX3G8FccbIx7T+hwigoXyQu6Ce0SxBdaCiFLQFCnA 8qCyJjxO/bMi44tS4NqELzV0J3MQjRkcOVWLunS3rTl8CYULqcRmpTJ5jz7zPZbF2UMv Kks4orX8fcBvJ+ueaN2zJAhWsb5kAXFAd7JQz2SqSi0kG0bVb+gawHRvEcD1x86vNMu0 lsTTYZE1HfEM2LB7ypC/PvbkXibDJZPM4hXT6ApmFSQcUXyuPYwGomeuPYOUzmnhSHNV l99w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="DdtLF/87"; 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 61-v6sor869371plz.2.2018.09.05.14.13.29 for (Google Transport Security); Wed, 05 Sep 2018 14:13:29 -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="DdtLF/87"; 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=FFB08YKorxcOMOwUtMi0I35BA7p13x7BDsSY6WAe3AI=; b=DdtLF/87vAOXPUTUfEcTfx2b2IglcVvadCSny53Kc9sSV52xzfZh0E+ZHHet2VuAqK hP5R+XpigMxTmZsuYyarck55nfJJZEWKH3RqqKxto0fpnqyUJtOguCSX9btcwVNQlqoq 7Y444rlBrdR+4RVH9ifTCKwhQW0vgF7hdyJyNHdIH6WqXodrU5iYjbczT8eTPLytqkrA /NBjL+UL07iobWxnD/zTXafppmH/jQCYD0mwOAI6nUTARE3tbH+OHEq+WJK218M9NcaA IE3RsLwpzsTRoVH9N5YTV6L36tvbbEqVTiJOFZIGRoZ4l2Gv7u8I5XYM8069fIhYK4gS IE3w== X-Google-Smtp-Source: ANB0VdaP0uEFD0vUxKoZqr+MtSqk6mL/WLLyi+Nu7jfIFrinCMKXFzFyLQVGINzRzAMYlimlflyoiA== X-Received: by 2002:a17:902:598d:: with SMTP id p13-v6mr18229562pli.171.1536182009350; Wed, 05 Sep 2018 14:13:29 -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 74-v6sm4307213pfv.33.2018.09.05.14.13.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 05 Sep 2018 14:13:28 -0700 (PDT) Subject: [PATCH v2 1/2] mm: Move page struct poisoning to CONFIG_DEBUG_VM_PAGE_INIT_POISON 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:28 -0700 Message-ID: <20180905211328.3286.71674.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 On systems with a large amount of memory it can take a significant amount of time to initialize all of the page structs with the PAGE_POISON_PATTERN value. I have seen it take over 2 minutes to initialize a system with over 12GB of RAM. In order to work around the issue I had to disable CONFIG_DEBUG_VM and then the boot time returned to something much more reasonable as the arch_add_memory call completed in milliseconds versus seconds. However in doing that I had to disable all of the other VM debugging on the system. Instead of keeping the value in CONFIG_DEBUG_VM I am adding a new CONFIG value called CONFIG_DEBUG_VM_PAGE_INIT_POISON that will control the page poisoning independent of the CONFIG_DEBUG_VM option. Signed-off-by: Alexander Duyck --- include/linux/page-flags.h | 8 ++++++++ lib/Kconfig.debug | 14 ++++++++++++++ mm/memblock.c | 5 ++--- mm/sparse.c | 4 +--- 4 files changed, 25 insertions(+), 6 deletions(-) diff --git a/include/linux/page-flags.h b/include/linux/page-flags.h index 74bee8cecf4c..0e95ca63375a 100644 --- a/include/linux/page-flags.h +++ b/include/linux/page-flags.h @@ -13,6 +13,7 @@ #include #include #endif /* !__GENERATING_BOUNDS_H */ +#include /* * Various page->flags bits: @@ -162,6 +163,13 @@ static inline int PagePoisoned(const struct page *page) return page->flags == PAGE_POISON_PATTERN; } +static inline void page_init_poison(struct page *page, size_t size) +{ +#ifdef CONFIG_DEBUG_VM_PAGE_INIT_POISON + memset(page, PAGE_POISON_PATTERN, size); +#endif +} + /* * Page flags policies wrt compound pages * diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug index 613316724c6a..3b1277c52fed 100644 --- a/lib/Kconfig.debug +++ b/lib/Kconfig.debug @@ -637,6 +637,20 @@ config DEBUG_VM_PGFLAGS If unsure, say N. +config DEBUG_VM_PAGE_INIT_POISON + bool "Enable early page metadata poisoning" + default y + depends on DEBUG_VM + help + Seed the page metadata with a poison pattern to improve the + likelihood of detecting attempts to access the page prior to + initialization by the memory subsystem. + + This initialization can result in a longer boot time for systems + with a large amount of memory. + + If unsure, say Y. + config ARCH_HAS_DEBUG_VIRTUAL bool diff --git a/mm/memblock.c b/mm/memblock.c index 237944479d25..a85315083b5a 100644 --- a/mm/memblock.c +++ b/mm/memblock.c @@ -1444,10 +1444,9 @@ void * __init memblock_virt_alloc_try_nid_raw( ptr = memblock_virt_alloc_internal(size, align, min_addr, max_addr, nid); -#ifdef CONFIG_DEBUG_VM if (ptr && size > 0) - memset(ptr, PAGE_POISON_PATTERN, size); -#endif + page_init_poison(ptr, size); + return ptr; } diff --git a/mm/sparse.c b/mm/sparse.c index 10b07eea9a6e..67ad061f7fb8 100644 --- a/mm/sparse.c +++ b/mm/sparse.c @@ -696,13 +696,11 @@ int __meminit sparse_add_one_section(struct pglist_data *pgdat, goto out; } -#ifdef CONFIG_DEBUG_VM /* * Poison uninitialized struct pages in order to catch invalid flags * combinations. */ - memset(memmap, PAGE_POISON_PATTERN, sizeof(struct page) * PAGES_PER_SECTION); -#endif + page_init_poison(memmap, sizeof(struct page) * PAGES_PER_SECTION); section_mark_present(ms); sparse_init_one_section(ms, section_nr, memmap, usemap); 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