From patchwork Wed Nov 7 17:38: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: 10672775 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 EFC2B109C for ; Wed, 7 Nov 2018 17:39:12 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E25BB2CD06 for ; Wed, 7 Nov 2018 17:39:12 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D69802CD1C; Wed, 7 Nov 2018 17:39:12 +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=unavailable 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 6BE162CD06 for ; Wed, 7 Nov 2018 17:39:12 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1DCED6B0531; Wed, 7 Nov 2018 12:39:07 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 18C9A6B0533; Wed, 7 Nov 2018 12:39:07 -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 07CFE6B0534; 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-it1-f197.google.com (mail-it1-f197.google.com [209.85.166.197]) by kanga.kvack.org (Postfix) with ESMTP id CF7646B0531 for ; Wed, 7 Nov 2018 12:39:06 -0500 (EST) Received: by mail-it1-f197.google.com with SMTP id r79-v6so11358970itc.4 for ; Wed, 07 Nov 2018 09:39:06 -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=Izl7FQIjX6vtgzV3Bh7GUeX8NbhWtWlS4nwo7NYT9mE=; b=pL20uPQd987uzbXdSrMzmSVqmrC7Oe3eWeIfSikX5dJlrGaWiRBK4TZSWt2sO9H7Qd OIeowcYGObmZakqDe9ej7h6CGxDXHzkAP2+4cUHDSkWHhdxNw9AKS6XAGwJDFbFpaHAl 1F1IPTDNCqLoEYeFXHdEqUUVXky1DPWe/mzZvUGTD6Vzq3GCNNWDSCnqD0NXjlfGTDRc MIOdJ/eqGOmpkiemYN0IQ4POFtM+eGprmVGTItFpQj9+u2jREzeKGwJpxxDp4E+M3a2B gy0OFDUZ4SE1TGIkVa3EnsCvBY2D5pBhtarg5iynvrf23km12h65a/WaAa6jXb5wsgvU NWYg== 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: AGRZ1gKMBrYUsmMBKRuV0OyRiFTyH6q8u2JAjC9jJ2B6TNokSsJbOzmw H+BgDFs/GVRDV8cvLd088JrAcBQWFjKMY0G0l5x0y2SAtEVdDS/2JY2euGTIAiNdzI2ZxlZw/Ml PgFW4bGLnm9RbU81DYSikihhDC/8B6mqViEUEhSpL6lK2W5+w9PG0Hkbh/VGN2DqgaQ== X-Received: by 2002:a24:4486:: with SMTP id o128-v6mr977605ita.23.1541612346595; Wed, 07 Nov 2018 09:39:06 -0800 (PST) X-Google-Smtp-Source: AJdET5cZUtJOaVxbwdvwl6/iNQzNSTYF1fuZ42gKmJbs7AjvJEhKHoM+f6DPqczdvPYshJRUPBYk X-Received: by 2002:a24:4486:: with SMTP id o128-v6mr977579ita.23.1541612345875; Wed, 07 Nov 2018 09:39:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541612345; cv=none; d=google.com; s=arc-20160816; b=q5dluBxGZDtCwYVI+1hj+RwB3aHsMG4ySeS4og4LVAONUgg1VnhA5mDYH2lkvlTxeG +jgJm5LXLO5rJJj0WLEAZdwkAMsDZUekyARlh4TJKWwEaf43Bx/cifQ9mibZTEO3WLnG YD8BjtEGrldww1oQ1sELUaFF/1ht2PT9/XSIXdCc9Fd0hn52TmCb6J9OwOvgwzc8Qkzc r2a/pRALHIDDgwAykZkrhgo9hw/flfjCYmO4eGr2cKiprmHIRzi8VmvyLbgoto+6+gOr 34rpQGeJbxMWf7cL+nZHfUk/xvAMVNp/H5Zk85zw3eXDjFWEfdxn/Enr77t5kHhckZO3 /A0w== 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=Izl7FQIjX6vtgzV3Bh7GUeX8NbhWtWlS4nwo7NYT9mE=; b=s3rpwUux74LKy6c/YbHJjpqNlvKq8sxBkRR8H5Bpn1YOlATt7mjfSXr4AbNgpRO5Ps FMno5uKsHUbNumaG8RbTMhTQRwanrKtvaUbNifbDkUSThUnNkV0RenRr3Ky5uEtCpPgk aCPl56g+/WOTa12TUREIySQpzbfmb7ZRCON6GYj87VfeUqJ4JYPWnzviq0UVuKsBQbT6 v32VbyPjazQxgoFbniMjfppYuYZvnvaaLmzFQkvAhGPFSMjQfXWAopyjcJfOdY9Iv5l3 zUXEDvOWxS2WCdD0srgFL7q4AFruA1+J24grPYUS7rIOJaDngR0zEhcfqp2Byk09F8OV Vo5g== 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 c7-v6si924267jah.125.2018.11.07.09.39.03 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 07 Nov 2018 09:39:03 -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 1gKRnB-0003U5-I0; Wed, 07 Nov 2018 10:39:02 -0700 Received: from gunthorp by cgy1-donard.priv.deltatee.com with local (Exim 4.89) (envelope-from ) id 1gKRnA-0006HQ-Fv; 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 , Catalin Marinas Date: Wed, 7 Nov 2018 10:38:58 -0700 Message-Id: <20181107173859.24096-2-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, catalin.marinas@arm.com X-SA-Exim-Mail-From: gunthorp@deltatee.com Subject: [PATCH 1/2] mm: Introduce common STRUCT_PAGE_MAX_SHIFT define 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 This define is used by arm64 to calculate the size of the vmemmap region. It is defined as the log2 of the upper bound on the size of a struct page. We move it into mm_types.h so it can be defined properly instead of set and checked with a build bug. This also allows us to use the same define for riscv. Signed-off-by: Logan Gunthorpe Acked-by: Will Deacon Cc: Catalin Marinas Cc: Arnd Bergmann Cc: Andrew Morton Cc: Christoph Hellwig Acked-by: Andrew Morton --- arch/arm64/include/asm/memory.h | 9 --------- arch/arm64/mm/init.c | 8 -------- include/asm-generic/fixmap.h | 1 + include/linux/mm_types.h | 5 +++++ 4 files changed, 6 insertions(+), 17 deletions(-) diff --git a/arch/arm64/include/asm/memory.h b/arch/arm64/include/asm/memory.h index b96442960aea..f0a5c9531e8b 100644 --- a/arch/arm64/include/asm/memory.h +++ b/arch/arm64/include/asm/memory.h @@ -34,15 +34,6 @@ */ #define PCI_IO_SIZE SZ_16M -/* - * Log2 of the upper bound of the size of a struct page. Used for sizing - * the vmemmap region only, does not affect actual memory footprint. - * We don't use sizeof(struct page) directly since taking its size here - * requires its definition to be available at this point in the inclusion - * chain, and it may not be a power of 2 in the first place. - */ -#define STRUCT_PAGE_MAX_SHIFT 6 - /* * VMEMMAP_SIZE - allows the whole linear region to be covered by * a struct page array diff --git a/arch/arm64/mm/init.c b/arch/arm64/mm/init.c index 9d9582cac6c4..1a3e411a1d08 100644 --- a/arch/arm64/mm/init.c +++ b/arch/arm64/mm/init.c @@ -612,14 +612,6 @@ void __init mem_init(void) BUILD_BUG_ON(TASK_SIZE_32 > TASK_SIZE_64); #endif -#ifdef CONFIG_SPARSEMEM_VMEMMAP - /* - * Make sure we chose the upper bound of sizeof(struct page) - * correctly when sizing the VMEMMAP array. - */ - BUILD_BUG_ON(sizeof(struct page) > (1 << STRUCT_PAGE_MAX_SHIFT)); -#endif - if (PAGE_SIZE >= 16384 && get_num_physpages() <= 128) { extern int sysctl_overcommit_memory; /* diff --git a/include/asm-generic/fixmap.h b/include/asm-generic/fixmap.h index 827e4d3bbc7a..8cc7b09c1bc7 100644 --- a/include/asm-generic/fixmap.h +++ b/include/asm-generic/fixmap.h @@ -16,6 +16,7 @@ #define __ASM_GENERIC_FIXMAP_H #include +#include #define __fix_to_virt(x) (FIXADDR_TOP - ((x) << PAGE_SHIFT)) #define __virt_to_fix(x) ((FIXADDR_TOP - ((x)&PAGE_MASK)) >> PAGE_SHIFT) diff --git a/include/linux/mm_types.h b/include/linux/mm_types.h index 5ed8f6292a53..2c471a2c43fa 100644 --- a/include/linux/mm_types.h +++ b/include/linux/mm_types.h @@ -206,6 +206,11 @@ struct page { #endif } _struct_page_alignment; +/* + * Used for sizing the vmemmap region on some architectures + */ +#define STRUCT_PAGE_MAX_SHIFT (order_base_2(sizeof(struct page))) + #define PAGE_FRAG_CACHE_MAX_SIZE __ALIGN_MASK(32768, ~PAGE_MASK) #define PAGE_FRAG_CACHE_MAX_ORDER get_order(PAGE_FRAG_CACHE_MAX_SIZE) 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