From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 178102D3ECF for ; Thu, 19 Feb 2026 16:09:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771517366; cv=none; b=DUoelKyTWna5EZvYhWsQ7si3191jlkVmWuGESIKgvQMy8IdltQ7cwzOCO3ydqLHqmgU6riQiYtaW63VJQeRu4NzZ67re2cL9koGM3aa5fV9CdNvrBvnxjf4Jreuu5pwOr/cmeUuL6W3O0KeA0RtDolE+3zaCUnIpTQjkBjQ/Ybc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771517366; c=relaxed/simple; bh=boOUalCJC3hYBCLJXs/ukOFBzgUXboyd5OOqwGud8VY=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=R6hnLyKqygKqiOjUTvevnNEqk6wCr/2gAnBCUsCQ2oJxAF084KGeCHU1zNWC30ExxiBEzbJVliTVnbla/1JRUEPcArIH6HtIz7CbVYPikyIphhkhCSpw5qhiGaMFEuuiayV8aJR9ginfrvVB/mz000zrDdnbSpgmnHIwEIsgTK4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=BGbCRqRF; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="BGbCRqRF" Received: by smtp.kernel.org (Postfix) with ESMTPSA id EAD21C4CEF7; Thu, 19 Feb 2026 16:09:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1771517365; bh=boOUalCJC3hYBCLJXs/ukOFBzgUXboyd5OOqwGud8VY=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=BGbCRqRF62S/hWsLFPP/eH9S7oEhgQkI6F31fs3obJTkY/3yxuBycefLwWlIsjUQv cWSbHuaEl2rod179UchNchRwkh24IZfoAd1Urqj/krGOA31btg3mrVvN/3gEIr1uGe JsOCDqubRBzpUuPr8FQk8x7LmiHUYDekHomTxuqznXCe/bc1Ak5B46p7A0S8JXk9Vf u4yG2DDkAn9nGWdLuazBRyyPRnnesFGhIQHda+Ha2FyH1ZrJ1dsfTI+QUY0ZnOp47d URrGlWdL4Kn+AlAqOxUYv9XLhgTbhiBmGMCE5YXjWZUjrv43QNJMYto85dG5vRp3fn OSi6eAx/udhjg== Message-ID: Date: Thu, 19 Feb 2026 17:09:20 +0100 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [LSF/MM/BPF TOPIC] 64k (or 16k) base page size on x86 To: Kiryl Shutsemau Cc: lsf-pc@lists.linux-foundation.org, linux-mm@kvack.org, x86@kernel.org, linux-kernel@vger.kernel.org, Andrew Morton , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , Lorenzo Stoakes , "Liam R. Howlett" , Mike Rapoport , Matthew Wilcox , Johannes Weiner , Usama Arif References: <915aafb3-d1ff-4ae9-8751-f78e333a1f5f@kernel.org> From: "David Hildenbrand (Arm)" Content-Language: en-US Autocrypt: addr=david@kernel.org; keydata= xsFNBFXLn5EBEAC+zYvAFJxCBY9Tr1xZgcESmxVNI/0ffzE/ZQOiHJl6mGkmA1R7/uUpiCjJ dBrn+lhhOYjjNefFQou6478faXE6o2AhmebqT4KiQoUQFV4R7y1KMEKoSyy8hQaK1umALTdL QZLQMzNE74ap+GDK0wnacPQFpcG1AE9R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3e EPcA/4NaBQJonNqrBQkmWAihAAoJEE3eEPcA/4NaKtMQALAJ8PzprBEXbXcEXwDKQu+P/vts IfUb1UNMfMV76BicGa5NCZnJNQASDP/+bFg6O3gx5NbhHHPeaWz/VxlOmYHokHodOvtL0WCC 8A5PEP8tOk6029Z+J+xUcMrJClNVFpzVvOpb1lCbhjwAV465Hy+NUSbbUiRxdzNQtLtgZzOV Zw7jxUCs4UUZLQTCuBpFgb15bBxYZ/BL9MbzxPxvfUQIPbnzQMcqtpUs21CMK2PdfCh5c4gS sDci6D5/ZIBw94UQWmGpM/O1ilGXde2ZzzGYl64glmccD8e87OnEgKnH3FbnJnT4iJchtSvx yJNi1+t0+qDti4m88+/9IuPqCKb6Stl+s2dnLtJNrjXBGJtsQG/sRpqsJz5x1/2nPJSRMsx9 5YfqbdrJSOFXDzZ8/r82HgQEtUvlSXNaXCa95ez0UkOG7+bDm2b3s0XahBQeLVCH0mw3RAQg r7xDAYKIrAwfHHmMTnBQDPJwVqxJjVNr7yBic4yfzVWGCGNE4DnOW0vcIeoyhy9vnIa3w1uZ 3iyY2Nsd7JxfKu1PRhCGwXzRw5TlfEsoRI7V9A8isUCoqE2Dzh3FvYHVeX4Us+bRL/oqareJ CIFqgYMyvHj7Q06kTKmauOe4Nf0l0qEkIuIzfoLJ3qr5UyXc2hLtWyT9Ir+lYlX9efqh7mOY qIws/H2t In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 2/19/26 16:54, Kiryl Shutsemau wrote: > On Thu, Feb 19, 2026 at 04:39:34PM +0100, David Hildenbrand (Arm) wrote: >> On 2/19/26 16:08, Kiryl Shutsemau wrote: >>> No, there's no new hardware (that I know of). I want to explore what page size >>> means. >>> >>> The kernel uses the same value - PAGE_SIZE - for two things: >>> >>> - the order-0 buddy allocation size; >>> >>> - the granularity of virtual address space mapping; >>> >>> I think we can benefit from separating these two meanings and allowing >>> order-0 allocations to be larger than the virtual address space covered by a >>> PTE entry. >>> >>> The main motivation is scalability. Managing memory on multi-terabyte >>> machines in 4k is suboptimal, to say the least. >>> >>> Potential benefits of the approach (assuming 64k pages): >>> >>> - The order-0 page size cuts struct page overhead by a factor of 16. From >>> ~1.6% of RAM to ~0.1%; >>> >>> - TLB wins on machines with TLB coalescing as long as mapping is naturally >>> aligned; >>> >>> - Order-5 allocation is 2M, resulting in less pressure on the zone lock; >>> >>> - 1G pages are within possibility for the buddy allocator - order-14 >>> allocation. It can open the road to 1G THPs. >>> >>> - As with THP, fewer pages - less pressure on the LRU lock; >>> >>> - ... >>> >>> The trade-off is memory waste (similar to what we have on architectures with >>> native 64k pages today) and complexity, mostly in the core-MM code. >>> >>> == Design considerations == >>> >>> I want to split PAGE_SIZE into two distinct values: >>> >>> - PTE_SIZE defines the virtual address space granularity; >>> >>> - PG_SIZE defines the size of the order-0 buddy allocation; >>> >>> PAGE_SIZE is only defined if PTE_SIZE == PG_SIZE. It will flag which code >>> requires conversion, and keep existing code working while conversion is in >>> progress. >>> >>> The same split happens for other page-related macros: mask, shift, >>> alignment helpers, etc. >>> >>> PFNs are in PTE_SIZE units. >>> >>> The buddy allocator and page cache (as well as all I/O) operate in PG_SIZE >>> units. >>> >>> Userspace mappings are maintained with PTE_SIZE granularity. No ABI changes >>> for userspace. But we might want to communicate PG_SIZE to userspace to >>> get the optimal results for userspace that cares. >>> >>> PTE_SIZE granularity requires a substantial rework of page fault and VMA >>> handling: >>> >>> - A struct page pointer and pgprot_t are not enough to create a PTE entry. >>> We also need the offset within the page we are creating the PTE for. >>> >>> - Since the VMA start can be aligned arbitrarily with respect to the >>> underlying page, vma->vm_pgoff has to be changed to vma->vm_pteoff, >>> which is in PTE_SIZE units. >>> >>> - The page fault handler needs to handle PTE_SIZE < PG_SIZE, including >>> misaligned cases; >>> >>> Page faults into file mappings are relatively simple to handle as we >>> always have the page cache to refer to. So you can map only the part of the >>> page that fits in the page table, similarly to fault-around. >>> >>> Anonymous and file-CoW faults should also be simple as long as the VMA is >>> aligned to PG_SIZE in both the virtual address space and with respect to >>> vm_pgoff. We might waste some memory on the ends of the VMA, but it is >>> tolerable. >>> >>> Misaligned anonymous and file-CoW faults are a pain. Specifically, mapping >>> pages across a page table boundary. In the worst case, a page is mapped across >>> a PGD entry boundary and PTEs for the page have to be put in two separate >>> subtrees of page tables. >>> >>> A naive implementation would map different pages on different sides of a >>> page table boundary and accept the waste of one page per page table crossing. >>> The hope is that misaligned mappings are rare, but this is suboptimal. >>> >>> mremap(2) is the ultimate stress test for the design. >>> >>> On x86, page tables are allocated from the buddy allocator and if PG_SIZE >>> is greater than 4 KB, we need a way to pack multiple page tables into a >>> single page. We could use the slab allocator for this, but it would >>> require relocating the page-table metadata out of struct page. >> >> When discussing per-process page sizes with Ryan and Dev, I mentioned that >> having a larger emulated page size could be interesting for other >> architectures as well. >> >> That is, we would emulate a 64K page size on Intel for user space as well, >> but let the OS work with 4K pages. >> >> We'd only allocate+map large folios into user space + pagecache, but still >> allow for page tables etc. to not waste memory. >> >> So "most" of your allocations in the system would actually be at least 64k, >> reducing zone lock contention etc. > > I am not convinced emulation would help zone lock contention. I expect > contention to be higher if page allocator would see a mix of 4k and 64k > requests. It sounds like constant split/merge under the lock. If most your allocations are larger, then there isn't that much splitting/merging. There will be some for the < 64k allocations of course, but when all user space+page cache is >= 64 then the split/merge + zone lock should be heavily reduced. > >> It doesn't solve all the problems you wanted to tackle on your list (e.g., >> "struct page" overhead, which will be sorted out by memdescs). > > I don't think we can serve 1G pages out of buddy allocator with 4k > order-0. And without it, I don't see how to get to a viable 1G THPs. Zi Yan was one working on this, and I think we had ideas on how to make that work in the long run. -- Cheers, David