From patchwork Mon Sep 10 23:43:41 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Duyck X-Patchwork-Id: 10594907 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 9F1316CB for ; Mon, 10 Sep 2018 23:43:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8D1AC291BB for ; Mon, 10 Sep 2018 23:43:46 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 807A1291F4; Mon, 10 Sep 2018 23:43:46 +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=unavailable 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 07131291BB for ; Mon, 10 Sep 2018 23:43:45 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 040B28E0005; Mon, 10 Sep 2018 19:43:45 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id F0B2D8E0001; Mon, 10 Sep 2018 19:43:44 -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 DD5688E0005; Mon, 10 Sep 2018 19:43:44 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pl1-f199.google.com (mail-pl1-f199.google.com [209.85.214.199]) by kanga.kvack.org (Postfix) with ESMTP id 9A4E98E0001 for ; Mon, 10 Sep 2018 19:43:44 -0400 (EDT) Received: by mail-pl1-f199.google.com with SMTP id 2-v6so10572529plc.11 for ; Mon, 10 Sep 2018 16:43:44 -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=mK1ugpb/LCNhaDTIyoSauvWmhfcRUffOy8mLsBZJR5A=; b=KAYLBnp/KmaK6Rlhr0NBH+u1FUAjeRzC1UEvMu1UfC2jQfVtvPAXWJ8PNueajpxV/i AA8bly06qAc9/eqnZcYeNrHOPRVSwvlbpJHLWFVMgJH92f/GpDx8BxBT97tuacH0ysyR grI2JOM7lm69MQFk9hhKLUHx/7KbK/neg0FQCjKvruhfOYpipwTy3oai3XbGPfQj8Ww5 dZA+1HtsfF4gBleh2waIyGdQPAAPH9ltFua47Rzc36lXjdPXNa8dNdUqTjCsrbYSW9nc Idiifa/XtY7nBOaf4QT3VNowN4QQgMnG99gCoj/Qxn/HENboQMoWsIR3SR0BnJCDpSsb wd9g== X-Gm-Message-State: APzg51CT0hBkT40qDLDl7rg2aIClHO7Ip4UcWws50uPtHS+jXpHAYkGF mwCIn71yG7Z2RpsLoIQV3b7l6nqLMhe8Py7q3byvEoDQBlbCzVxb0+fFQ34XiGjoXB5y9zFAGYO HdfX+KgIzCvH2pKrtsrBdiAa1KcJHdU/0AX2jHzHQ5pEb94cKYPwZHxxoZWS88cm02uuO/TBN65 C0nwfhtDqSmHHI0vvWnTS8tynGujtB0dL7111UfTzXrLNlcmGQcu6j2QZNGWbbwRPeugzn/5wGZ blYRzDYGlgczhgbHtzcQ/xaas89Bx24dITSxaD/i4XrQ0ZQMzbPgq9axb4ZJ523Pz8IjKVr6GJ8 ttT8pP07Ddj/QJx4feSm91rtwBVDUxe/ERzeHT5s7WY+orRG+jc+Lsdj1ONtQkKSH4/1MPI0ldK M X-Received: by 2002:a17:902:1d4a:: with SMTP id u10-v6mr24374607plu.267.1536623024271; Mon, 10 Sep 2018 16:43:44 -0700 (PDT) X-Received: by 2002:a17:902:1d4a:: with SMTP id u10-v6mr24374580plu.267.1536623023411; Mon, 10 Sep 2018 16:43:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536623023; cv=none; d=google.com; s=arc-20160816; b=qmnCWDj5lT8BVaH5DV5VnpxlG8+hEE+ogyz9Xruarp8+o73E1j98NyjgjOf5sfJOMN aP3UCyJkoo53kimQWe5MuMzD+4ZOjocVxvp70fQyjVkt2LstLETSozFP3VFyHr50TMEk s6EIClFYTpqsluXCRZfXE2AY2IKU3ZIMLH6RDYmKB/edrQPmElautGjW3VFIzNBW/RXb LYsSLwrYC5mR/xsX61CH936QWVT61JE/D2iZt/dp2F0KWhO6NGX0LxcdEcZRh+Z2LO8+ KjNSX20bcAV1UxHWsOzpTVhRQ5AdS/mYVFsN9ZYulXV4kmXDTWYZ+hyvu+6ZuR5/OKn2 5dGA== 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=mK1ugpb/LCNhaDTIyoSauvWmhfcRUffOy8mLsBZJR5A=; b=yfB2mVa5h2d5XQlSVKvWWwuHM7EZZHTLrXgxq36DNMaAfegpBsbbzAdFTjBTwVQIau U3QdmJfLKv2oGErkrbp58TfudCUqx8Xwm2E//oybjj+V3PZg7b3x1tmBkZ7OQuQm66ZW 4ds+FrCLavPwyHWKtaxhrSatoKJW1rkO4Ff8aZmIn9HHCoHGMfJB0meWlfh3l/Wmrpp4 JY0/UqJ6Fr8Xcu/BBLmx5K7sTZ85iWkbh5PdhI/9ZKpAu50gr/GNq28z1KVweabVLcz9 Emn21q/SJvwa9xljizO6zNw60xLNzqGHdFCWyOAwkYXxP1Ex/9M+5/fpGqWH+EwQY5Mg Cdow== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=gXMFNcn6; 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 69-v6sor3137841pla.99.2018.09.10.16.43.43 for (Google Transport Security); Mon, 10 Sep 2018 16:43:43 -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=gXMFNcn6; 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=mK1ugpb/LCNhaDTIyoSauvWmhfcRUffOy8mLsBZJR5A=; b=gXMFNcn6Uhsq1Poo1ZFAUqIaW2IbJ/INlomS9949qdQEdHq+HaXa37/FmPUrchHLP9 XsgeeVjxvdF+z/23Or2XnohMb5J1aPlYTfgh8SbJMW+hh7WpRrefoNZ6Pz3bfQTrXJ4D iuc88bA0mRkvfIR7kSBdx2DcQX6dWSd5Yu3I2X6W38GHLys7ka4WnIeQqmFU0vkV6z7H z/QU+FnT7DQZz7Pwpk66ztExDL6eQLrl5xZd0STWmRrUsrppfUPJIJlYb1j68PBtxzHH qeCB2tvhUlhqZ6RP71JTIU0PpoGYdesLPYQ5tYGmQKqc6cdiJr8dQX3oj4TsNlJ2JGEA 9lCA== X-Google-Smtp-Source: ANB0VdaVXpJqV+58IBdRBFehwoJtL+fd7tHuuYHv5Y+GQ65svTqcpB8Q60RFqHEI56PxpPTtNWOn8w== X-Received: by 2002:a17:902:3c5:: with SMTP id d63-v6mr24207713pld.145.1536623022977; Mon, 10 Sep 2018 16:43:42 -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 d12-v6sm24980289pfk.69.2018.09.10.16.43.42 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 10 Sep 2018 16:43:42 -0700 (PDT) Subject: [PATCH 1/4] mm: Provide kernel parameter to allow disabling page init poisoning From: Alexander Duyck To: linux-mm@kvack.org, linux-kernel@vger.kernel.org, linux-nvdimm@lists.01.org Cc: pavel.tatashin@microsoft.com, mhocko@suse.com, dave.jiang@intel.com, mingo@kernel.org, dave.hansen@intel.com, jglisse@redhat.com, akpm@linux-foundation.org, logang@deltatee.com, dan.j.williams@intel.com, kirill.shutemov@linux.intel.com Date: Mon, 10 Sep 2018 16:43:41 -0700 Message-ID: <20180910234341.4068.26882.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-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. In order to work around a kernel that might have CONFIG_DEBUG_VM enabled on a system that has a large amount of memory I have added a new kernel parameter named "page_init_poison" that can be set to "off" in order to disable it. Signed-off-by: Alexander Duyck Reviewed-by: Pavel Tatashin --- Documentation/admin-guide/kernel-parameters.txt | 8 ++++++++ include/linux/page-flags.h | 8 ++++++++ mm/debug.c | 16 ++++++++++++++++ mm/memblock.c | 5 ++--- mm/sparse.c | 4 +--- 5 files changed, 35 insertions(+), 6 deletions(-) diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt index 64a3bf54b974..7b21e0b9c394 100644 --- a/Documentation/admin-guide/kernel-parameters.txt +++ b/Documentation/admin-guide/kernel-parameters.txt @@ -3047,6 +3047,14 @@ off: turn off poisoning (default) on: turn on poisoning + page_init_poison= [KNL] Boot-time parameter changing the + state of poisoning of page structures during early + boot. Used to verify page metadata is not accessed + prior to initialization. Available with + CONFIG_DEBUG_VM=y. + off: turn off poisoning + on: turn on poisoning (default) + panic= [KNL] Kernel behaviour on panic: delay timeout > 0: seconds before rebooting timeout = 0: wait forever diff --git a/include/linux/page-flags.h b/include/linux/page-flags.h index 74bee8cecf4c..d00216cf00f8 100644 --- a/include/linux/page-flags.h +++ b/include/linux/page-flags.h @@ -162,6 +162,14 @@ static inline int PagePoisoned(const struct page *page) return page->flags == PAGE_POISON_PATTERN; } +#ifdef CONFIG_DEBUG_VM +void page_init_poison(struct page *page, size_t size); +#else +static inline void page_init_poison(struct page *page, size_t size) +{ +} +#endif + /* * Page flags policies wrt compound pages * diff --git a/mm/debug.c b/mm/debug.c index 38c926520c97..c5420422c0b5 100644 --- a/mm/debug.c +++ b/mm/debug.c @@ -175,4 +175,20 @@ void dump_mm(const struct mm_struct *mm) ); } +static bool page_init_poisoning __read_mostly = true; + +static int __init page_init_poison_param(char *buf) +{ + if (!buf) + return -EINVAL; + return strtobool(buf, &page_init_poisoning); +} +early_param("page_init_poison", page_init_poison_param); + +void page_init_poison(struct page *page, size_t size) +{ + if (page_init_poisoning) + memset(page, PAGE_POISON_PATTERN, size); +} +EXPORT_SYMBOL_GPL(page_init_poison); #endif /* CONFIG_DEBUG_VM */ 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);