From patchwork Wed Nov 7 17:38:59 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Logan Gunthorpe X-Patchwork-Id: 10672773 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 22998109C for ; Wed, 7 Nov 2018 17:39:10 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 12E3F2CD0D for ; Wed, 7 Nov 2018 17:39:10 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 06A432CD13; Wed, 7 Nov 2018 17:39:10 +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 7A76C2CD15 for ; Wed, 7 Nov 2018 17:39:09 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5ABA46B052F; Wed, 7 Nov 2018 12:39:06 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 560B36B0531; Wed, 7 Nov 2018 12:39:06 -0500 (EST) 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 3D85D6B0532; Wed, 7 Nov 2018 12:39:06 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org 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) 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=SUpvKtrKWj0LEBMJVxJ8Fc9aERslhBdlht6Yi3t4nSs=; b=JJp3HaOEPfJ1oQxRmZUSUHBMIDuz1AcErEBXywM5cAuYMlPirH05TubPv5TaZADAP3 KrNKeEPsEZ4deYgVN71Oh9kdDw9pJ3Rw2U1G3Ahlyih703H230D0HTvYjc786saap2go YSOrlVUe1UUMYu9M9oqRwKgBvnAZ3AkeiJ/yARRxNB4h/SBF7mdw6evObtt/e1sr6+xJ ti10oyt9kwJ+Hc+dwHxJ+VWYzMmVQqhhs5wiCwSJOmnPa5TXlYxFE6l6zKRMeGqQu4U1 wXgExEcKyRuwSdn7fQbBFamOENwU7rYnMSZwLnoj0LKLtvljM/Siqxc0r8GJz8EpGsSy /ZfQ== 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: AGRZ1gLOvXNwuMQJp5d+R9DE6H0QGUNjSb/3jNkIdRpVa22n1govSX/j Tdns5APfdJcR9vpU0CKZ+Q3JHI1cqsxcq+EHDUWjWbXf5BXlZIR+Wm+PY8q9z62PmHqPZe848Ef aIFS7zS+Djet+wCgkcore/M095nVc2JEWOjt6k6X5xNHYRZdhHbBDik2hnrXPE5O03w== X-Received: by 2002:a5e:8b42:: with SMTP id z2-v6mr845741iom.144.1541612345728; Wed, 07 Nov 2018 09:39:05 -0800 (PST) X-Google-Smtp-Source: AJdET5epVtt0799dSqv3L3R032qQ4Y9OEYSbW2ccWEprJgk9tOLWP64BoxnKH24Q0hT2C2fSOgKm X-Received: by 2002:a5e:8b42:: with SMTP id z2-v6mr845710iom.144.1541612345016; Wed, 07 Nov 2018 09:39:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541612344; cv=none; d=google.com; s=arc-20160816; b=0N9Z4FM9sTnWssynsIAy1UBaGqBAl+jOniO6gO5cZdFIe2+z/j1Oml9NiGUfTpnrZf rGdw3z8d5+zKS4/84l9WNDu4t3baffVsCQu2PD21ImHG91tikhW3ldZgPiGKVCuc1dCn k/m+8kMUQj6fyDkWLCoR4bTWadK/L2gxvesqWx58aBViNeDKxOVXouugVoHKCNDg1ZTa hR+PEBvQqupSGsx5xCz3+DLxgLbgsQjrPf2M/p9dehKrPysMJbdWTcqQHFubV+/W0FSZ ZURtcbF0Yg0pMV9ysZMtlZsHonzHzOJhlGacdi0SdrqlLwEEnvCvAXSjjAalhEiooldI IOtw== 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=SUpvKtrKWj0LEBMJVxJ8Fc9aERslhBdlht6Yi3t4nSs=; b=PMm9d1oJ8QmmdLzlH1uHvEh4aT3fgfc9wcYJbiYXpTaohItzMrDLCsETHlING6IU4d HQsz0595N5mpPrGAs5dVl0fgY/SSHxvejvYD/yTOZoBo9v6fqCIry3kiAqn8vu378H4u kfaBM0eC3ssoxxlE5T/VbcxYY2bPa/jKLuEr1n4xQldq0XXDgBCFnu8AZkeNTAyX+Bit Vx/WnohmOFM8HvIJKyZDZQU5iFL6OLI2iyImcwEjA0+PBHofzER1JDJ+f3tEQEtdSYxH UqSbFDStpREFy6NFve/5EDsZ4vapszHVnfr644kp0OP7vEPvp45zmUFFSnbFzfbWGO2a 8IPQ== 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 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) 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 1gKRnC-0003U6-6F; Wed, 07 Nov 2018 10:39:04 -0700 Received: from gunthorp by cgy1-donard.priv.deltatee.com with local (Exim 4.89) (envelope-from ) id 1gKRnA-0006HT-JA; Wed, 07 Nov 2018 10:39:00 -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 10:38:59 -0700 Message-Id: <20181107173859.24096-3-logang@deltatee.com> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20181107173859.24096-1-logang@deltatee.com> References: <20181107173859.24096-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-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 Subject: [PATCH 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) 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: Oscar Salvador Acked-by: Andrew Morton --- 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