Thread (21 messages) 21 messages, 5 authors, 2026-02-25

Re: [PATCH 5/5] mm: Do not map the shadow stack as THP

From: Catalin Marinas <catalin.marinas@arm.com>
Date: 2026-02-25 15:51:26
Also in: linux-mm, linux-riscv, lkml

On Wed, Feb 25, 2026 at 01:02:36PM +0000, Mark Brown wrote:
On Tue, Feb 24, 2026 at 05:57:57PM +0000, Catalin Marinas wrote:
quoted
The default shadow stack size allocated on first prctl() for the main
thread or subsequently on clone() is either half of RLIMIT_STACK or half
of a thread's stack size (for arm64). Both of these are likely to be
suitable for a THP allocation and the kernel is more aggressive in
creating such mappings. However, it does not make much sense to use a
huge page. It didn't make sense for the normal stacks either, see commit
c4608d1bf7c6 ("mm: mmap: map MAP_STACK to VM_NOHUGEPAGE").
Reviewed-by: Mark Brown <broonie@kernel.org>
Thanks.
The create THP and immediately splitting it pattern is very clear when
checking the mm behaviour on new GCSs, this should help performance.
If the first access is a write, the kernel allocates a THP from the
start without subsequent splitting. Also since 6.13 (commit 1ced09e0331f
"mm: allocate THP on hugezeropage wp-fault"), we go for another THP on
write. It's still wasting memory and time to zero the full 2MB when
it's highly unlikely we'd ever use that much for a shadow stack.

-- 
Catalin
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help