Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp2963995imm; Tue, 4 Sep 2018 12:56:52 -0700 (PDT) X-Google-Smtp-Source: ANB0VdZP+NDx1JZJsF6SKG3dMHy6c9xk24+oGyc0MHamk9GmJwnIVEMu0E0xy4uvoOZQyeIVx4Km X-Received: by 2002:a62:ed5:: with SMTP id 82-v6mr36235786pfo.198.1536091012148; Tue, 04 Sep 2018 12:56:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536091012; cv=none; d=google.com; s=arc-20160816; b=L4ZIyF+2zzNp82z23mA9RH8SqLXP0GQVhm8p08kqPHpavJOijdArQl+ArBrbigsjhW 4w4w17aHcUkAcpRgGnclGnKRgVzHPtx0BPE+B65ZTruHCPwKr26rRRTWfMJQvDaYzDSu /vY3UdCmkH0ArcpXi2nGc61o4m5Iq6Q75pHZl5tQgQfZkyfzZGyNjQo+gwPbccM5dt1u W/AizULGtYYFW7d079jLT1hMzWOZhjnJPYBkptGjUvO4sUCi3LMcwwffgt2YQr57xHyR xZ7XwBHQ+nLIsXfYyEJpH8MGWZL6xTEztdc46hW8XQyaDHIr1P2yi34PMQ0eR2/kPCTu Nayg== 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 :arc-authentication-results; bh=qlvMIbwcpPiVoUXhiuxxOLJeEXDCxHM0YBWuKTE8niQ=; b=GY4xaUNEtDd5d73Y9vnnkqqBrbw8ChQOFhizTHPxeofEGDqQJBicqjCFXTIzBM4mWj enD/In90b8Wr73kI+tFduJgCSxqFmof2mbV0O1pMhcNvhIHU6+Ci4LleIk4XxYtvYuGq xyzDlfZBPRfVbfwZNdPG4gJ/xrB6uNwsWcwEB9A350Fp/xVRN0Lj5l9du22PfhnCv9nD IpyeFayRKH2suxPhQ7qVQ03StDMwRcMYQ5ERAkJYF3gy6u2XF9rK+ChpaEGCwS1A4L9P r0qfZhp7iuhjTg+kUjJ8oAdzz7hocP21dob/J3+n9nBlem/IR6/PIdcRUVCH4tB1nHSq gmVQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=roQK0eBZ; 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 y25-v6si20652663pga.39.2018.09.04.12.56.36; Tue, 04 Sep 2018 12:56:52 -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=roQK0eBZ; 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 S1728277AbeIEAVm (ORCPT + 99 others); Tue, 4 Sep 2018 20:21:42 -0400 Received: from mail-it0-f66.google.com ([209.85.214.66]:53707 "EHLO mail-it0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727220AbeIEAVk (ORCPT ); Tue, 4 Sep 2018 20:21:40 -0400 Received: by mail-it0-f66.google.com with SMTP id p79-v6so6736796itp.3 for ; Tue, 04 Sep 2018 12:55:03 -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=qlvMIbwcpPiVoUXhiuxxOLJeEXDCxHM0YBWuKTE8niQ=; b=roQK0eBZsv6Sgn6rXJWAlEyKZxpl4Ze85pZ25ChMd2h/Hn6ba2GhhAedjuOpdMLYJY +W+33L/+1OO5Ia3x04n+mu7zLZL+eVAzYfC+5D8sVUoRdZL4v5+TwnxD9t9a5YIc2CMc Cc2FZnJaqeOvdevWnUON73XCPlR1rAqvydJIjP7Xk1EafqsHsbYNkvyxD/yyZ5TusWxd BLKZDEKt30MoZ0+vzp73CwUX90KjfFcBapIs7SM4fqV1KpdumbzDkv2893ux3Yu9nEaD D7QqVUzgmtbC3X9AoDtmutDK69VImVIgZ721tj+JOPkHfwEJC2/JQh6WcHmjlUV99Bum gueA== 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=qlvMIbwcpPiVoUXhiuxxOLJeEXDCxHM0YBWuKTE8niQ=; b=L1t0nBOYVAJN5y64fn/dK6eB8iEI5v6NJFmj6X0Rdc+IvR0p2ozBU8+aTLlrO1axJI lIOPmozvuKyriliCA0LM7tJuTvr/S2ewyMSKxdGwZ44socWIiMOHY6GmgHNvafSbYp8n lZ7hZ+vHZcqNy5aHspTvxXajXz0pqQVvcYTzlZvXYSCtg7MXMBmXjE/llhHByg1icm+J WwFpE/umnLI7wFHCUxQZxIjKbr1sf4JRbvfxFids/p/lFlKmigAxRS8cF5YSh0yfUnw4 jjGtsIOEb0FUvX6TEMdVr/YReAkEvfps1ca9dacl7KJDqQuS1MtB4E4wJUC8peIN5MXX qN/g== X-Gm-Message-State: APzg51AHK/xkOw/oBH5UY677RXuVcdHKQFHDbkP/DxbQkzeF6Mqb9zxO fzV/sxH7npjIqsHSf/CP33gP0zYqROt8jDUVQAU= X-Received: by 2002:a24:918d:: with SMTP id i135-v6mr1482904ite.98.1536090902544; Tue, 04 Sep 2018 12:55:02 -0700 (PDT) MIME-Version: 1.0 References: <20180904181550.4416.50701.stgit@localhost.localdomain> <20180904183339.4416.44582.stgit@localhost.localdomain> In-Reply-To: From: Alexander Duyck Date: Tue, 4 Sep 2018 12:54:50 -0700 Message-ID: Subject: Re: [PATCH 1/2] mm: Move page struct poisoning from CONFIG_DEBUG_VM to CONFIG_DEBUG_VM_PGFLAGS To: Dave Hansen Cc: linux-mm , LKML , "Duyck, Alexander H" , pavel.tatashin@microsoft.com, Michal Hocko , 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 Tue, Sep 4, 2018 at 12:25 PM Dave Hansen wrote: > > On 09/04/2018 11:33 AM, Alexander Duyck wrote: > > --- a/mm/memblock.c > > +++ b/mm/memblock.c > > @@ -1444,7 +1444,7 @@ void * __init memblock_virt_alloc_try_nid_raw( > > > > ptr = memblock_virt_alloc_internal(size, align, > > min_addr, max_addr, nid); > > -#ifdef CONFIG_DEBUG_VM > > +#ifdef CONFIG_DEBUG_VM_PGFLAGS > > if (ptr && size > 0) > > memset(ptr, PAGE_POISON_PATTERN, size); > > #endif > > diff --git a/mm/sparse.c b/mm/sparse.c > > index 10b07eea9a6e..0fd9ad5021b0 100644 > > --- a/mm/sparse.c > > +++ b/mm/sparse.c > > @@ -696,7 +696,7 @@ int __meminit sparse_add_one_section(struct pglist_data *pgdat, > > goto out; > > } > > > > -#ifdef CONFIG_DEBUG_VM > > +#ifdef CONFIG_DEBUG_VM_PGFLAGS > > /* > > * Poison uninitialized struct pages in order to catch invalid flags > > * combinations. > > I think this is the wrong way to do this. It keeps the setting and > checking still rather tenuously connected. If you were to leave it this > way, it needs commenting. It's also rather odd that we're memsetting > the entire 'struct page' for a config option that's supposedly dealing > with page->flags. That deserves _some_ addressing in a comment or > changelog. > > How about: > > #ifdef CONFIG_DEBUG_VM_PGFLAGS > #define VM_BUG_ON_PGFLAGS(cond, page) VM_BUG_ON_PAGE(cond, page) > +static inline void poison_struct_pages(struct page *pages, int nr) > +{ > + memset(pages, PAGE_POISON_PATTERN, size * sizeof(...)); > +} > #else > #define VM_BUG_ON_PGFLAGS(cond, page) BUILD_BUG_ON_INVALID(cond) > static inline void poison_struct_pages(struct page *pages, int nr) {} > #endif > > That puts the setting and checking in one spot, and also removes a > couple of #ifdefs from .c files. So the only issue with this is the fact that the code here is wrapped in a check for CONFIG_DEBUG_VM, so if that isn't defined we end up with build errors. If the goal is to consolidate things I could probably look at adding a function in include/linux/page-flags.h, probably next to PagePoisoned. I could then probably just look at wrapping the memset call itself with the CONFIG_DEBUG_VM_PGFLAGS instead of the entire function. I could then place some code documentation in there explaining why it is wrapped. - Alex