Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp4219746imm; Mon, 15 Oct 2018 11:00:12 -0700 (PDT) X-Google-Smtp-Source: ACcGV63N85EJELgpxT6IXXW/YJ5oCM1YxgjoJaMC5tqSz7SykToH1wnGvkSnhp2RF2Fv1tl4RCuA X-Received: by 2002:a62:ea03:: with SMTP id t3-v6mr19221235pfh.228.1539626412234; Mon, 15 Oct 2018 11:00:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539626412; cv=none; d=google.com; s=arc-20160816; b=MvrpQq91nn7jdRRoJpt/kR0Mr9+YkF588VShFtMojUJLrqtFMNJbUriNqb8RZTytjC wStSVHh/KwxZeT8u5LESRVOgpKHAc4zOlXPpuc0gp+EumyHXmnGSlQYQ+CdL/KPDMek5 gOxWw3xO/r6V3Qi9MK43Zqk09BnL7CAhnv+qDuACserNujN23mv3BcqRf7qpxN03cFnf NsNCh8IFmKFs0KsVORky6yL8GGm86bMqyYsL4ETBE98aLt8HMvE/GJ1aOaKE9pcuTpw5 4THP4v2vspQzTzQEbl1P/q+G88Aj6e7mH0hJbJYZXYm16h2RArs1rLBSXSW9TTUmCXHU iQ1w== 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=a7aBurZQf1xOEaxtTGVVjY94nlqilp86989r55UdLSE=; b=fx5gfbx8Qb4oQ42+W+J4E8as4T2j27ZgYYQq5Ip917yBhSJclY+yvplhX9vjjnwkp8 gWoqcwpk9/+O+Jf9ZxH97QXJbLn5WAiRj9yxU0uOsJeeol2sFkxX3loXsbKXZWwFe9aD oydGexPZ+2vLn/UUtbby+btck+e/q4aYMJKXXkv8Frp2Iu9mRolKmpuVnM5Qne3Q7ZKo dLGwnCWE5etBIm6jYcoKvAIJKcY8cLImoFf1KDXy5zKZnxLPM8/AHbqc6xF51ehHuGya tHw17Cd6BoPj1F+vMGFR59YLgxeY6ycKokHMQ2OMJ1JTb48V7OShscenXxnv47X59AFN cktA== 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 q18-v6si9745552pgh.523.2018.10.15.10.59.56; Mon, 15 Oct 2018 11:00:12 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727003AbeJPBp0 (ORCPT + 99 others); Mon, 15 Oct 2018 21:45:26 -0400 Received: from ale.deltatee.com ([207.54.116.67]:54708 "EHLO ale.deltatee.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726820AbeJPBnf (ORCPT ); Mon, 15 Oct 2018 21:43:35 -0400 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 1gC77D-0002IJ-IV; Mon, 15 Oct 2018 11:57:16 -0600 Received: from gunthorp by cgy1-donard.priv.deltatee.com with local (Exim 4.89) (envelope-from ) id 1gC779-0002Md-7J; Mon, 15 Oct 2018 11:57:11 -0600 From: Logan Gunthorpe To: linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-riscv@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-sh@vger.kernel.org Cc: Stephen Bates , Palmer Dabbelt , Albert Ou , Christoph Hellwig , Andrew Morton , Arnd Bergmann , Logan Gunthorpe , Michal Hocko , Vlastimil Babka , Pavel Tatashin , Oscar Salvador Date: Mon, 15 Oct 2018 11:56:58 -0600 Message-Id: <20181015175702.9036-3-logang@deltatee.com> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20181015175702.9036-1-logang@deltatee.com> References: <20181015175702.9036-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-sh@vger.kernel.org, sbates@raithlin.com, palmer@sifive.com, aou@eecs.berkeley.edu, hch@lst.de, akpm@linux-foundation.org, arnd@arndb.de, logang@deltatee.com, mhocko@suse.com, vbabka@suse.cz, pasha.tatashin@oracle.com, 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/6] 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 Cc: Andrew Morton Cc: Michal Hocko Cc: Vlastimil Babka Cc: Pavel Tatashin Cc: Oscar Salvador --- include/linux/mmzone.h | 6 ++++++ mm/sparse.c | 14 ++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h index d4b0c79d2924..26a026a45857 100644 --- a/include/linux/mmzone.h +++ b/include/linux/mmzone.h @@ -784,6 +784,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) && defined(CONFIG_HAVE_MEMBLOCK) +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 10b07eea9a6e..90aec8331a03 100644 --- a/mm/sparse.c +++ b/mm/sparse.c @@ -5,6 +5,7 @@ #include #include #include +#include #include #include #include @@ -238,6 +239,19 @@ void __init memory_present(int nid, unsigned long start, unsigned long end) } } +#ifdef CONFIG_HAVE_MEMBLOCK +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)); + } +} +#endif + /* * 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