From patchwork Fri Oct 5 16:16:38 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Logan Gunthorpe X-Patchwork-Id: 10628423 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 307C61515 for ; Fri, 5 Oct 2018 16:17:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 16F7829A12 for ; Fri, 5 Oct 2018 16:17:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0AE2B29A2C; Fri, 5 Oct 2018 16:17:03 +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 9484629A2B for ; Fri, 5 Oct 2018 16:17:02 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 840956B0266; Fri, 5 Oct 2018 12:16:51 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 818826B0269; Fri, 5 Oct 2018 12:16:51 -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 6E4416B026B; Fri, 5 Oct 2018 12:16:51 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-io1-f69.google.com (mail-io1-f69.google.com [209.85.166.69]) by kanga.kvack.org (Postfix) with ESMTP id 324976B0269 for ; Fri, 5 Oct 2018 12:16:51 -0400 (EDT) Received: by mail-io1-f69.google.com with SMTP id g133-v6so12235751ioa.12 for ; Fri, 05 Oct 2018 09:16:51 -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=biEQ///jlvyI4fc25H8Z943OL0W4L93EMFGNrpYwZuQ=; b=guZ0aNYaNp2KTlemVXAFxXKwoaGHWax7yGzscPt9oiNXxeeOcnOyzVZUOJHN5KD1qx 0WUCRxHWSx8mZ8Eg5reEqBjFWEGESC7XOCYkMMaVppFiWfxU8H11vNJ7r0wvkoR0YaD2 wJVAYjFEC1C8hUvjzZQLaSWTazXqRRfJQXAbO+mkKLgd3/zOvRjAb56vrw0dp6NLWGdL V68Wga0FYCMHdoxMAiaunUlwqGJ+C/UVZHugqU30MlM2h3k0IriFF+V2tB/YBjIEsL6x cXRwx0i5ugrFgrWylcgmXyLQGcnRM5tRc97ZMAbTHrc1jxtFl5KOUlhce8V1pocOJjAv r4PQ== 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: ABuFfogVGuCtImtSIyNqJe9q/jOuV3nDjADhhi36w+a1Z6jHiJaRbaCD CxpPFDr6ZXPbHjJOBRGDXPBC+KA8Zs1IBU/trwdEuYh2pGBhVUX7AxSOgn5VuSD8eQqMtR6aJ8s MBLrHN5MQOYIvxc7H+5zk/IELKGgQOqliwa5H+Pp0TFk3m3ixkjmiLc+vaYRNlha8yA== X-Received: by 2002:a6b:ec0d:: with SMTP id c13-v6mr8533184ioh.33.1538756210836; Fri, 05 Oct 2018 09:16:50 -0700 (PDT) X-Google-Smtp-Source: ACcGV60/+A6V1Jo+g7VNv2owqlmPpfaXewnTjCb4F6h0RidWeDQBMhTWP/o0ft0rKILhziopldeG X-Received: by 2002:a6b:ec0d:: with SMTP id c13-v6mr8533064ioh.33.1538756209054; Fri, 05 Oct 2018 09:16:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538756209; cv=none; d=google.com; s=arc-20160816; b=Rs184BMMv4cGqpoI2WuoglXrxBG7gZzdizTgh1caSiS9ouUrnmrkUCGt5wT1nmHokf TDF2H8m7WfXcEecq+GRZjaS4l1gXciSRlY4BlI+RTdPIIhDZbI47SwKFhRk5RnGBalHv UYurMrlGbk6QGFSlBRrt8vgf3Rsij4fqgafxumOatplHcAY/oHwXaZTWWSkbz+flVmwF qE8QQKUiezCVrEfQXqSH9kXS0aDPBrKolMWafjQhzGHeIqp5UiHWdeH6nwGcczs5mNl5 lExqLxtsaHBBI2yFEzjF4zMXyuLv6wkEgGy1qijep9MzczyWQN9LwnN2juo+4JbxtHwT Z5yg== 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=biEQ///jlvyI4fc25H8Z943OL0W4L93EMFGNrpYwZuQ=; b=oo+dDmn5ExYKSpCqLtmzqLLUxmfMbsTFs6WVZ3JGSI5cotbIbVqw0s+usXEeUCUqvu PWzw7ItrupFxLngjORl+8fbOCN1hvxYNh9hQxyBQ60YttWRaVGzfg4mSUiKVq3r/Lhkc 7DJ9W85gnTqZskwplZoe01ASyAXVs55YZVTEu5wyveVKz6QlssyfL9zYOLasRiyzyYL6 idjAugw2HzWXYrAAIvvSrzfEQuFJInkla9S64/h89rUnWJNcNk7C+BJolzNDCQTZ+iIO bfgKkfGkn2BmhURZ53LXPifqgwCC32UYSN/4YQolU0IGuamIohc71wYvqj8UNwma4lAW CXUQ== 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 d31-v6si6303763jaa.0.2018.10.05.09.16.48 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 05 Oct 2018 09:16:49 -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 1g8SmU-0008D2-45; Fri, 05 Oct 2018 10:16:47 -0600 Received: from gunthorp by cgy1-donard.priv.deltatee.com with local (Exim 4.89) (envelope-from ) id 1g8SmR-0000eX-VZ; Fri, 05 Oct 2018 10:16:44 -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 , Logan Gunthorpe , Andrew Morton , Michal Hocko , Vlastimil Babka , Pavel Tatashin , Oscar Salvador Date: Fri, 5 Oct 2018 10:16:38 -0600 Message-Id: <20181005161642.2462-2-logang@deltatee.com> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20181005161642.2462-1-logang@deltatee.com> References: <20181005161642.2462-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, logang@deltatee.com, akpm@linux-foundation.org, mhocko@suse.com, vbabka@suse.cz, pasha.tatashin@oracle.com, osalvador@suse.de X-SA-Exim-Mail-From: gunthorp@deltatee.com Subject: [PATCH 1/5] 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, 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 | 15 +++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h index 1e22d96734e0..a10fc3c18b07 100644 --- a/include/linux/mmzone.h +++ b/include/linux/mmzone.h @@ -794,6 +794,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..109159574208 100644 --- a/mm/sparse.c +++ b/mm/sparse.c @@ -5,6 +5,7 @@ #include #include #include +#include #include #include #include @@ -238,6 +239,20 @@ 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) { + int nid = memblock_get_region_node(reg); + + memory_present(nid, 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