From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 07EBFC6FD1A for ; Tue, 7 Mar 2023 16:43:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:From:References:Cc:To: Subject:MIME-Version:Date:Message-ID:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=hYUUrEiC3nEo+ItbaHWOlDv/u2VseuQcIl0Z1B6BKeg=; b=G+W/FkwVeMCBz3 AkP4c1jMisWkSOpn6/C4wLAUXjx+j2usQYQMw1fReGCoNPQbq2rIe7dUAirLeoh9re0tgE9afUKjl 9mm1K2gK0JKVo7euyCHTgRJ1UsEUcFR1TdF+Ywi/+3MhPDYYsGtDkRgj3YMhz/xJt/NNYHejNNuYQ QPZwVSYoJrDvCgfifx5CWpkwGK+MsAaLSUPs1gfzzM8rrtQjfhAB1imX/tB6xhuHgRHXgsFFdHTYS qst2y8BkKXHYdY+Fda3T2n+G9qmgIXUqQyitr9uCjouJ1N9ccIIAmEqab+oSQnFbJSf9ivG7F4gGu RF633qQMWV9SZBmRn8dQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pZaOn-001cKK-Cu; Tue, 07 Mar 2023 16:42:49 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pZaOi-001cIe-4w for linux-arm-kernel@lists.infradead.org; Tue, 07 Mar 2023 16:42:46 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 3010411FB; Tue, 7 Mar 2023 08:43:22 -0800 (PST) Received: from [10.1.29.181] (C02CF1NRLVDN.cambridge.arm.com [10.1.29.181]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 791653F67D; Tue, 7 Mar 2023 08:42:37 -0800 (PST) Message-ID: <8e931b7c-3c10-10f7-5d59-546b1a9d5735@arm.com> Date: Tue, 7 Mar 2023 16:42:36 +0000 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.8.0 Subject: Re: [PATCH v3 09/60] arm64: mm: Reclaim unused vmemmap region for vmalloc use Content-Language: en-US To: Ard Biesheuvel , linux-kernel@vger.kernel.org Cc: linux-arm-kernel@lists.infradead.org, Catalin Marinas , Will Deacon , Marc Zyngier , Mark Rutland , Anshuman Khandual , Kees Cook References: <20230307140522.2311461-1-ardb@kernel.org> <20230307140522.2311461-10-ardb@kernel.org> From: Ryan Roberts In-Reply-To: <20230307140522.2311461-10-ardb@kernel.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230307_084244_293721_86C4F9D4 X-CRM114-Status: GOOD ( 21.52 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On 07/03/2023 14:04, Ard Biesheuvel wrote: > The vmemmap array is statically sized based on the maximum supported > size of the virtual address space, but it is located inside the upper VA > region, which is statically sized based on the *minimum* supported size > of the VA space. This doesn't matter much when using 64k pages, which is > the only configuration that currently supports 52-bit virtual > addressing. As I understand it, the vmemmap section only holds struct pages, and the number of struct pages in the system is surely a function of PA size, not VA size? So why is the region sized based on VA size? > > However, upcoming LPA2 support will change this picture somewhat, as in > that case, the vmemmap array will take up more than 25% of the upper VA > region when using 4k pages. Given that most of this space is never used > when running on a system that does not support 52-bit virtual > addressing, let's reclaim the unused vmemmap area in that case. > > Signed-off-by: Ard Biesheuvel > --- > arch/arm64/include/asm/pgtable.h | 8 ++++++-- > 1 file changed, 6 insertions(+), 2 deletions(-) > > diff --git a/arch/arm64/include/asm/pgtable.h b/arch/arm64/include/asm/pgtable.h > index 3eff06c5d0eb73c7..2259898e8c3d990a 100644 > --- a/arch/arm64/include/asm/pgtable.h > +++ b/arch/arm64/include/asm/pgtable.h > @@ -18,11 +18,15 @@ > * VMALLOC range. > * > * VMALLOC_START: beginning of the kernel vmalloc space > - * VMALLOC_END: extends to the available space below vmemmap, PCI I/O space > - * and fixed mappings > + * VMALLOC_END: extends to the available space below vmemmap > */ > #define VMALLOC_START (MODULES_END) > +#if VA_BITS == VA_BITS_MIN > #define VMALLOC_END (VMEMMAP_START - SZ_8M) > +#else > +#define VMEMMAP_UNUSED_NPAGES ((_PAGE_OFFSET(vabits_actual) - PAGE_OFFSET) >> PAGE_SHIFT) > +#define VMALLOC_END (VMEMMAP_START + VMEMMAP_UNUSED_NPAGES * sizeof(struct page) - SZ_8M) > +#endif > > #define vmemmap ((struct page *)VMEMMAP_START - (memstart_addr >> PAGE_SHIFT)) > _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel