From patchwork Mon Oct 15 17:56:58 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Logan Gunthorpe X-Patchwork-Id: 10642291 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E0BF813AD for ; Mon, 15 Oct 2018 17:57:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D33272984E for ; Mon, 15 Oct 2018 17:57:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C74C72992B; Mon, 15 Oct 2018 17:57:27 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5AC252984E for ; Mon, 15 Oct 2018 17:57:27 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id F0F2C6B000E; Mon, 15 Oct 2018 13:57:18 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id E9A476B0266; Mon, 15 Oct 2018 13:57:18 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C77826B000E; Mon, 15 Oct 2018 13:57:18 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-it1-f197.google.com (mail-it1-f197.google.com [209.85.166.197]) by kanga.kvack.org (Postfix) with ESMTP id 9C9656B000D for ; Mon, 15 Oct 2018 13:57:18 -0400 (EDT) Received: by mail-it1-f197.google.com with SMTP id v13-v6so22433916itc.4 for ; Mon, 15 Oct 2018 10:57:18 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:from:to:cc :date:message-id:in-reply-to:references:mime-version :content-transfer-encoding:subject; bh=a7aBurZQf1xOEaxtTGVVjY94nlqilp86989r55UdLSE=; b=LR39oUeHrAEs6+BA0JUf5XATCwPSDPeqQEixI1zOi/rgYf4gwFCbegX7qQkMRAIGqm t0SYUz7u0r40UKSR7D6SnJ8Y7m6jl8SgvOQPWHDm6wFL5PN0vt9HOi3FS0dXad5Fwy8x rUajXpcAdnpY2gXXnR3WlDmZO4PytEN2VKTWWar0B1Utq2DI63peMDkcSSY8iEvfkl4f DjmzkjICZ5QPYImaYI2liatK9Mzg+Vq0sjF+vaQ2RRvxwpngsO5Hj/L10SuHCxw7nWvV oOfpn7O8Dp1eBwIzYh1udaQ4hDwLKjHx5qg03TqzCM0kPosWQT5CYbDwkkJoDWFlX8Fm dtPg== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of gunthorp@deltatee.com designates 207.54.116.67 as permitted sender) smtp.mailfrom=gunthorp@deltatee.com X-Gm-Message-State: ABuFfojqb2fCL5WhOd0BUYfVKeIPjvf+g3ZgMYMp+vOxjJeu0TYvycPz nJLV35TJhIyMvojrjHUfwswUaVCoKj3/2LirVJNdtmFuHUYKqedH6TkGliL2VJh7FHt6RSKEgeQ TYFJBXfI2WNbYgDAvSnduZHEH4/acMtF3d8q5n88IEaCFM7GpUAahUTDvqNQJl0rmVQ== X-Received: by 2002:a24:c9c6:: with SMTP id h189-v6mr13457012itg.161.1539626238420; Mon, 15 Oct 2018 10:57:18 -0700 (PDT) X-Google-Smtp-Source: ACcGV63u2+AK7RcsaSkekG08Kh/HQxCvTahPOZwjr7r/gAhC/y4QL1qjQfAjBZ2Kqv1Ma8zP52mP X-Received: by 2002:a24:c9c6:: with SMTP id h189-v6mr13456974itg.161.1539626237598; Mon, 15 Oct 2018 10:57:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539626237; cv=none; d=google.com; s=arc-20160816; b=b21z8vSUiJHinP7K+XmJK9dufbCoTukFiZ+Ef8YyA5JJpoIrCE8RgAb+fRetiS75h8 UNvUyTsBWWn0IfOUuKya72xavncb+hf5JCUN8fQISck5BdU5afLVllsy6DGROpO93baX hKmWU4VmDuxQhTAbIMm3vSXyqf0LkansiMMGepV5Wu9PdIyshBTizJ6UYdn8HixCXjos DqJ+bZ70OcEbfhut73pQCR/urWJNUoX8OBPEsPuLY2x09d+enfZa5vCmGxqz/QEWuUqO RQun9Njlf3rJMsGQA6Ur9yr8GwSH1npZ5L1Wvy1dt2Yp4kPChttg5T8F4DfkkYhDsZu1 u6RA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=subject:content-transfer-encoding:mime-version:references :in-reply-to:message-id:date:cc:to:from; bh=a7aBurZQf1xOEaxtTGVVjY94nlqilp86989r55UdLSE=; b=0d2ojZq2mI9loeWxuMjmWaU5rPwncZnMRnxp+3vs7ulwM5vqVEi4swILROH3tnLjJk 7siW0p3eqwk9t0fIBaIkePNPNdNS5yc1LpPUiXGGwHoWNGe5KE2KmCQuMfSQLUtAsOPY dJUWRo6/ou7lJ3vU9HivE0jg16OT6A+TtVwFLacn9rK7n+pcF22OCwqZzPafN/Djpi5M 1vevrBRZbH+0ASp5WsJ6wJW6kyAoT0aDWf3F7Sr/oXZRn/HwPG1Wt0fHEj/muGIx1dnS VJ1XeVCOjxaWjD28yGQ6eVb5FxX3ficp5ARKAkUakSQHZMNGm7joNMpd513v3zm48NdM AtEA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of gunthorp@deltatee.com designates 207.54.116.67 as permitted sender) smtp.mailfrom=gunthorp@deltatee.com Received: from ale.deltatee.com (ale.deltatee.com. [207.54.116.67]) by mx.google.com with ESMTPS id c199-v6si1778696itc.90.2018.10.15.10.57.17 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 15 Oct 2018 10:57:17 -0700 (PDT) Received-SPF: pass (google.com: domain of gunthorp@deltatee.com designates 207.54.116.67 as permitted sender) client-ip=207.54.116.67; Authentication-Results: mx.google.com; spf=pass (google.com: domain of gunthorp@deltatee.com designates 207.54.116.67 as permitted sender) smtp.mailfrom=gunthorp@deltatee.com 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 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 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) X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP 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