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);