Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp56883imm; Wed, 5 Sep 2018 14:56:30 -0700 (PDT) X-Google-Smtp-Source: ANB0VdY/P8XftOPnZCsSUspOKUSm7DLqZ6WajQ39zwx0yJcbR0N4XgBtRjd36rLJbIHfiLcWAI30 X-Received: by 2002:a62:401:: with SMTP id 1-v6mr42529353pfe.28.1536184590293; Wed, 05 Sep 2018 14:56:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536184590; cv=none; d=google.com; s=arc-20160816; b=XUrbxl7lh05K+tDGqF3yrBN0fOVLZ49pOF19vRGkiH+Ccm8AtbltWjVMXp29+caLsF mstu40/+9iFziX6KqIk3m+tm4tN47b9tZvSmzwp35kb/MIOFgviAx0aenhjyY0/uyoUi T13mWJdqfn0oQjC4lanwBLNeeJNG0qLiGInWVpi0Aa5UBBPEb0SOSCiG8oUm465Aew7i /qwuLS966+XVYSGcY2VwhLDWqq3qdo+ZhnKN0wxQ8e/ZbkxIRVR1MfKsP00o7LnsVt2s tFG9xQInJY8h6CRshKlqf0o94bwL2S4iLnG8MrhgIbbO6BdWUwAy6jGr6d4wa604FtcX 4cng== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=OzSGOPfK5Nz7DruLUyX9lOE5Oj01I9xouOuLccHJTe4=; b=mdL4eTL9k58Sk41py6MMts6BgziXITPhnI8mvP8yRtSxtLi4gZZ2nwOUeNCAdbj0DJ vS2iIvCCFt8KSO/ly753BCKAZNwNR1nZZRtD0fUSDfzQyNIY8viNGdEmnvXKAKhPsw7s e3v/qe0F2kZ/yb83lgZMOL3qZPdPAmZq6fbiAzWUxktf9bDTpUsY5mMkIbmyVm/r4gkW D1hYtZOlKIALNuYojR91LcKW0fouQ3sd3Mw4XhJP3IHjua4+deKl2p3uqpQRTz51S4tv 7yF5TikMfDSSIhXkTSPVTrrW/W9V7ZQVy0+uVE3A05ctFHQ/RX2KS5jMcEQd+yn+vGBU berg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=QC9O9Yt+; 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 p2-v6si3246684pfd.76.2018.09.05.14.56.12; Wed, 05 Sep 2018 14:56:30 -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=QC9O9Yt+; 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 S1727870AbeIFC04 (ORCPT + 99 others); Wed, 5 Sep 2018 22:26:56 -0400 Received: from mail-io0-f195.google.com ([209.85.223.195]:34895 "EHLO mail-io0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727824AbeIFC04 (ORCPT ); Wed, 5 Sep 2018 22:26:56 -0400 Received: by mail-io0-f195.google.com with SMTP id w11-v6so7272775iob.2 for ; Wed, 05 Sep 2018 14:54:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=OzSGOPfK5Nz7DruLUyX9lOE5Oj01I9xouOuLccHJTe4=; b=QC9O9Yt+VS94TqPVKIN5P/IXpZvzckvOnuJ7El2cXaGBJUcm3ThBI9pCgnHa2p+PJb ehN4FU3+UnxnQaO+wgZcP774uCFEijy0yjEZ6Gs389FzZ3BZZHxXvkhMApBagn1tkAkF 5w8B0Zbk1/X380ES7GVrch3YAxdk+ioAQlRiT1MCjftHd6t5sIjDs8wMnWgj+7Dl6+xa Apngj6kqrqEDGgGRf+pLIWK+aaLoofHLf3umNDY9HwoIcz/1CMx8zRQKl/lNrNRNJVcn ZfAanYWxaKvaHH2w2VadZyETq1o16/MkmQOoK8jj6q2kuiWWWcAl1JzkQGKqYzTqajC7 mA+Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=OzSGOPfK5Nz7DruLUyX9lOE5Oj01I9xouOuLccHJTe4=; b=AgK7rKWqinKHehxnLkqZotXyOH1qq9hOrdvkchTz1GrcEbxZqo0IRicvBDuZKu0F+6 jmPo0uks69ai52U/QJogn2DBaAs/lfsoYR18mon0MXmxNM6JHCkeFQs+7aNON00KRZPl U0NwPFOlRMHrb9Ze33kmU5bmsC6zdpYW6axg/j98LzRr113jAMFRDU9Nb2H9Z93mgXYD MyqnuXtCldAcR+NFxa8LOTwJPtHLe4+ErwL9cRWeYDHj9muIkeGfOsNsnCEU0YuFzzEA vJv0d8bhIvAw7es65LKYLzCXHZOBXoBPBwpkfcLCPE5tO2Asm4S2imR/C85BFy8tKPDZ d9eg== X-Gm-Message-State: APzg51CVoVQch1Q6NyUH+4g+C/NoKE/rZaPOmvNNEuyrl/QOwnoC8tBv JMzowfGmKitf+Q64bX4bX9tx5q7/oo2jpgoc8VE= X-Received: by 2002:a6b:5911:: with SMTP id n17-v6mr28175103iob.68.1536184487494; Wed, 05 Sep 2018 14:54:47 -0700 (PDT) MIME-Version: 1.0 References: <20180905211041.3286.19083.stgit@localhost.localdomain> <20180905211328.3286.71674.stgit@localhost.localdomain> <985fe87b-b8f4-de58-ea2a-970cbe51b72d@microsoft.com> In-Reply-To: <985fe87b-b8f4-de58-ea2a-970cbe51b72d@microsoft.com> From: Alexander Duyck Date: Wed, 5 Sep 2018 14:54:35 -0700 Message-ID: Subject: Re: [PATCH v2 1/2] mm: Move page struct poisoning to CONFIG_DEBUG_VM_PAGE_INIT_POISON To: Pavel.Tatashin@microsoft.com Cc: linux-mm , LKML , "Duyck, Alexander H" , Michal Hocko , Dave Hansen , Andrew Morton , Ingo Molnar , "Kirill A. Shutemov" Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Sep 5, 2018 at 2:38 PM Pasha Tatashin wrote: > > > > On 9/5/18 5:29 PM, Alexander Duyck wrote: > > On Wed, Sep 5, 2018 at 2:22 PM Pasha Tatashin > > wrote: > >> > >> > >> > >> On 9/5/18 5:13 PM, Alexander Duyck wrote: > >>> 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. > >> > >> What happens when DEBUG_VM_PGFLAGS = y and > >> DEBUG_VM_PAGE_INIT_POISON = n ? > >> > >> We are testing for pattern that was not set? > >> > >> I think DEBUG_VM_PAGE_INIT_POISON must depend on DEBUG_VM_PGFLAGS instead. > >> > >> Looks good otherwise. > >> > >> Thank you, > >> Pavel > > > > The problem is that I then end up in the same situation I had in the > > last patch where you have to have DEBUG_VM_PGFLAGS on in order to do > > the seeding with poison. > > OK > > > > > I can wrap the bit of code in PagePoisoned to just always return false > > if we didn't set the pattern. I figure there is value to be had for > > running DEBUG_VM_PGFLAGS regardless of the poison check, or > > DEBUG_VM_PAGE_INIT_POISON without the PGFLAGS check. That is why I > > wanted to leave them independent. > > How about: > > Remove "depends on DEBUG_VM", but make DEBUG_VM_PGFLAGS to depend on > both DEBUG_VM and DEBUG_VM_PAGE_INIT_POISON? > > DEBUG_VM_PGFLAGS is already extremely slow, so having this extra > dependency is OK. > > Thank you, > Pavel Why create the extra dependency though? In the case of DEBUG_VM I am doing it so that we can retain the original behavior where enabling DEBUG_VM should enable the poisoning. I want to avoid this just getting disabled by default and want to try to stick to the original behavior as closely as possible unless we want to go in and explicitly turn it off. From what I can tell the original code prior to your changes didn't bother checking for the poison value when testing the page flags. The poison value only applies prior to the page being initialized, so the value add for having it is only so much. It makes more sense to me to have these as two separate config options where enabling both would give you the maximum benefit, but you could test with either one or the other if you so desired. - Alex