From patchwork Thu Sep 20 22:26:36 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Duyck X-Patchwork-Id: 10608801 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 4C6F915E8 for ; Thu, 20 Sep 2018 22:26:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3E0402DEFC for ; Thu, 20 Sep 2018 22:26:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 31E042DF14; Thu, 20 Sep 2018 22:26:57 +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.9 required=2.0 tests=BAYES_00,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 A08772DEFC for ; Thu, 20 Sep 2018 22:26:56 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 63E8A8E0003; Thu, 20 Sep 2018 18:26:54 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 5EC688E0001; Thu, 20 Sep 2018 18:26:54 -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 4DCD18E0003; Thu, 20 Sep 2018 18:26:54 -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 0BF278E0001 for ; Thu, 20 Sep 2018 18:26:54 -0400 (EDT) Received: by mail-pf1-f197.google.com with SMTP id b69-v6so5438806pfc.20 for ; Thu, 20 Sep 2018 15:26:54 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:subject:from :to:cc:date:message-id:in-reply-to:references:user-agent :mime-version:content-transfer-encoding; bh=j6g+gX5p29AHCR+jAj2W2G6ghXucCVUNEUSc4EVcWrk=; b=lGwt1K70zVcmd8v9mnjY4mclZiMEo7IUW4bAVfqW3gjVTo0Oo//CfilJO1xv2v/UW3 EYDL6wzP9XfSlNN3WW7ZsPadAtpB3OTEA7+ynuo4e0LtvxK4lC7BK8DaCmEDXTdb95/L bEr80oTwujwJXXEDYIfeFQfRzU1WBYt+H6lRUkD/xS1PeV0/UT2+Lv9nqgWgRWY1T1hY X0nRnD5QcbruUeRwK340VuedJ0X471oP+BKgb/sRA6vM6ZUiKrC1H89f8NwYZlbTI8wv lXISy/l6anv24GghCli2mbWISCtTBJ07o+/miFVyz7dpT1wc7dPcd7K+REpvz+YIrF2F PCdQ== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of alexander.h.duyck@linux.intel.com designates 192.55.52.136 as permitted sender) smtp.mailfrom=alexander.h.duyck@linux.intel.com; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com X-Gm-Message-State: APzg51A9fIPLv0yzLspxlLpnD+yyLlVk3PMtY+LPnpKWOBMffHeDMMz5 Wwz28mAWhcyZInck7zUrAOvLc9XeCuMxFm1PY/MUnQ1cGjbLGiT1bRYHJ975yg0lQNVoo5xIFgw y1r8VZlhyJRHwT9wRfeuc9+/fhJ48uL+5DTmJX05b5lGL4Zr8VTAd9PIlCaBljWoegA== X-Received: by 2002:a17:902:280a:: with SMTP id e10-v6mr41299456plb.187.1537482413711; Thu, 20 Sep 2018 15:26:53 -0700 (PDT) X-Google-Smtp-Source: ANB0VdYpx4cgqJXRQdYM/ogccG/Bu/1zbIEmWwIJpNlr8H3UJ9MaRDPUBFowreU5/EASogBL/h8C X-Received: by 2002:a17:902:280a:: with SMTP id e10-v6mr41299416plb.187.1537482412629; Thu, 20 Sep 2018 15:26:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537482412; cv=none; d=google.com; s=arc-20160816; b=grDZb/9fWW+JGJdfMrL46dR4I6KNc+J2ivvi32P4dv2rHeG5h+ZvpApPtzZE6rqkl0 J/4ZB/wgQMr4ZlPLdXnH20Fh2JNvU/J4KHnW5wRfFgWnIOqN4CGQXeB++lODePFJb9vs YUxrsWH/TIObt4N6FU6JnctpqImyhBQHLUjQ2oybqMAzPt7sfFstZ+ImP5sWN9Xn52Jl hRbpdlr1e/TZfSPq6Nb6u7Qx2dCPQ2waL/8iOdZNLj72uJGMSPAcroqPKp7BPxddm4ya iJrXBkNshQR6+8p2SFprEmaTb6AgKv55Sd3i/G+mUJbP+5D2KJAn0DSh/Jh4eOzTEqBN TujA== 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; bh=j6g+gX5p29AHCR+jAj2W2G6ghXucCVUNEUSc4EVcWrk=; b=akyMBHBMQH2QfZg/usYtmK9YVWOjigrIcv10h9Ry+mD2i9QGec0KKxc0AEW1TBDFjN UPIcvTYrOMzMX2RwO0eDFyXnjcF5U2OD0Lq8015dq2UtLEf4bEo2DCY28gMO+GF/SvVF JgVKUEPkXU76+KvBmcGVOvrdq3x7k+27n/4C4P37RuL9xsI8H//yD2I9IRRGQhgz7dv9 SldvapHLVu+6kED9E7WQauiv9XW6IgOE00NOvEIom10xQoWCp5zoxPwRTFihSGO7KN/a wDjRZoiRCM/tC55BPnOImdDXFWIXEZxMt6ueD1+jWigCH6POmcUXo7+YRbBL3xZZlKjG Z3HA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of alexander.h.duyck@linux.intel.com designates 192.55.52.136 as permitted sender) smtp.mailfrom=alexander.h.duyck@linux.intel.com; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from mga12.intel.com (mga12.intel.com. [192.55.52.136]) by mx.google.com with ESMTPS id w1-v6si25923139pgt.629.2018.09.20.15.26.52 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 20 Sep 2018 15:26:52 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of alexander.h.duyck@linux.intel.com designates 192.55.52.136 as permitted sender) client-ip=192.55.52.136; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of alexander.h.duyck@linux.intel.com designates 192.55.52.136 as permitted sender) smtp.mailfrom=alexander.h.duyck@linux.intel.com; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga106.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 20 Sep 2018 15:26:51 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.54,282,1534834800"; d="scan'208";a="85285550" Received: from ahduyck-mobl.amr.corp.intel.com (HELO localhost.localdomain) ([10.7.198.152]) by orsmga003.jf.intel.com with ESMTP; 20 Sep 2018 15:26:36 -0700 Subject: [PATCH v4 1/5] 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: Thu, 20 Sep 2018 15:26:36 -0700 Message-ID: <20180920222415.19464.38400.stgit@localhost.localdomain> In-Reply-To: <20180920215824.19464.8884.stgit@localhost.localdomain> References: <20180920215824.19464.8884.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 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 12TB 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 "vm_debug" that can be set to "-" in order to disable it. Signed-off-by: Alexander Duyck Reviewed-by: Pavel Tatashin --- v3: Switched from kernel config option to parameter v4: Added comment to parameter handler to record when option is disabled Updated parameter description based on feedback from Michal Hocko Fixed GB vs TB typo in patch description. Switch to vm_debug option similar to slub_debug Documentation/admin-guide/kernel-parameters.txt | 12 ++++++ include/linux/page-flags.h | 8 ++++ mm/debug.c | 46 +++++++++++++++++++++++ mm/memblock.c | 5 +-- mm/sparse.c | 4 +- 5 files changed, 69 insertions(+), 6 deletions(-) diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt index dfe3d7b99abf..ee257b5b584f 100644 --- a/Documentation/admin-guide/kernel-parameters.txt +++ b/Documentation/admin-guide/kernel-parameters.txt @@ -4811,6 +4811,18 @@ This is actually a boot loader parameter; the value is passed to the kernel using a special protocol. + vm_debug[=options] [KNL] Available with CONFIG_DEBUG_VM=y. + May slow down system boot speed, especially when + enabled on systems with a large amount of memory. + All options are enabled by default, and this + interface is meant to allow for selectively + enabling or disabling specific virtual memory + debugging features. + + Available options are: + P Enable page structure init time poisoning + - Disable all of the above options + vmalloc=nn[KMG] [KNL,BOOT] Forces the vmalloc area to have an exact size of . This can be used to increase the minimum size (128MB on x86). It can also be used to diff --git a/include/linux/page-flags.h b/include/linux/page-flags.h index 4d99504f6496..934f91ef3f54 100644 --- a/include/linux/page-flags.h +++ b/include/linux/page-flags.h @@ -163,6 +163,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 bd10aad8539a..cdacba12e09a 100644 --- a/mm/debug.c +++ b/mm/debug.c @@ -13,6 +13,7 @@ #include #include #include +#include #include "internal.h" @@ -175,4 +176,49 @@ void dump_mm(const struct mm_struct *mm) ); } +static bool page_init_poisoning __read_mostly = true; + +static int __init setup_vm_debug(char *str) +{ + bool __page_init_poisoning = true; + + /* + * Calling vm_debug with no arguments is equivalent to requesting + * to enable all debugging options we can control. + */ + if (*str++ != '=' || !*str) + goto out; + + __page_init_poisoning = false; + if (*str == '-') + goto out; + + while (*str) { + switch (tolower(*str)) { + case'p': + __page_init_poisoning = true; + break; + default: + pr_err("vm_debug option '%c' unknown. skipped\n", + *str); + } + + str++; + } +out: + if (page_init_poisoning && !__page_init_poisoning) + pr_warn("Page struct poisoning disabled by kernel command line option 'vm_debug'\n"); + + page_init_poisoning = __page_init_poisoning; + + return 1; +} +__setup("vm_debug", setup_vm_debug); + +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 f7981098537b..b1017ec1b167 100644 --- a/mm/memblock.c +++ b/mm/memblock.c @@ -1495,10 +1495,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);