Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp2510460imm; Mon, 16 Jul 2018 09:10:51 -0700 (PDT) X-Google-Smtp-Source: AAOMgpfKZ+yML6NqGW1A81C3xh3dUJpXx+dHbWZHEHf2CP+aiYSFSuyQ7M1DzWcTZDx/XQRT+OpC X-Received: by 2002:a63:1f20:: with SMTP id f32-v6mr622342pgf.84.1531757451139; Mon, 16 Jul 2018 09:10:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531757451; cv=none; d=google.com; s=arc-20160816; b=q/GMB4+lf67QI0QE0whfL2eic2ykVfeyNzLCYZpQGFmPFXp7XrGptv7qshrdSv8Ufw n/Jz0PCGl7954hnkWqD6xgzSmOy/q4kFBfITokrYs0wIY4u8YJtaR2fOc+kWmjEVcNG6 tC3QrcDrWiMxWZ8ttH1gQBpHV41o+gykt/mQaMmN4dq7LoGDmqE3Ibx9I357x4i/moqH dK8W/CdIUzYmW1r3FKPfFt81xnA2vT4ZCcfJae4FmW4isqdF+JgemwNRujP8FZiFKZ+T 4MczQpv+wNA4eDOkA3dhF3nM2934cU7HL39953UjJnrHVFhjCEsnrT3B60fWBoFxXQlO 7Ugg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:arc-authentication-results; bh=j6hmvVoJDgTuqWSKs5JazTjhBNtGmVUTR0tR9cW5Mj0=; b=Jvzhu/QXK/2XPZ45R5aOjUOlqdtbKE0x1CQqElD3RR3/dsjaruTTH2Scw/ZmRxbSWI Sj3gfhgsmtaQEhrm36w0ZSZbAp9liEdYR1AyxIwNjYocD5syKs9QVStx0XfsMJCDqsEY CjVxTxiD8AzwuivgbdM01UqWDq6zDE+AezKRjtXqolkomPxgKBgzcEYKQGWdqaw30lNL 9+3dE/vETnsIsFfYGF4M+B91GOj79z164/sdPE2SDohPa5e4ATZdRVT6D0x1KLnc8/bY kBZpIT2abv+XCzKAZfo8kZ1TkwVGdUfVRzq8q/KuCRZZ3z81D1xOXWpZ7kSTMJOmAlaq ZnBA== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m1-v6si29522366pge.531.2018.07.16.09.10.36; Mon, 16 Jul 2018 09:10:51 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728466AbeGPQiE (ORCPT + 99 others); Mon, 16 Jul 2018 12:38:04 -0400 Received: from mx2.suse.de ([195.135.220.15]:47640 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727514AbeGPQiE (ORCPT ); Mon, 16 Jul 2018 12:38:04 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id CE95FAF41; Mon, 16 Jul 2018 16:09:57 +0000 (UTC) Date: Mon, 16 Jul 2018 18:09:56 +0200 From: Michal Hocko To: Pavel Tatashin Cc: steven.sistare@oracle.com, daniel.m.jordan@oracle.com, linux-kernel@vger.kernel.org, akpm@linux-foundation.org, kirill.shutemov@linux.intel.com, linux-mm@kvack.org, mgorman@techsingularity.net, torvalds@linux-foundation.org, gregkh@linuxfoundation.org Subject: Re: [PATCH] mm: don't do zero_resv_unavail if memmap is not allocated Message-ID: <20180716160956.GW17280@dhcp22.suse.cz> References: <20180716151630.770-1-pasha.tatashin@oracle.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180716151630.770-1-pasha.tatashin@oracle.com> User-Agent: Mutt/1.10.0 (2018-05-17) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon 16-07-18 11:16:30, Pavel Tatashin wrote: > Moving zero_resv_unavail before memmap_init_zone(), caused a regression on > x86-32. > > The cause is that we access struct pages before they are allocated when > CONFIG_FLAT_NODE_MEM_MAP is used. > > free_area_init_nodes() > zero_resv_unavail() > mm_zero_struct_page(pfn_to_page(pfn)); <- struct page is not alloced > free_area_init_node() > if CONFIG_FLAT_NODE_MEM_MAP > alloc_node_mem_map() > memblock_virt_alloc_node_nopanic() <- struct page alloced here > > On the other hand memblock_virt_alloc_node_nopanic() zeroes all the memory > that it returns, so we do not need to do zero_resv_unavail() here. This all is subtle as hell and almost impossible to build a sane code on top. Your patch sounds good as a stop gap fix but we really need something resembling an actual design rather than ad-hoc hacks piled on top of each other. > Fixes: e181ae0c5db9 ("mm: zero unavailable pages before memmap init") > Signed-off-by: Pavel Tatashin Acked-by: Michal Hocko > --- > include/linux/mm.h | 2 +- > mm/page_alloc.c | 4 ++-- > 2 files changed, 3 insertions(+), 3 deletions(-) > > diff --git a/include/linux/mm.h b/include/linux/mm.h > index a0fbb9ffe380..3982c83fdcbf 100644 > --- a/include/linux/mm.h > +++ b/include/linux/mm.h > @@ -2132,7 +2132,7 @@ extern int __meminit __early_pfn_to_nid(unsigned long pfn, > struct mminit_pfnnid_cache *state); > #endif > > -#ifdef CONFIG_HAVE_MEMBLOCK > +#if defined(CONFIG_HAVE_MEMBLOCK) && !defined(CONFIG_FLAT_NODE_MEM_MAP) > void zero_resv_unavail(void); > #else > static inline void zero_resv_unavail(void) {} > diff --git a/mm/page_alloc.c b/mm/page_alloc.c > index 5d800d61ddb7..a790ef4be74e 100644 > --- a/mm/page_alloc.c > +++ b/mm/page_alloc.c > @@ -6383,7 +6383,7 @@ void __paginginit free_area_init_node(int nid, unsigned long *zones_size, > free_area_init_core(pgdat); > } > > -#ifdef CONFIG_HAVE_MEMBLOCK > +#if defined(CONFIG_HAVE_MEMBLOCK) && !defined(CONFIG_FLAT_NODE_MEM_MAP) > /* > * Only struct pages that are backed by physical memory are zeroed and > * initialized by going through __init_single_page(). But, there are some > @@ -6421,7 +6421,7 @@ void __paginginit zero_resv_unavail(void) > if (pgcnt) > pr_info("Reserved but unavailable: %lld pages", pgcnt); > } > -#endif /* CONFIG_HAVE_MEMBLOCK */ > +#endif /* CONFIG_HAVE_MEMBLOCK && !CONFIG_FLAT_NODE_MEM_MAP */ > > #ifdef CONFIG_HAVE_MEMBLOCK_NODE_MAP > > -- > 2.18.0 > -- Michal Hocko SUSE Labs