Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp24600imm; Wed, 5 Sep 2018 14:15:23 -0700 (PDT) X-Google-Smtp-Source: ANB0VdZDRnbtWDZN8iJutg2yQbrDxbacBECV0UI+3INEWnjIm0km8uGeplcJmJ95tztz06rldhk3 X-Received: by 2002:a62:401:: with SMTP id 1-v6mr42395885pfe.28.1536182123432; Wed, 05 Sep 2018 14:15:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536182123; cv=none; d=google.com; s=arc-20160816; b=qLBRomHj5r//GSpts+MrDdHexRHOBGb+wM2961joc/hWq21p9ua0PkQ7J+xWdthuZj bPoIzgWfEY1hSRZh0TiWm0nqVpHlLf/H2f8uqLyr7nikPzBOuybllioJVANnN475oei6 u9ihxUr17DM8fV0N6dVKZtXKeha5dpZ155aviyElqE9BS+ae4Gb0lywanJZwoefBOqL3 KKz0cWdtfz46GTiXT2NiW/+/1ufw0WirhaXS07FQg9YLGP76MZROqjCCNAKpabvYljnq srAZV176G3lX62+xKycQ/2QMwPo3vaYIMCmD2XwD6TUOkQ1KmkDXzuM4XdrMyRhVZkZ+ lGaQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:cc:to:from :subject:dkim-signature; bh=FFB08YKorxcOMOwUtMi0I35BA7p13x7BDsSY6WAe3AI=; b=tX1KfkxmDrguL0oIKALmoG6kN8/np3NkzZ8Yu2J+WEbNH+ScPl4GlI/E1S1bZtxw3J 9nfhca5j/NEWeHP8GZLLXqumOTeRaGYdbQHM6yA+msjAxsGWKRTodkti1gg2B35BzyiQ RcqTxImA51K7HvZVmrYbNH6+gIa3AFVnTvuzh1n4Xv100wU/DuO1MHNGZJZpmBERXHTs gTcRSaYLizj7p1dtj4lMRe0oxM0lUQYPfgL5BvfZ/+28ipP3VGNt5OWhFTXOvJAS3mB2 4VmiIW3H2vAwH5UWRKJGs2xu9Q3eiRxFPqsQf4MaIkavuVoUR/SmDINSpLc83M/38REh +VDw== 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: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x128-v6si3290086pfd.246.2018.09.05.14.15.07; Wed, 05 Sep 2018 14:15:23 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="DdtLF/87"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727700AbeIFBp3 (ORCPT + 99 others); Wed, 5 Sep 2018 21:45:29 -0400 Received: from mail-pl1-f195.google.com ([209.85.214.195]:42272 "EHLO mail-pl1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727069AbeIFBp2 (ORCPT ); Wed, 5 Sep 2018 21:45:28 -0400 Received: by mail-pl1-f195.google.com with SMTP id g23-v6so3872645plq.9 for ; Wed, 05 Sep 2018 14:13:29 -0700 (PDT) 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-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:from:to:cc:date:message-id:in-reply-to :references:user-agent:mime-version:content-transfer-encoding; bh=FFB08YKorxcOMOwUtMi0I35BA7p13x7BDsSY6WAe3AI=; b=WuQxYveqhMbqYPHoTTBkGiGW6tAVpY0Rg0ExMHrEufSuAfpaOVb4uvw60e1uUL+zzs MTMp+YoRjuv7uI1hO0AkrHVsaP4u4F2Dxrgxkhy+C0Ci25xgllDXDu3B1c79X+VqxKfM wrrwneLfIpF8jb2IVhj5HetWCgb5Lxt+qKl/1Mgz/Fdu16k2WdghycCby3K86sUf/3QZ 5+BYCEwoFsBbVTHVi8/KB+jJQXZ675EAin16/8506QySqzu/OLOAMzh7H96MLrZCufKl kj6tpHmvD4xEDOj+/Ekz5V3sYLXa0yhIpNF2wnSDe6FsWhD6maRt75rmR291oJRZpOko rCeA== X-Gm-Message-State: APzg51Ab9AIdtuL6sR6Dq/pOixXvBjqxqBsuThfPElR36lv2YEy4Q/a8 AOFSdl6RLDwWbH1gZj5Hadg= 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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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);