From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-io1-f70.google.com (mail-io1-f70.google.com [209.85.166.70]) by kanga.kvack.org (Postfix) with ESMTP id F1EFD6B052F for ; Wed, 7 Nov 2018 12:39:05 -0500 (EST) Received: by mail-io1-f70.google.com with SMTP id c17-v6so20122147ioi.15 for ; Wed, 07 Nov 2018 09:39:05 -0800 (PST) Received: from ale.deltatee.com (ale.deltatee.com. [207.54.116.67]) by mx.google.com with ESMTPS id y140-v6si952453iof.56.2018.11.07.09.39.04 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 07 Nov 2018 09:39:04 -0800 (PST) From: Logan Gunthorpe Date: Wed, 7 Nov 2018 10:38:59 -0700 Message-Id: <20181107173859.24096-3-logang@deltatee.com> In-Reply-To: <20181107173859.24096-1-logang@deltatee.com> References: <20181107173859.24096-1-logang@deltatee.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [PATCH 2/2] mm/sparse: add common helper to mark all memblocks present Sender: owner-linux-mm@kvack.org List-ID: To: linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-arch@vger.kernel.org, linux-riscv@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-sh@vger.kernel.org, Andrew Morton Cc: Stephen Bates , Palmer Dabbelt , Albert Ou , Christoph Hellwig , Arnd Bergmann , Logan Gunthorpe , Michal Hocko , Vlastimil Babka , Oscar Salvador Presently the arches arm64, arm and sh have a function which loops through each memblock and calls memory present. riscv will require a similar function. Introduce a common memblocks_present() function that can be used by all the arches. Subsequent patches will cleanup the arches that make use of this. Signed-off-by: Logan Gunthorpe Cc: Andrew Morton Cc: Michal Hocko Cc: Vlastimil Babka Cc: Oscar Salvador --- include/linux/mmzone.h | 6 ++++++ mm/sparse.c | 11 +++++++++++ 2 files changed, 17 insertions(+) diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h index 847705a6d0ec..db023a92f3a4 100644 --- a/include/linux/mmzone.h +++ b/include/linux/mmzone.h @@ -783,6 +783,12 @@ void memory_present(int nid, unsigned long start, unsigned long end); static inline void memory_present(int nid, unsigned long start, unsigned long end) {} #endif +#if defined(CONFIG_SPARSEMEM) +void memblocks_present(void); +#else +static inline void memblocks_present(void) {} +#endif + #ifdef CONFIG_HAVE_MEMORYLESS_NODES int local_memory_node(int node_id); #else diff --git a/mm/sparse.c b/mm/sparse.c index 33307fc05c4d..5841e4ad6d93 100644 --- a/mm/sparse.c +++ b/mm/sparse.c @@ -239,6 +239,17 @@ void __init memory_present(int nid, unsigned long start, unsigned long end) } } +void __init memblocks_present(void) +{ + struct memblock_region *reg; + + for_each_memblock(memory, reg) { + memory_present(memblock_get_region_node(reg), + memblock_region_memory_base_pfn(reg), + memblock_region_memory_end_pfn(reg)); + } +} + /* * Subtle, we encode the real pfn into the mem_map such that * the identity pfn - section_mem_map will return the actual -- 2.19.0