From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5E1D83921FC for ; Wed, 25 Feb 2026 15:51:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772034687; cv=none; b=uZE0pOYOdqR7zBB/+QacVCULQJV0K1icRgSDc1fL2ixsedKHZDxPu+xPdBPB/cJWL6TSCqIcexE//L+OADpA0vDa4KOc3+G8m5yWM0iirHQeTMeQU3FVP/gLnCLUgmWQex0qu/2HGUjMp5l6SA8SwtnQYNkEduadUgu/h99qHBk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772034687; c=relaxed/simple; bh=W8WKCjg6uEXNgjPMgB/IT5hiOs9WEQQfQoHGkOe70OI=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=phqqRnG6yUdrUhqcnJsT9k4VrVfeHHYG6QO7MZS4IFXooSkhsxgGQ/mjHxoTGjPCFlwxjQChbLJXYrKOuCEoCyC70s2xqhGy7RryXQtdO5dM5I0xgXLXQguUBFEjHdww7wOFLBLgd0D1AOIlwWp/kg7VT57N60FvakI771Smh8M= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com 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 6415B165C; Wed, 25 Feb 2026 07:51:19 -0800 (PST) Received: from arm.com (arrakis.cambridge.arm.com [10.1.197.46]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id DE9613F62B; Wed, 25 Feb 2026 07:51:22 -0800 (PST) Date: Wed, 25 Feb 2026 15:51:20 +0000 From: Catalin Marinas To: Mark Brown Cc: Andrew Morton , David Hildenbrand , Deepak Gupta , Rick Edgecombe , Will Deacon , Paul Walmsley , Palmer Dabbelt , Albert Ou , Alexandre Ghiti , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , "H. Peter Anvin" , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, linux-mm@kvack.org Subject: Re: [PATCH 5/5] mm: Do not map the shadow stack as THP Message-ID: References: <20260224175800.2500729-1-catalin.marinas@arm.com> <20260224175800.2500729-6-catalin.marinas@arm.com> <5570c06d-fbc1-42c9-9b27-26211e8b033c@sirena.org.uk> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <5570c06d-fbc1-42c9-9b27-26211e8b033c@sirena.org.uk> 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: > > 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 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