From patchwork Mon Oct 15 17:56:57 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Logan Gunthorpe X-Patchwork-Id: 10642289 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 39B4C13AD for ; Mon, 15 Oct 2018 17:57:25 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2AC362984E for ; Mon, 15 Oct 2018 17:57:25 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1F19F298CA; Mon, 15 Oct 2018 17:57:25 +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 8B5EF2984E for ; Mon, 15 Oct 2018 17:57:24 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8D2BA6B0007; 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 8305C6B000C; 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 682F36B000D; 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-f199.google.com (mail-it1-f199.google.com [209.85.166.199]) by kanga.kvack.org (Postfix) with ESMTP id 36B7B6B0007 for ; Mon, 15 Oct 2018 13:57:18 -0400 (EDT) Received: by mail-it1-f199.google.com with SMTP id z136-v6so23111974itc.5 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=Q2/22PJP5KiW9SOBKPYV29chcTBnVKjNVxRDnLt6F18=; b=UdCM835kAXdnrcxD++e5GOsqgLk7UhFBzfNapqFN2/gHXvn+ydtp6anQ/OxlXdQcec ocZKA9ZvwT9RMltt5tzvQCl0C+bdvI5X/kx+UV0+CE31ovxwTNzI3kxz1T40cG52tJnT VN8Neg8V3ZLWqyoSSVNXV4zBmtOWi1oR8uizqUgcCuIXrnTteYOdj7oqQF+WFfu4gUEm bTlWoYPSy617l6/x8OBRrijPh996uJKU4ZP7FfSPF42SIvOOPujmm6pIz2rXYq7G8XcO 2l373BdN77Xj/gbAd4wHRaiCijzPi9eP72N+yjejYmLjgx4M7Q21dO/YvNQHPKkf8lg2 Geig== 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: ABuFfoiEDhbvjDb0NSUy6nw9z5QyBsBt3+7WuimGyNp28m/0V14lnc4i tYg72JENu1b6p0hb2VDzTA/ckiTkdVOvPTfhLL32D4MgP6sxHZxwaYjs7ndLy5C3Y64c3haV+bu 2X2soeUSCU9PwZmIuMeJkyZSb51RzFhjKjN+H0cdY90xrKb0ZcpQZb/C22jDO1LVheQ== X-Received: by 2002:a24:ac53:: with SMTP id m19-v6mr12533615iti.147.1539626237930; Mon, 15 Oct 2018 10:57:17 -0700 (PDT) X-Google-Smtp-Source: ACcGV6105B61rJb+4V6S34Z7f57wFLnqfPy/WieGzdf0CANTfKgp03E2aN6YswXCT7TfeT6+TfYh X-Received: by 2002:a24:ac53:: with SMTP id m19-v6mr12533582iti.147.1539626237143; 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=XKoZx3VT2gM0nbDq+qn2JA3DQZ92UvhwUumr41TT6qHjSUUYbRzwILIycHHbqEpRt8 jgyVxOfp0FcVnwQkocXu+UHZ/hueeepwDzhkOMSXtYTU1PJLsCkqrDjq9eDVr5Dxz7Hu 4N+MxX681WxfOE/UKTE9zNSsUyOVJE98KgtToy3jPVZSPZGqqSTByKJuv9xWjpPJ4ebH LGrPxxYfmYl/woPEWrZHu+WMcyou8oHzR4zujkRjRdJg7Ad23Xenpq5pJabZxB2hpDG0 WrwWw8DoUwUMOSoHyNfDDt0gkXZd7TYGxrz052rXAs8LCZgeZRVjllw4xJB2kQnQHgHP memw== 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=Q2/22PJP5KiW9SOBKPYV29chcTBnVKjNVxRDnLt6F18=; b=mtiEwYgF6uLkar4uZ/T/AQJLPcwdvPGF64l96UtZ+OaqGVBrV7znWqUqzhNZOiX0S2 M6vUWAgkEYwflqaHQU4tVqbCOsHuomLYcDHYTCfB6/IgzgEF2eB5UakoRkrmUobB27GZ 4PWFj9vnFTTkxXNr+ABfSrly5if07eSsWiwXiCKHdNqEC7hu0ZmezTTeGIfKMM61XwR7 NXY9z5s17nA21En80jgCWxM2e0icvCVuketggCmcqCvKPLFPiOiOsTaTov9fyD2G2KT/ /cpAcEH6UD/Bibkrytcu9YV8kolHsl/Z3CINaDeG7YnoMi9jK4VtelNqiDm8Q7bRx04z IJ7Q== 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 a204-v6si7556442ita.40.2018.10.15.10.57.16 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 1gC77C-0002II-7K; 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-0002Ma-0e; 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 , Catalin Marinas , Will Deacon Date: Mon, 15 Oct 2018 11:56:57 -0600 Message-Id: <20181015175702.9036-2-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, catalin.marinas@arm.com, will.deacon@arm.com X-SA-Exim-Mail-From: gunthorp@deltatee.com Subject: [PATCH v2 1/6] 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 Cc: Catalin Marinas Cc: Will Deacon Cc: Arnd Bergmann Cc: Andrew Morton Cc: Christoph Hellwig Acked-by: Will Deacon --- 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 787e27964ab9..6a0b5c5a61af 100644 --- a/arch/arm64/mm/init.c +++ b/arch/arm64/mm/init.c @@ -615,14 +615,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..ec8c16d9396b 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 ilog2(roundup_pow_of_two(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 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 From patchwork Mon Oct 15 17:56: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: 10642299 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 74FF6109C for ; Mon, 15 Oct 2018 17:57:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6837C2984E for ; Mon, 15 Oct 2018 17:57:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5C61D298CA; Mon, 15 Oct 2018 17:57:38 +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 7DDF72984E for ; Mon, 15 Oct 2018 17:57:36 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6AEBF6B0269; Mon, 15 Oct 2018 13:57:20 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 63BC46B026A; Mon, 15 Oct 2018 13:57:20 -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 3C5196B026B; Mon, 15 Oct 2018 13:57:20 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-it1-f200.google.com (mail-it1-f200.google.com [209.85.166.200]) by kanga.kvack.org (Postfix) with ESMTP id 0BFC56B0269 for ; Mon, 15 Oct 2018 13:57:20 -0400 (EDT) Received: by mail-it1-f200.google.com with SMTP id z136-v6so23112104itc.5 for ; Mon, 15 Oct 2018 10:57:20 -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=mq4QtvYHSMhQdcMuVA2j3k3DUiWW7bfEBg/DlAVzixM4s/wsYwqvoOBgVgLzj6C1vb ZSxc5JZhKwplZNmh5l6EM8DUhMd8Z3vNk1ehw/W7KnEcpz4Se9kq5GVzH+Dl7LFbGgRQ k/AUfjfKTTfpmKmqfVvpgnSfXxu5ltzGKcVzM++m21w6jxsYbFpJmFwJ+SPxaXS7Mwgm nzSgD7vt4ZeFonIyBq/fNLOwa+cRwYJ3hYYncZ0FWBmfOFNEuK/cplgPOo7+2VchAIiI 4nMr6ewB5Fu4igVWpM92RciGMi2QGc+AyhnEewNr63qKOVpe6HbCd1kJSDQSf8RqKZFK sPfQ== 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: ABuFfohlfhAM14rYFKxs7zjyLAM/RuwpuYHAVuL+ry/sGSx2Uk10arvp Z6nsAvJF1k1AbqOYUTdk30/iggMBM9VgSkG/MxOsL2uMqdOc9B9EAYV7wFEVyRgiQTMdFjET6lI kAvS9zcTqs8i/B+d5ntDAK9C3lonYdP4KYEQRYgDX/4LdLv+ikAgO1cDHB9BbKyCOlw== X-Received: by 2002:a6b:d611:: with SMTP id w17-v6mr12393840ioa.216.1539626239777; Mon, 15 Oct 2018 10:57:19 -0700 (PDT) X-Google-Smtp-Source: ACcGV61cU/yWM45ostcyCHhB5jXyaSmx7HAAr3H/S3Dv2dGADMlcrZ9CX6XXc3gcsmcrHUpOQ1ei X-Received: by 2002:a6b:d611:: with SMTP id w17-v6mr12393813ioa.216.1539626239135; Mon, 15 Oct 2018 10:57:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539626239; cv=none; d=google.com; s=arc-20160816; b=xiWU++L83liKz6SzN8PVV9zL0LLFU3Psue9xtAFmyj7L+xx7YK3KXCEzr9wHupKq1Z qJFxMlg2WgPIW2TmprkXuqzBorTRGgQLyjluVVdzm2XwhteiU6Q8FTCsN+c76oTe+xsf qjTYzKMZzFOzfmzItSPB+UdNqRbOlHWfsHNKC6+uGZw6VZxaMQqhLawFKo4rvGMkHSzB 0r9bLto4KqHssEWtWBCGl1C6kFZvTru3NPhOkEypAZSAI7hMTwZXyo14fRE72SXHI0M4 FNb9holmme7G93YeM5jdYi0Ztfz0uHX26HxayP3sI1C2qaBd/2PcJQkfJeteanTkkvXh VPLg== 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=tKYYLA0ZTWJ8UaAU7NUz3Xgi/201j2DVUerC9Qpw/IAyYD7dJeTRzf4oSecGhhe7mp SORFsoPqeWT26nOqdajAsEKqfcdoZHvTSY4l/zkwjXPgqcYoKZsKhinEjvu27GzEmau4 wYMr9axlFsXflZ6kORlCX+92DRDqqEdBUAbR60R8OjGByL9avajkiRNEcfHualGVt0Jg b8ftBR7JyjcCDamHECcubjIgNFzKPohfkD7iLqfsf57S/4BILRFTubnQmcs1Mo1NSjzT 02SOU3empZjky4DqrLFtTSuoXl341eFEHkd89l8SEG9qScyA2BZk18Lx9qVdwpdyq6Eb q1Zw== 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 t140-v6si8143869itf.139.2018.10.15.10.57.18 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 15 Oct 2018 10:57:19 -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-0002IK-Pi; Mon, 15 Oct 2018 11:57:18 -0600 Received: from gunthorp by cgy1-donard.priv.deltatee.com with local (Exim 4.89) (envelope-from ) id 1gC779-0002Mg-AI; 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 , Russell King , Kees Cook , Philip Derrin , "Steven Rostedt (VMware)" , Nicolas Pitre Date: Mon, 15 Oct 2018 11:56:59 -0600 Message-Id: <20181015175702.9036-4-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, 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 v2 3/6] 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 Mon Oct 15 17:57:00 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Logan Gunthorpe X-Patchwork-Id: 10642287 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 6DE28109C for ; Mon, 15 Oct 2018 17:57:22 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5F6B32984E for ; Mon, 15 Oct 2018 17:57:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 535A6298CA; Mon, 15 Oct 2018 17:57:22 +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 C23D12984E for ; Mon, 15 Oct 2018 17:57:21 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C4E686B0006; Mon, 15 Oct 2018 13:57:17 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id C24606B0007; Mon, 15 Oct 2018 13:57:17 -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 AEC4D6B000C; Mon, 15 Oct 2018 13:57:17 -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 836986B0007 for ; Mon, 15 Oct 2018 13:57:17 -0400 (EDT) Received: by mail-io1-f71.google.com with SMTP id m7-v6so19501466iop.9 for ; Mon, 15 Oct 2018 10:57:17 -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=F3AcXnh1HyzAbBQ9lssNNroRP37cDvf3IpGQVMtb+Jw=; b=L8P8o0Vi9ZSnylqxhAZdA5QhbFNfyS+VyOWCeDky18jE7lG35XNxfrKI9rhGvcbDUP NPpwjQV/oWIcQ62nicnnou/DchbtMd9rtlpNTffxgMDiKHXxKro9IyJGpvVh5Yw4D3b0 1xkWA+SFhXALwyNK9sqJu1DPYANuMtR1FFyMhfPT4afa1Qb1ABJLV1jFpEysJ4uPPyvQ eh9rvTKG025N1hAoojtv2WJvPQYkAACzmeeGmGbtv+C+yhk0h+QOB0vZyyx0nHwrP/d3 /MueHkTTkeEsTo6h30l0ppo5cY0MpyYMYQrzLugtoxY7PKlloTTF/Q5fuo0QYt5MWGSm G2ww== 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: ABuFfog8plsmA1ZmmhTw4L2VN59bvzqAfvpfzN9v5zA+7m9C+Gvk22z1 rC5Z3MkiHq+gS1bq6ZtKJgt6sgBBnh21GjIvsPmIZpEgLd4JnRr1d3vAOakclnrGISHw24tNZH1 U4VATw5gOcjOc+nS/l62qSkcuQYh1ELzSwXTt0FlFQvI14qEYeacc914ArHOft1O5sg== X-Received: by 2002:a02:a087:: with SMTP id g7-v6mr14072154jah.92.1539626237290; Mon, 15 Oct 2018 10:57:17 -0700 (PDT) X-Google-Smtp-Source: ACcGV63MM6nhVTNmovNhiCjgLYGvoIkrieysByjFySTzKclbw6f2C3pB4qdfTRdk/CVr5jRsRz4W X-Received: by 2002:a02:a087:: with SMTP id g7-v6mr14072123jah.92.1539626236663; Mon, 15 Oct 2018 10:57:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539626236; cv=none; d=google.com; s=arc-20160816; b=mmFRORYplGwKCLlQLvJkcmLmLkEvDdwctw/73AnCjAL4JUL6yyyRZ1IAVlcTwOiAHC qH6YcJ6w9UpSaj0/PrZdh17Te9KaMCNci5SGLG4JvoznHTWlbMD1DoZxJIyv845TnrxN AO91gN/ETFbBfhF4CPYpgMeYvcBoRHvAJM2/C9XsNjuwJwX7sbpidLwDalcrUBov77Ma rvuULd7q34NonADSuFGcGD3toBk4MV9Et8q9bR6qpEdRzwjg8PPK63+dYzVHyrXMqcj7 9Nc2nYlKvwJYuSgii7KperPZ8nt4c7G74gj9IXfoKHnWzpOJGzul7sNmHnAypHNpztDG c0Dg== 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=F3AcXnh1HyzAbBQ9lssNNroRP37cDvf3IpGQVMtb+Jw=; b=oFZn4rBrU/s3JC3/bi+PU4+tkz4IwMZFeaZ07L8uEwZPy5n3w4en8tE6KH2RCia8JQ qRi4tRPbTO2P/VsKwQY55IoY6PZG2jQQmss3nQZ3OKBQ5hsdMUaucuE28TtGWXM8XI+Y b6LrlOfG0FIR9OJNm1uj4NgafQvSrWBWqNdcEks3h/0rg68Eor1PE4g5JIZe2PJ0ukLI /lhjlPCj/2rggoxRLmnHcvAjqGBXT2JN9TMyGQkMv3NRw/T3MH/31KKW55VtRQ25xQ3t /VF/i6P2WPEGJ1WsH+mJFFt/mfuxm97gjMxIokdusEnBMa4el8z6yj7e3FX78sktruTD +Lpg== 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 g80-v6si8054459jae.116.2018.10.15.10.57.16 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 15 Oct 2018 10:57:16 -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 1gC77C-0002IL-7I; Mon, 15 Oct 2018 11:57:15 -0600 Received: from gunthorp by cgy1-donard.priv.deltatee.com with local (Exim 4.89) (envelope-from ) id 1gC779-0002Mj-F4; 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 , Will Deacon Date: Mon, 15 Oct 2018 11:57:00 -0600 Message-Id: <20181015175702.9036-5-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, will.deacon@arm.com X-SA-Exim-Mail-From: gunthorp@deltatee.com Subject: [PATCH v2 4/6] 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 Cc: Will Deacon --- 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 6a0b5c5a61af..c51a944fe19f 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 Mon Oct 15 17:57:01 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Logan Gunthorpe X-Patchwork-Id: 10642297 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 368D73B73 for ; Mon, 15 Oct 2018 17:57:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 278F32984E for ; Mon, 15 Oct 2018 17:57:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1B72E298CA; Mon, 15 Oct 2018 17:57:34 +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 85B6329863 for ; Mon, 15 Oct 2018 17:57:33 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8CD7B6B0010; Mon, 15 Oct 2018 13:57:19 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 87B666B0266; Mon, 15 Oct 2018 13:57:19 -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 71E7F6B0269; Mon, 15 Oct 2018 13:57:19 -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 269F86B0010 for ; Mon, 15 Oct 2018 13:57:19 -0400 (EDT) Received: by mail-io1-f69.google.com with SMTP id z9-v6so16895031iog.18 for ; Mon, 15 Oct 2018 10:57:19 -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=shw3kfS+u/CVWdxjm2B2SFOlB0tif8qCVf02XrqjMRXUidZ8YALio9JXP8kL7cwT8F D1rOyv+/KFX/rLjwB9z7nlfrtu01ANs3z816jNG0R0pDD3w8UU7HblDj1+NSEWIx8P8l HYBvFYTZzR0IE7f0cbzG5C+bbqWnhepX6DkooxcIiylR7kXY47t3dFMSTeXut/hNnW6R 2uyy/8JTqywvBAVcfyEzwU44aC7jUII3NRffXXFlPoHU7OVwfb/FfsxcynY90rN7nmFd 93GJ1UjtGMoZaqO+aBx+qOoWNly5qyfTVLjbCRdMW2JZIEHbA2MIuzCOuh3JxQxCWdJE YC8A== 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: ABuFfohc22Es2IcV3WHbbSt3j8I/bcfCE579H8QS6k/ukv/QNT1WNr98 BlK5CCccYxl7jCbfwrj/8y7jzBk2Kg0eSzMYqUcEkYbLRmyyPjwRBmR5zY4TjScZKuhTwADhkHb McRCiTUiSXHiSvpjwCiDDS+b93kUMQ/PFyrTkLhq/OFIF4kQXO8EF4QzY6yTYJYu9/A== X-Received: by 2002:a24:3795:: with SMTP id r143-v6mr13647061itr.43.1539626238916; Mon, 15 Oct 2018 10:57:18 -0700 (PDT) X-Google-Smtp-Source: ACcGV63V34orFap1jvzo/kfvps7lCzbUHuZT2gnzNF3mlpZYIlPDnLlslovCMQdmo0BfAVMoPuiQ X-Received: by 2002:a24:3795:: with SMTP id r143-v6mr13647033itr.43.1539626238318; Mon, 15 Oct 2018 10:57:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539626238; cv=none; d=google.com; s=arc-20160816; b=fmfdHdpEFUkAyuG2WxT8u+PtD0xWTO4KsO7Gdq9JRvGQYZ0RZfBHD7o6GxepXeFOEo tleI+Udq4na2CxH0te0XIx8h1SuvAPN0Bj+9QWDbGXknQkHpylXWwsDnasJBfK6MMFSI pjqBKig2aHGsixuBEhUhObdgcp/Jw5jnIZ3Bk8hmXGNz/gkhmnm/ayDNTlCNJy6Ge7hc mVn7FRsD+FM+GV4m60BROJ9POvV/V6l6tXXPh8JT8GtK2DQLq902neOwgwKIhnupFgb2 l+sNDOyRX4HMGVjvxtKQZ+Kh/6an7+R8W+Dmz8f1MB6dkY65Mey2NO6UnSfAF1d5lrS2 k/Jg== 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=lfZaD/dHMj7QhvXu70hUTYrPH58chIbOHcT6sIjMsTCJjgA5rKdctlLU3bXGqE/rSp +ABc/THk0GB7WXOvyalsx9cP8nM52DF8IbY1LzEwqMQa7tN/ZCF+iVbJh6zrF1h1AuKy Exw+OBHgOpSBFbLo7wdvJMPw61N1AKX6rNS54jrxqmosJerFzlG6mglXSjp06028JBLv UYPP5lJ836mza1GiXVPyU9ogN9QfFX2EvmDYca5wMZ5nZCDx6p2ixVZSiq5ibT5RH6GE 2ZvvlWCqOiJMtxsecWZ0ilxOUvTpypSxPAeXM6g99ykw0Ff1nIxmwuBaw4b8M6i6prQX yImQ== 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 g10-v6si7513145jag.125.2018.10.15.10.57.18 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 15 Oct 2018 10:57:18 -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 1gC77C-0002IM-K6; Mon, 15 Oct 2018 11:57:17 -0600 Received: from gunthorp by cgy1-donard.priv.deltatee.com with local (Exim 4.89) (envelope-from ) id 1gC779-0002Mm-IN; 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 , Yoshinori Sato , Rich Felker , Dan Williams , Rob Herring Date: Mon, 15 Oct 2018 11:57:01 -0600 Message-Id: <20181015175702.9036-6-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, 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 v2 5/6] 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 Mon Oct 15 17:57:02 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Logan Gunthorpe X-Patchwork-Id: 10642293 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 53B5E109C for ; Mon, 15 Oct 2018 17:57:31 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 43A7C2984E for ; Mon, 15 Oct 2018 17:57:31 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 37F8A298CA; Mon, 15 Oct 2018 17:57:31 +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 62E0C2984E for ; Mon, 15 Oct 2018 17:57:30 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 489A56B000C; Mon, 15 Oct 2018 13:57:19 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 40F9B6B0266; Mon, 15 Oct 2018 13:57:19 -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 2B3786B0269; Mon, 15 Oct 2018 13:57:19 -0400 (EDT) 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 E220F6B000C for ; Mon, 15 Oct 2018 13:57:18 -0400 (EDT) Received: by mail-io1-f70.google.com with SMTP id x5-v6so19232664ioa.6 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=n4jIzrbnBCacqLnjvleqlZ7L9vWuleOBeEwBxh/6H+A=; b=tEnUo2eC4H1yym5y3lfqkIVl5ZCryalJ6SrU2Z8lLlg51F6jiuOK5yKZakpnAFQyMc kMSjkvPYl4dnZB7BzUytyfZ+BNkcW+AvA7gSpW0W1SMY6H84ynwo3hX6AxchI5T2qNiQ nTud3998L8+SH1EJpQJgIR9UQJPB/v3YjoBn6b7X90nnzYohvtNLsKfG+JTAuvx1HYo3 bGClK76CrQiH/QKkyUtCb3JqLONyz6OHY/nAcNG+LmbRqQHNytIrrrwE14iekXfohFjq NkIiwicGQQaEcD7HZjaNoLkw3kxGm/TqSpg/Ftlb7UUrYtHdGe6mmlBso4eHdEhItjPW TIEA== 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: ABuFfog0UqjZv0l8ILimabA7fMvjmsDtroLLK10r84AsB4gNllp+bjds G8QF6P8fpfLRbzyRPFMQjmrPjNFhvjNboQSEZmCqEO51tFjy4pCzwiDT+Pno3U7yenNNsVU9DZS FmlJN0fCTCYH61btRUpVW4vGX8IFaQlObulvm2wxujgbuVraKKZBZvLyienBBjyaTLw== X-Received: by 2002:a6b:c744:: with SMTP id x65-v6mr12154347iof.208.1539626238631; Mon, 15 Oct 2018 10:57:18 -0700 (PDT) X-Google-Smtp-Source: ACcGV62OcIlQwxtkTy2A09ih7nd/GHxIImPqfGMcDg+UFTeBIeCE28w/9yyGamtDqdm392YeUlcY X-Received: by 2002:a6b:c744:: with SMTP id x65-v6mr12154317iof.208.1539626237799; 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=E1mfmSOOUU5JC5qqWuX7cqgyHIiFuxqTdK97nLEMiKbI4c4o5y3rNZN9MYataMZ0qQ +hQfdrTNHmyXguhK8O3fwlWRxx3tJQFH0ksyiEVEVJMXOLTLEY9PjdkMyLOO8YjQrT2B nUWWlpg+eZvFe+yB4utgOlfpCrLcVCIUAqyrWg0wFy6HFySPw08F1yYQEI0ar60nmUuY Ps0YixyL9M05eQxhSz2XRMN/qvlFqaeuT5BfUhbFCYczrxIALaxjGgO+h/s1IupuY6oa hpy2vViHv+Y4DJFTBRxIDTV4GulJlsV/Bw4X+aZSC0Rra7vQ2TubFbusRiv27RZPsiQP bLRw== 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=n4jIzrbnBCacqLnjvleqlZ7L9vWuleOBeEwBxh/6H+A=; b=bRUq3gx+Zz5wXdLF2UFh9Lj8ieIsqY4PbdXQdPVeDMa/9vyoCion0QBPveVpJ7CrZs qsQKOb2K5QDNJSqvaENLn998srHjq6Mk35SHkK2tzvxcxUeNLMoZJEH/QYNjmkz8Kxsp ZjdlXd9szw5HNDYuu1ltGaaXrIpc1cvxtqR+B8FXOhYKDESxy6qPmcXZuatxbFRGs2Jg 0wL7syXMryOcvqbOZhyOPMzlz5Q0qNr6zQ1oAWyWk4nSpPlUlGMf4dDZOWD4ob/rupJ/ 8eX4HjzKmQYpJsCbN/pu/U+TG4MOIZxiCfgguMHPVGrUSavJNw4FRCpSNeN7r3IOXzsF CsBw== 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 j206-v6si7656523iof.77.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-0002IN-0U; 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-0002Mp-Lw; 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 , Andrew Waterman , Olof Johansson , Michael Clark , Rob Herring , Zong Li Date: Mon, 15 Oct 2018 11:57:02 -0600 Message-Id: <20181015175702.9036-7-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, aou@eecs.berkeley.edu, hch@lst.de, akpm@linux-foundation.org, arnd@arndb.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 v2 6/6] 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 Reviewed-by: Palmer Dabbelt Cc: Albert Ou Cc: Andrew Waterman Cc: Olof Johansson Cc: Michael Clark Cc: Rob Herring Cc: Zong Li --- arch/riscv/Kconfig | 23 +++++++++++++++++++++++ arch/riscv/include/asm/pgtable.h | 21 +++++++++++++++++---- arch/riscv/include/asm/sparsemem.h | 11 +++++++++++ arch/riscv/kernel/setup.c | 4 +++- arch/riscv/mm/init.c | 8 ++++++++ 5 files changed, 62 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..e1162336f5ea 100644 --- a/arch/riscv/include/asm/pgtable.h +++ b/arch/riscv/include/asm/pgtable.h @@ -89,6 +89,23 @@ 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) + +/* + * Roughly size the vmemmap space to be large enough to fit enough + * struct pages to map half the virtual address space. Then + * position vmemmap directly below the VMALLOC region. + */ +#define VMEMMAP_SHIFT \ + (CONFIG_VA_BITS - PAGE_SHIFT - 1 + STRUCT_PAGE_MAX_SHIFT) +#define VMEMMAP_SIZE (1UL << VMEMMAP_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 +428,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..215530b24336 --- /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 /* CONFIG_SPARSEMEM */ + +#endif /* __ASM_SPARSEMEM_H */ diff --git a/arch/riscv/kernel/setup.c b/arch/riscv/kernel/setup.c index b2d26d9d8489..494c380e4ea6 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