Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp56244imu; Wed, 7 Nov 2018 12:55:43 -0800 (PST) X-Google-Smtp-Source: AJdET5c9Of7+nmJPaYtz33kcNc5wr6ZAub4zuOailVIjXwC/I3zFgQZV/v/45M4badYpNQ0vDJ1+ X-Received: by 2002:a62:678a:: with SMTP id t10-v6mr1786250pfj.139.1541624143829; Wed, 07 Nov 2018 12:55:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541624143; cv=none; d=google.com; s=arc-20160816; b=D01jTyCEFvhUst5bcreeLlTBYggfFUufvykGs+K+sFiv+jgfl2zJXvUlDfQS4QWjau f6Br1EwqPmed/QiM/CncCJU9NeeLSS6pEyL+fRo5RD7cR0XQ0jdBkhRt4Af3N7T14qGw sFHebHDsafiAddDqO/KThl6x/293lPtUbMHGn/k5CavL+vDPGckptVacBJS5vpGpf4re QaQ4hKosY3NYC9miBWFVTVl0hJM+aCtedSBypICTenoJ8A9fHT+tTkJzDYmVePfvZ6ay qrB5f2X5dcfgf292qvikjwW+5BE27wMt3B2kemvX8A739W5LZS97PRt9g/akwb8BOBjQ 14jw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:subject:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:cc:to:from; bh=EkFCSae6iKJXGDcMb8cjAsUlI5kGVVrCG3uHoZ2SD4E=; b=Q4VjwOGxGN3z+bMceLfZLyaVWCxH4PsYmN+av44e7bfZfLrMp6P2+fYA8mguLTHHKx EaJWF7Nyvh4TH2v/CEt0Z8aq1N8OhIPwTGYLnnZknAY9IksbwouxJR413u6dh2l+PjQr 0eLgPdpi2/Xctg83e/eJHyihv5KQs3ajT/dAGyypUDFOFAY/a4qMRqJW4iyabrZu9eBa iSiFnv6TSh63Kob/4Lm9+pL7NNT1dE234I9WkCEiVXWAoP4COHpGv9T0eqgzbuV7gxRE gOLs1ot1KriU+VJoduqDdL0+nWzN8eJBd7MkGHdp3XcL2IltLIvYv9rjcMpeqfxMdDJi 2N6g== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a17-v6si1611945pgf.443.2018.11.07.12.55.29; Wed, 07 Nov 2018 12:55:43 -0800 (PST) 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727249AbeKHG0r (ORCPT + 99 others); Thu, 8 Nov 2018 01:26:47 -0500 Received: from ale.deltatee.com ([207.54.116.67]:49882 "EHLO ale.deltatee.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726583AbeKHG0p (ORCPT ); Thu, 8 Nov 2018 01:26:45 -0500 Received: from cgy1-donard.priv.deltatee.com ([172.16.1.31]) by ale.deltatee.com with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1gKUqS-0005zI-Dz; Wed, 07 Nov 2018 13:54:37 -0700 Received: from gunthorp by cgy1-donard.priv.deltatee.com with local (Exim 4.89) (envelope-from ) id 1gKUqQ-00011K-Ij; Wed, 07 Nov 2018 13:54:34 -0700 From: Logan Gunthorpe 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 Date: Wed, 7 Nov 2018 13:54:33 -0700 Message-Id: <20181107205433.3875-3-logang@deltatee.com> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20181107205433.3875-1-logang@deltatee.com> References: <20181107205433.3875-1-logang@deltatee.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SA-Exim-Connect-IP: 172.16.1.31 X-SA-Exim-Rcpt-To: linux-mm@kvack.org, linux-riscv@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org, linux-sh@vger.kernel.org, akpm@linux-foundation.org, sbates@raithlin.com, palmer@sifive.com, aou@eecs.berkeley.edu, hch@lst.de, arnd@arndb.de, logang@deltatee.com, mhocko@suse.com, vbabka@suse.cz, osalvador@suse.de X-SA-Exim-Mail-From: gunthorp@deltatee.com X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on ale.deltatee.com X-Spam-Level: X-Spam-Status: No, score=-8.7 required=5.0 tests=ALL_TRUSTED,BAYES_00, GREYLIST_ISWHITE,MYRULES_NO_TEXT autolearn=ham autolearn_force=no version=3.4.1 Subject: [PATCH v2 2/2] mm/sparse: add common helper to mark all memblocks present X-SA-Exim-Version: 4.2.1 (built Tue, 02 Aug 2016 21:08:31 +0000) X-SA-Exim-Scanned: Yes (on ale.deltatee.com) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 Acked-by: Andrew Morton Cc: Michal Hocko Cc: Vlastimil Babka Cc: Oscar Salvador --- include/linux/mmzone.h | 6 ++++++ mm/sparse.c | 16 ++++++++++++++++ 2 files changed, 22 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..3abc8cc50201 100644 --- a/mm/sparse.c +++ b/mm/sparse.c @@ -239,6 +239,22 @@ void __init memory_present(int nid, unsigned long start, unsigned long end) } } +/* + * Mark all memblocks as present using memory_present(). This is a + * convienence function that is useful for a number of arches + * to mark all of the systems memory as present during initialization. + */ +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