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 From patchwork Fri Oct 5 16:16:39 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Logan Gunthorpe X-Patchwork-Id: 10628425 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 E25D7933 for ; Fri, 5 Oct 2018 16:17:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CA71C29A12 for ; Fri, 5 Oct 2018 16:17:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BC7DF29A2B; Fri, 5 Oct 2018 16:17:06 +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 08C8629A12 for ; Fri, 5 Oct 2018 16:17:06 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2041D6B0269; Fri, 5 Oct 2018 12:16:52 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 0EEA96B026A; Fri, 5 Oct 2018 12:16:52 -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 F1EF76B026B; 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-f71.google.com (mail-io1-f71.google.com [209.85.166.71]) by kanga.kvack.org (Postfix) with ESMTP id C49886B0269 for ; Fri, 5 Oct 2018 12:16:51 -0400 (EDT) Received: by mail-io1-f71.google.com with SMTP id m7-v6so12616391iop.9 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=Pjn2SKMH8bI3Nc5MBoKr+9lA/vWqKzACQOBqjOPOq7Y=; b=SPvFXHdiClQFO2SY0fkQCh1tDzoa6BIUR0siaeD0sS1R1q2ZZle2PLt4iwZwukuY9G ffkJG8tMjaLTZ2Rsv3ShH5u4k6/qmzzVcAmmzmxUFFQC3ke96Lm1SVcinUexkV+uk1rj AuzsyrfHfaadugpbTKdC6T04yb5jJFY2iFEEs1xHv6TXjl2P2GX7gSdmNfai34jAA2Yf LEJTWeEPs6bFPEQKZz8mDpoitpjjFl+kJURjxbb4LW4p47o98prUtztwlyeMIvyqNqNb hB5cyPh3lkGOCjGDujA5qHG+Cne2+vc3b1S8sxUuMSu+mJ/rs8IK0iwlhJoJR9B05fPS +W4A== 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: ABuFfogfXj9UfJ4GQdXdIhaRX+/XFRdElDPFj+6GnKMcytBbao794K0H b/bQJkenrVmnE5tbhaISuklbum0CeaQkyO/DuCpTIUi5xdin9D5aSpnBIq/GFFW/a60G/wbglsO hxdRfDLBHBTKfNkMwUhi915bmHFswY6O8HFiVI/7+Yrb+phYmeaWBWmYZBkRN34Przg== X-Received: by 2002:a6b:e00c:: with SMTP id z12-v6mr7759957iog.44.1538756211550; Fri, 05 Oct 2018 09:16:51 -0700 (PDT) X-Google-Smtp-Source: ACcGV61zyrfT8MzXt8GmlPlRYtGmb+I83eRXLSXHMTeiWtbxvUvjirSKmJow94uJMrqXg/YpdG5q X-Received: by 2002:a6b:e00c:: with SMTP id z12-v6mr7759897iog.44.1538756210601; Fri, 05 Oct 2018 09:16:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538756210; cv=none; d=google.com; s=arc-20160816; b=suwuzxipu+mVFrA4Amd5f8YFUhMnJwgDSLdOO1ejQwwEyUavAvns5MTIK4O4ZeKJ3z jT+Pgacb/XXF2pQgJWfRjOLWj20D1YKW705b9e7iwj/oNM4EOd5ybarsJm4MxzIYP4kg kmJvM8vzSGrdXgzc46eius3ACWblfQ8he+lSxc3YgQhgSyFSbspXzhftePns2Td6Gg2k lcn2rBe4XIKMJDaBHzw4++9BDCTc8qUdv0nu4ueNLmufrnRtSvHNGuRuiw68TXnBlfnK VOPIGLo3q2Hovlx0n2F7XFn/QPPq5hynnoyTyetHcem+Iera09K4So6NW0HuNobWVa0q iIyQ== 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=Pjn2SKMH8bI3Nc5MBoKr+9lA/vWqKzACQOBqjOPOq7Y=; b=iIAT1tJNTgA/Z/5xuAz/X9EzzVnGiCxuhawJgw5HpgY1/EOG896z5l2dOGWk1cs92/ oa9lnvBUpDDatzO+OzaYcLod8J+o1DZNSZiB8lUEwBTvSGkcFkdbUrvEMvqZgCAGjL8D 5ry4wfFFV+U7vqTiXnbKzIirVIky0VwIZaEWxPe+eeILHRwftnRrcFryrOgKJgWTniVu Qj6sEtbIIBit97e/wcT48gqW9+2Y2xHUzYaP3C3MIORcImIA4LWhNqlcYYy+0JoXc9c8 qTIEMYjYtEb4DIhES6B6Egxq0zVLjD3yyVlbzFeAyMmENTuE/+rEkMwjEV1Z0D3/I8Is qTOg== 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 c42-v6si5712919jaa.60.2018.10.05.09.16.50 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 05 Oct 2018 09:16:50 -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-0008D3-Sl; Fri, 05 Oct 2018 10:16:49 -0600 Received: from gunthorp by cgy1-donard.priv.deltatee.com with local (Exim 4.89) (envelope-from ) id 1g8SmS-0000ea-2I; 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 , Russell King , Kees Cook , Philip Derrin , "Steven Rostedt (VMware)" , Nicolas Pitre Date: Fri, 5 Oct 2018 10:16:39 -0600 Message-Id: <20181005161642.2462-3-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, linux@armlinux.org.uk, keescook@chromium.org, philip@cog.systems, rostedt@goodmis.org, nicolas.pitre@linaro.org X-SA-Exim-Mail-From: gunthorp@deltatee.com Subject: [PATCH 2/5] ARM: mm: make use of new memblocks_present() helper 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 Cleanup the arm_memory_present() function seeing it's very similar to other arches. The new memblocks_present() helper checks for node ids which the arm version did not. However, this is equivalent seeing HAVE_MEMBLOCK_NODE_MAP should be false in this arch and therefore memblock_get_region_node() should return 0. Signed-off-by: Logan Gunthorpe Cc: Russell King Cc: Kees Cook Cc: Philip Derrin Cc: "Steven Rostedt (VMware)" Cc: Nicolas Pitre --- arch/arm/mm/init.c | 17 +---------------- 1 file changed, 1 insertion(+), 16 deletions(-) diff --git a/arch/arm/mm/init.c b/arch/arm/mm/init.c index 0cc8e04295a4..e2710dd7446f 100644 --- a/arch/arm/mm/init.c +++ b/arch/arm/mm/init.c @@ -201,21 +201,6 @@ int pfn_valid(unsigned long pfn) EXPORT_SYMBOL(pfn_valid); #endif -#ifndef CONFIG_SPARSEMEM -static void __init arm_memory_present(void) -{ -} -#else -static void __init arm_memory_present(void) -{ - struct memblock_region *reg; - - for_each_memblock(memory, reg) - memory_present(0, memblock_region_memory_base_pfn(reg), - memblock_region_memory_end_pfn(reg)); -} -#endif - static bool arm_memblock_steal_permitted = true; phys_addr_t __init arm_memblock_steal(phys_addr_t size, phys_addr_t align) @@ -317,7 +302,7 @@ void __init bootmem_init(void) * Sparsemem tries to allocate bootmem in memory_present(), * so must be done after the fixed reservations */ - arm_memory_present(); + memblocks_present(); /* * sparse_init() needs the bootmem allocator up and running. From patchwork Fri Oct 5 16:16:40 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Logan Gunthorpe X-Patchwork-Id: 10628417 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 DAB21933 for ; Fri, 5 Oct 2018 16:16:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C29D929A11 for ; Fri, 5 Oct 2018 16:16:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B67CE29A22; Fri, 5 Oct 2018 16:16:53 +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 4BA1D29A11 for ; Fri, 5 Oct 2018 16:16:53 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 03A266B000E; Fri, 5 Oct 2018 12:16:49 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id D941F6B000C; Fri, 5 Oct 2018 12:16:48 -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 BC03B6B000D; Fri, 5 Oct 2018 12:16:48 -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 8610E6B000A for ; Fri, 5 Oct 2018 12:16:48 -0400 (EDT) Received: by mail-io1-f69.google.com with SMTP id l4-v6so12567199iog.13 for ; Fri, 05 Oct 2018 09:16:48 -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=ny/KrIVq9zxLwXex6XJYsyavmrRK9P1AkriNn2ykBmc=; b=RMHrPqqXgqL9EImT+6eHzpHIbNTbpH2ZkLI+6+dxRSweV/L/clacMTF6tY2FHjgfcH fCw/0BuLrShvcLkkZo2SD3LFWeMHPz86Ib94suQ5iuiOQzJoztpX33ow3AKLnnRnjVXi L4dE6D4dvzQBasQhQzJIWRJyFrxtvVg2oKRIx69HWcDTYZnsAF+fIKwd2HtfnkVjXeX6 66782P1741toL0uSfG3c8m1R61ENEShd04o7Vu1ut6ygHlg9QtifYbQayDJoDZhm0hJy GF0PqF/nXPHVWuw+ZoRcDTzSsP23SFoo4gKFkyn8RKGwNqbCT26a5kbqLuxD7xPQ1DH1 ri0w== 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: ABuFfogqyWicTO41h1iEcSSWGeM+gXK9DrJsxCSox6yrh4WmOhNS2I7M TBbggnqY+JuUjjWQ9YJiLAdqybcpk/r5KGs47L3/ePGHjssXjf7Wgh27XdMAob8Vzv48RvPqcUb U1ZH2oDZxA6tujxMkre57s+eFQhGXi0N7GgqW96azylnutPDpO0vdBeHOUNzQLl3Vaw== X-Received: by 2002:a6b:b305:: with SMTP id c5-v6mr8330242iof.49.1538756208192; Fri, 05 Oct 2018 09:16:48 -0700 (PDT) X-Google-Smtp-Source: ACcGV61js+RH2R0B75fruSODxM9v0BJtblp01oHFuqpvj7mF1B8ClFmu9R+RY4gqRKABd8KBdwB0 X-Received: by 2002:a6b:b305:: with SMTP id c5-v6mr8330203iof.49.1538756207373; Fri, 05 Oct 2018 09:16:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538756207; cv=none; d=google.com; s=arc-20160816; b=mY0TbZhXqxO6WH5Mcb6Ofg85CmLpsuzUfSjWiWeb2TP732VtwiaS38LLR+/7KHKJuh est53lc+BuLRe1EhHd7igQ/QL3mfXCbbS3ecLgt1vH3rcXrrtthTO2cSBb+UQFhnKqJM Es/rp3vHuJGKJQWaPcwrpoinhthx1Mtl0LZ+kHZYaVLR0S7kgD5tYEAvqfmmjglwBX8x otSl1yDruzemTufwNyEhz3VxKvqbW8T+IPhG+pX02N5zKjtCGVkNQbiwS2IC2yjPJFAs j9MFH7L/j75pY6JCbjxOzgLdomq7SC+hQ4phrkQfjVq2lkxzSuIOmIZ2QH/UUWpyzEr+ XM1w== 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=ny/KrIVq9zxLwXex6XJYsyavmrRK9P1AkriNn2ykBmc=; b=1BBNzvWkyIRG4su7lGtsmffZpJ30GpG2nQXo149AP3CD7IULBGRrK/n8UYgZYMjGwk ZhTzqFWCMQ9WtKFKEZe0EWbQWnmAxEM8f9xlbvvuA5re9VD5Y9/eW612rTQD4HFfsGaN n8eyIhX8CvTATCWrHmQWhWroMDTPZXGSvA2EBWIMDRxEZTDk0bFKDXPWmS51JUbksN1e kS8t/qhs70VdAQpRiPtAEMs/zuEo2sAzhYZEI+Q8IrIdxU3zdZ46ee8UXwE6KF/wBRDl 4CpoV/N5Eh3jzvZmSNeTHi/Gz35zlSXtSOUj3cIDr0BWMz81LLDre7TFpnhcvvxfVvkt epiA== 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 f6si1666271itk.72.2018.10.05.09.16.47 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 05 Oct 2018 09:16:47 -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 1g8SmS-0008D4-Iz; Fri, 05 Oct 2018 10:16:46 -0600 Received: from gunthorp by cgy1-donard.priv.deltatee.com with local (Exim 4.89) (envelope-from ) id 1g8SmS-0000ed-5h; 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 Date: Fri, 5 Oct 2018 10:16:40 -0600 Message-Id: <20181005161642.2462-4-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 X-SA-Exim-Mail-From: gunthorp@deltatee.com Subject: [PATCH 3/5] arm64: mm: make use of new memblocks_present() helper 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 Cleanup the arm64_memory_present() function seeing it's very similar to other arches. memblocks_present() is a direct replacement of arm64_memory_present() Signed-off-by: Logan Gunthorpe Acked-by: Catalin Marinas --- arch/arm64/mm/init.c | 20 +------------------- 1 file changed, 1 insertion(+), 19 deletions(-) diff --git a/arch/arm64/mm/init.c b/arch/arm64/mm/init.c index 787e27964ab9..63fa9653f281 100644 --- a/arch/arm64/mm/init.c +++ b/arch/arm64/mm/init.c @@ -296,24 +296,6 @@ int pfn_valid(unsigned long pfn) EXPORT_SYMBOL(pfn_valid); #endif -#ifndef CONFIG_SPARSEMEM -static void __init arm64_memory_present(void) -{ -} -#else -static void __init arm64_memory_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 - static phys_addr_t memory_limit = PHYS_ADDR_MAX; /* @@ -506,7 +488,7 @@ void __init bootmem_init(void) * Sparsemem tries to allocate bootmem in memory_present(), so must be * done after the fixed reservations. */ - arm64_memory_present(); + memblocks_present(); sparse_init(); zone_sizes_init(min, max); From patchwork Fri Oct 5 16:16:41 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Logan Gunthorpe X-Patchwork-Id: 10628419 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 D6804933 for ; Fri, 5 Oct 2018 16:16:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BE7A529A11 for ; Fri, 5 Oct 2018 16:16:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B23FC29A22; Fri, 5 Oct 2018 16:16:56 +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 3A95B29A11 for ; Fri, 5 Oct 2018 16:16:56 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 122B86B000A; 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 001266B000C; Fri, 5 Oct 2018 12:16:50 -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 E0BA26B0010; Fri, 5 Oct 2018 12:16:50 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-io1-f71.google.com (mail-io1-f71.google.com [209.85.166.71]) by kanga.kvack.org (Postfix) with ESMTP id AF9866B000A for ; Fri, 5 Oct 2018 12:16:50 -0400 (EDT) Received: by mail-io1-f71.google.com with SMTP id f9-v6so12232486iok.23 for ; Fri, 05 Oct 2018 09:16:50 -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=NTcJ226Q2+0NWWI9l8S5fVLhXXyyUbvC1ipsiSvc4qQ=; b=KWIMgwlZZWJZ0CuEiqEqODjOB5XA6TFcrmABY3acgxuWB+dufFXSl3ZESYxanyXvPI KOCusDSZKAEoe8gjuC1LX9fejHkAzUjLCvvfq1TY39M4LB0o/S6qzM1rw2UCyENeRPEx oT28QJR/HSTOj1NwKWwJbxbEV9fmv67EDpUdLDiXASdO0gxD7h4tnbPZqk39BNXnc74U kq/hC6XNC+N4Cc6uDsdn68QFb/Ow/GA8GrDrwkHWa29BQcvxyzNkP9u/ou248MxI5PPi zLP2pF763fG0zJGvmeHiL/H9YgQBVHb0dVreWnOd8+Geu0O1n2zTGVv7jiAaBc4ySOf/ GreA== 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: ABuFfojVrKLnMeoDdzplYsgR3vMRzz/SOiEqeaV9YWRnzQNjO3o34BqK 4+OfewR1ZGey+F0PALaOpXxGgquB+ncBDUHCPn+azGWI8mesKlzwKL//vIKsb7O/iyYCsU9L3Zi uqU/Aq0slJ+SL8lXPbngJ1WcqXw3oVByjH4rgrFCEwxd0DgAX/5xo87n7OLDA5O18fQ== X-Received: by 2002:a24:3306:: with SMTP id k6-v6mr9170637itk.79.1538756210446; Fri, 05 Oct 2018 09:16:50 -0700 (PDT) X-Google-Smtp-Source: ACcGV61tx++slz9ST/sijpjcJW1oltruxBZTTN9wK2tjAb04ENb4qTmskD8uYtSreIWHYnRZheiH X-Received: by 2002:a24:3306:: with SMTP id k6-v6mr9170588itk.79.1538756209743; 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=iFEy0jAkTj5w+9Cr6SW4aPCIKPnYUpVfghOrNbU4xCRf9p27oytZnFo0fz4iGiOHFS 84HNGsU8xlk3Tj4mjzzY0AimVFOgsWOnf1IMe+h73Uk8jQm2SK03hiWrtzDn/SWOUQ/O TfDjzLAJLe1KzbzxwhpcJ0zERk3/Smezju0HnpSxihyo+WygRbSLl17Y48vIeics4s/K Trgb+bIaYf50DGe2pNxQGvgxgGWrudZ03mJe1CM8YF0hFWAylkAUwXMsRAZ9CyaYClLM XOiDOUJS/Ph6z5fPp4/sU651m02oCjwunPwm/xNgD6fcK+k3Uoq4ikhtq3HhTg2rgVcp 6DDw== 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=NTcJ226Q2+0NWWI9l8S5fVLhXXyyUbvC1ipsiSvc4qQ=; b=nSVPkoBar6p6y477GOeAa2hXJYNrxDZhhfkt86s8PRECxironSACMOoXV4YzYz8d9X HJmxb+tno7dZublfqLYg4DEAWDNcpbavBC2XqJ8df4vgzBFTIEiG1Jx1kbuAPMrEHsSk Q5rvyppS9M1Xz7pbp66HkHdHFyXgwq/xarJajOEY8kIUK0iGfBfJ1vvrbaRqOPhm5QuN z/oqmvVinptJIeRDOWGcD2g1L/oxQdmaTNXY0t8tqGfNHOyjVghIPPMelvfxCOIv3FkN Z1mOBgmg7TYRJZ01CzCzqBEV1HanfQGqZ0fP67Hm6oZ8eFQ0libSDPvnFsLobXt7QZUx 2ypw== 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 d128-v6si1953878ite.36.2018.10.05.09.16.49 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-0008D5-8H; Fri, 05 Oct 2018 10:16:48 -0600 Received: from gunthorp by cgy1-donard.priv.deltatee.com with local (Exim 4.89) (envelope-from ) id 1g8SmS-0000eg-8U; 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 , Yoshinori Sato , Rich Felker , Dan Williams , Rob Herring Date: Fri, 5 Oct 2018 10:16:41 -0600 Message-Id: <20181005161642.2462-5-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, ysato@users.sourceforge.jp, dalias@libc.org, dan.j.williams@intel.com, robh@kernel.org X-SA-Exim-Mail-From: gunthorp@deltatee.com Subject: [PATCH 4/5] sh: mm: make use of new memblocks_present() helper 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 Cleanup the open coded for_each_memblock() loop that is equivalent to the new memblocks_present() helper. Signed-off-by: Logan Gunthorpe Cc: Yoshinori Sato Cc: Rich Felker Cc: Dan Williams Cc: Rob Herring --- arch/sh/mm/init.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/arch/sh/mm/init.c b/arch/sh/mm/init.c index 7713c084d040..f601f96408ee 100644 --- a/arch/sh/mm/init.c +++ b/arch/sh/mm/init.c @@ -235,12 +235,7 @@ static void __init do_init_bootmem(void) plat_mem_setup(); - 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)); - } + memblocks_present(); sparse_init(); } From patchwork Fri Oct 5 16:16:42 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Logan Gunthorpe X-Patchwork-Id: 10628421 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 24A491515 for ; Fri, 5 Oct 2018 16:17:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0D35529A22 for ; Fri, 5 Oct 2018 16:17:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 008C929A2C; Fri, 5 Oct 2018 16:16:59 +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 33C9729A22 for ; Fri, 5 Oct 2018 16:16:59 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 55C176B000C; 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 534726B0266; 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 3FBA26B026A; 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-f71.google.com (mail-io1-f71.google.com [209.85.166.71]) by kanga.kvack.org (Postfix) with ESMTP id 0A67C6B0266 for ; Fri, 5 Oct 2018 12:16:51 -0400 (EDT) Received: by mail-io1-f71.google.com with SMTP id l4-v6so12567347iog.13 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=yr/TP9feZ8IG/94MebYaG/K7p/cv35Gm1W1B2mzgYys=; b=kAT5hhZkWhGDxpjBLnfnJdTqWEWK7lxDcIcJvrfF5hiNAVwION55t6Fe8y9gvn3L6s Kn9Cj4JluVVte1IsHjcFWqDVvCgbGPtLlrfs+/ztVw1wPkOQ1yKGsPd1HJHAFrRat6Fg Y/GFvu2CuF96FtBwlu0w8sFC7zKFvmsQoBPFexjnYmVtpWyzuKO0lBT2B7GNLh7vvlM8 DIMpq9XlzIwXM7QlZgQhTkV9xfXVmrCr8DH55RofVjQOisgzV5OkxayajNuWM6zyAWuv ofsc829wie9aAXQcNnHHBGUwfhpSVurQWYDRcmjdoE4k/D7uaOxTDISbyPkAGmsX7hv9 Aktw== 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: ABuFfohUWEOFMc1EcBb6EtN5MLWyXQf/BXkK77jFGsji4yn++s/H7fzv FeSMjDgOBW3s3A1WxPhCEim5402F8q3ezipZiwYmE4H1kcGCmkH0K+VOsOUN+iYmtOitDNF6rZ7 wFfKN58iuFlH67f3sQH0YCqiGtWxM8eQj4StniVyYvJ2bq+TzhXx3Asjnl77h/x60Rg== X-Received: by 2002:a24:2f85:: with SMTP id j127-v6mr10191035itj.56.1538756210792; Fri, 05 Oct 2018 09:16:50 -0700 (PDT) X-Google-Smtp-Source: ACcGV62oKxi+HiC2IqF3gAApBagmpYgjMMK30sEHt71PONIvokKscXGTrwKUO6wn0+rzTnGvTLTW X-Received: by 2002:a24:2f85:: with SMTP id j127-v6mr10190970itj.56.1538756209923; 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=052IxiXGWWp9Xv59TOlHy60gjA+iAVUILsErrHqVNGlc3cUukUcO28UEeytwYQ/YJK 2RpeGMLO0iYdfA5D88dCG4yZNhvNI1+RO41FdwKzzTHRv7Mkcr17T5ejN+ipOeYW3SFb wh/Pbb2I7PTnsxp5RpHTDTOXcq4Ar7E36/uGv92aSslpBctLlJ3QawRNstLb28k/PCYN diBuitpwcEvK3N/Zpx7Ll/CVTWGbhZ52XvC6lVadNmESFKQjop5rlSxLJqU3O2a2r/3z LtdOfmLffE+XuUKx9pvdP4OEVghwadYLHvlW05WUXPOtx+bT1hwiG8iNGU/pPUX0WUkn SGJQ== 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=yr/TP9feZ8IG/94MebYaG/K7p/cv35Gm1W1B2mzgYys=; b=0JCFIzTvSBz6nKnZwT+9apV6U+rYwdGRrdq7g/HjC8ZZlTvQuCUWmbxlsfil+HzmJU Pg/QBOPopCGVwEtQhlfFSIuEHyb/ulvZd+k6RKjD0hUaX8xMBo9Nt7yCNEKabls9HygS XlVUVfQCdBFo9Q/ZhJ2MUg+tdJj/+ReDPPncrRo6OzRhIH5r64voheEM1t5vRyHKm7bg vklgjaNx/4WlZvuMpkyjM6oR3H7j5ecWnz4lhizVSp1HMqpbP/JQeFfG4n69ICmuyefC JgxJ6wm+Zr14Pet98V1/MRD7NxfAjCknVfCl7GJ0OU/p1hidg6QhoNfMIYfYt54x3axx ujOw== 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 e64-v6si1014172iof.46.2018.10.05.09.16.47 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 05 Oct 2018 09:16:48 -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 1g8SmT-0008D6-Oi; 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 1g8SmS-0000ej-BG; 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 Waterman , Olof Johansson , Michael Clark , Rob Herring , Zong Li Date: Fri, 5 Oct 2018 10:16:42 -0600 Message-Id: <20181005161642.2462-6-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, aou@eecs.berkeley.edu, hch@lst.de, logang@deltatee.com, palmer@sifive.com, andrew@sifive.com, olof@lixom.net, michaeljclark@mac.com, robh@kernel.org, zong@andestech.com X-SA-Exim-Mail-From: gunthorp@deltatee.com Subject: [PATCH 5/5] RISC-V: Implement sparsemem 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 patch implements sparsemem support for risc-v which helps pave the way for memory hotplug and eventually P2P support. We introduce Kconfig options for virtual and physical address bits which are used to calculate the size of the vmemmap and set the MAX_PHYSMEM_BITS. The vmemmap is located directly before the VMALLOC region and sized such that we can allocate enough pages to populate all the virtual address space in the system (similar to the way it's done in arm64). During initialization, call memblocks_present() and sparse_init(), and provide a stub for vmemmap_populate() (all of which is similar to arm64). Signed-off-by: Logan Gunthorpe Cc: Palmer Dabbelt Cc: Albert Ou Cc: Andrew Waterman Cc: Olof Johansson Cc: Michael Clark Cc: Rob Herring Cc: Zong Li Reviewed-by: Palmer Dabbelt --- arch/riscv/Kconfig | 23 +++++++++++++++++++++++ arch/riscv/include/asm/pgtable.h | 24 ++++++++++++++++++++---- arch/riscv/include/asm/sparsemem.h | 11 +++++++++++ arch/riscv/kernel/setup.c | 4 +++- arch/riscv/mm/init.c | 8 ++++++++ 5 files changed, 65 insertions(+), 5 deletions(-) create mode 100644 arch/riscv/include/asm/sparsemem.h diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig index a344980287a5..a1b5d758a542 100644 --- a/arch/riscv/Kconfig +++ b/arch/riscv/Kconfig @@ -52,12 +52,32 @@ config ZONE_DMA32 bool default y if 64BIT +config VA_BITS + int + default 32 if 32BIT + default 39 if 64BIT + +config PA_BITS + int + default 34 if 32BIT + default 56 if 64BIT + config PAGE_OFFSET hex default 0xC0000000 if 32BIT && MAXPHYSMEM_2GB default 0xffffffff80000000 if 64BIT && MAXPHYSMEM_2GB default 0xffffffe000000000 if 64BIT && MAXPHYSMEM_128GB +config ARCH_FLATMEM_ENABLE + def_bool y + +config ARCH_SPARSEMEM_ENABLE + def_bool y + select SPARSEMEM_VMEMMAP_ENABLE + +config ARCH_SELECT_MEMORY_MODEL + def_bool ARCH_SPARSEMEM_ENABLE + config STACKTRACE_SUPPORT def_bool y @@ -92,6 +112,9 @@ config PGTABLE_LEVELS config HAVE_KPROBES def_bool n +config HAVE_ARCH_PFN_VALID + def_bool y + menu "Platform type" choice diff --git a/arch/riscv/include/asm/pgtable.h b/arch/riscv/include/asm/pgtable.h index 16301966d65b..20c49cded686 100644 --- a/arch/riscv/include/asm/pgtable.h +++ b/arch/riscv/include/asm/pgtable.h @@ -89,6 +89,26 @@ extern pgd_t swapper_pg_dir[]; #define __S110 PAGE_SHARED_EXEC #define __S111 PAGE_SHARED_EXEC +#define VMALLOC_SIZE (KERN_VIRT_SIZE >> 1) +#define VMALLOC_END (PAGE_OFFSET - 1) +#define VMALLOC_START (PAGE_OFFSET - VMALLOC_SIZE) + +/* + * 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 + +#define VMEMMAP_SIZE (UL(1) << (CONFIG_VA_BITS - PAGE_SHIFT - 1 + \ + STRUCT_PAGE_MAX_SHIFT)) +#define VMEMMAP_END (VMALLOC_START - 1) +#define VMEMMAP_START (VMALLOC_START - VMEMMAP_SIZE) + +#define vmemmap ((struct page *)VMEMMAP_START) + /* * ZERO_PAGE is a global shared page that is always zero, * used for zero-mapped memory areas, etc. @@ -411,10 +431,6 @@ static inline void pgtable_cache_init(void) /* No page table caches to initialize */ } -#define VMALLOC_SIZE (KERN_VIRT_SIZE >> 1) -#define VMALLOC_END (PAGE_OFFSET - 1) -#define VMALLOC_START (PAGE_OFFSET - VMALLOC_SIZE) - /* * Task size is 0x40000000000 for RV64 or 0xb800000 for RV32. * Note that PGDIR_SIZE must evenly divide TASK_SIZE. diff --git a/arch/riscv/include/asm/sparsemem.h b/arch/riscv/include/asm/sparsemem.h new file mode 100644 index 000000000000..4563e806c788 --- /dev/null +++ b/arch/riscv/include/asm/sparsemem.h @@ -0,0 +1,11 @@ +/* SPDX-License-Identifier: GPL-2.0 */ + +#ifndef __ASM_SPARSEMEM_H +#define __ASM_SPARSEMEM_H + +#ifdef CONFIG_SPARSEMEM +#define MAX_PHYSMEM_BITS CONFIG_PA_BITS +#define SECTION_SIZE_BITS 30 +#endif + +#endif diff --git a/arch/riscv/kernel/setup.c b/arch/riscv/kernel/setup.c index aee603123030..89fa781a9bf8 100644 --- a/arch/riscv/kernel/setup.c +++ b/arch/riscv/kernel/setup.c @@ -205,6 +205,9 @@ static void __init setup_bootmem(void) PFN_PHYS(end_pfn - start_pfn), &memblock.memory, 0); } + + memblocks_present(); + sparse_init(); } void __init setup_arch(char **cmdline_p) @@ -239,4 +242,3 @@ void __init setup_arch(char **cmdline_p) riscv_fill_hwcap(); } - diff --git a/arch/riscv/mm/init.c b/arch/riscv/mm/init.c index 58a522f9bcc3..5d529878667c 100644 --- a/arch/riscv/mm/init.c +++ b/arch/riscv/mm/init.c @@ -70,3 +70,11 @@ void free_initrd_mem(unsigned long start, unsigned long end) { } #endif /* CONFIG_BLK_DEV_INITRD */ + +#ifdef CONFIG_SPARSEMEM +int __meminit vmemmap_populate(unsigned long start, unsigned long end, int node, + struct vmem_altmap *altmap) +{ + return vmemmap_populate_basepages(start, end, node); +} +#endif