From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f51.google.com (mail-wm1-f51.google.com [209.85.128.51]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B92341DED4C for ; Mon, 29 Jun 2026 20:28:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.51 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782764908; cv=none; b=cLqj/ADqyh82tX1/LNPwPpmOibL2+V5MjR0ZZQmopmLXBQHH5CQ7napBm+5X6csPwrFc1teFPFcDIMyDnJ80uXg6M+sOsD/Gj4czXD2O0Y8eO7y+2GNznGnPBCwxFPPr4HI/1Lisz38N4+0g9fBsMzBwrFrowvdn+XthpaC7i5M= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782764908; c=relaxed/simple; bh=CRGicjCV5ZZ28UrvzW4tlB+48bSLhHdIbKvxYmrYCCU=; h=Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=KGBqy24bufpnhHWW5HK7Op7JOFVK/Oyi48LmeS1FXlyGZER/op3qKQiZpCLB1B526mm4HgMT20crq1SkPncOh9Wjh5CMKewNGbbL2pacT8lCymNZBp8jhuZnhVSgvGFaQRKHUU+DI1jC/aOMCDvDp8OULlrz1G9jENr2PvZtFwg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=ir+3sZnL; arc=none smtp.client-ip=209.85.128.51 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="ir+3sZnL" Received: by mail-wm1-f51.google.com with SMTP id 5b1f17b1804b1-4926bd21aa1so26502395e9.3 for ; Mon, 29 Jun 2026 13:28:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1782764905; x=1783369705; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:from:to:cc:subject:date :message-id:reply-to; bh=RwBM1U8dWRy21no+IYOBvhWWP+kmvdE1hw/PUPXb+Vo=; b=ir+3sZnLSkbf1x2vRw+4+PeOQlWx1cjXCzlvb3tBLkj9pBtRezx4hrj4VkCHKjNjJp 6l6E2jUi2kxNq5ZdJBszd3butQhRBvx4S4MsdaTaZ1ZBrcoHU4WeK3QSYbihRpTEktzd YO1WBQ+v/ExgTt5aNyyGKekPKuuAU7VQiT1oBksRjN2n5DmLtpJ4b7kNIg8xMMf+vnAx l/2Ox7ZuxpQ8nto9fun3aNEuNdzN58I4uWnDEpQslNCK6BxnILjvQrDCnts1nzusviQq SJIdDzxUkQUBUsaG69egX0LO0n2RBEwiJK2ofYxemjISll+Vr0EtUfrSo4i0Y+jGINOn 0yEw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1782764905; x=1783369705; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=RwBM1U8dWRy21no+IYOBvhWWP+kmvdE1hw/PUPXb+Vo=; b=FWjzO9BuzBvLBcFaqYyf09UjNBccWoCzam5NbAmf0Y6/ZDil09OpfOHi536pP7j7u1 otWZZvZo1/z+bgxuQTSNEFTyoo2sgkiAGjnhpPdlCxFhfOhZfiv6BRQU5fC4AufuXxEc ALkg6xVQomTCqzs43yVYCFwk/0A3tYWelmEVI99ksGOHqqcVKrEUhJgmjIAzmMnObwKY RDF9et+C7blHyBqTa8R5GSiM7UGhSoDeNQpSRR6l40yvvyfbCwjiQfWDKI6uRsRiB9XH nVp1rkZUGoVoaG47Qx75OHGZsBrZFxob631GksAgX5KGQdKwch+CgS3/uXYDCxO09JkD bvSw== X-Forwarded-Encrypted: i=1; AFNElJ+h1FysAASE7nSVlt4IGBG8zIMT9G/4O9wKPrb78LfWyzg8oBFEzq8GRe0kyVeA4XUqHFRMAvbTqniMbWU=@vger.kernel.org X-Gm-Message-State: AOJu0YwLAvb5VXTV7fbVMrB3MqioVbmP7mIqr8hc4Kl1GcOAKMUxT/0X xRHKw0dU7eI4XLWNVYJ2WjoIDJZcLkpDFcvpkxCJqbwmdVcrrOVGSx8U X-Gm-Gg: AfdE7cnf3EbX9YeLfmKtrV4ECx0CAlTBsWVGN/QOCsgdJ9E5f1li+hlJKWHdsMi8XDd H8ryQ6a0fb6Dz2JBbTIIIME+yeUOQxLGmD3Na9CNebW7V1CKW7UJpkaO+EUojFzZeTPa8mE06kd +RNdBDrxwC17Sr5T3o9F7Xvirnb3WucZceif7Q8o9NIuqHLZlE0BOyXk2/5OruigPqXNVoGtWqv c2NaC44/z61mm8rAKJ4zQf8KrQ8r/k+LdTwkLRILnWeDXnYWly0QBcUHgi5TqnY0bH0bLX+MP6Q mNd/tjouLM5XNaeADpI8cdm+Vfo0PjKBW6RaFic1FUVG+YMw/UieKyqore9FyC8+tr3/Yh0+cfB uz9GNzy8XDK/f6HrUZQpoCN/Pg5CUB9zUpkrAGmngMtBPesSHlBLsIli1jd32Q7uskx9PEyxWcU uycKvyDhW6R2tknN0roWdIY6afXem0bY3oCZOebEHFvn4ig+bduNO7hLHT X-Received: by 2002:a05:600c:4f82:b0:48a:906b:14ca with SMTP id 5b1f17b1804b1-493b82af9c7mr16475685e9.20.1782764905029; Mon, 29 Jun 2026 13:28:25 -0700 (PDT) Received: from pumpkin (host-92-21-50-228.as13285.net. [92.21.50.228]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4756636cde2sm798992f8f.20.2026.06.29.13.28.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Jun 2026 13:28:24 -0700 (PDT) Date: Mon, 29 Jun 2026 21:28:22 +0100 From: David Laight To: Dave Hansen Cc: Thomas Gleixner , Zach O'Keefe , "H. Peter Anvin" , David Stevens , Pasha Tatashin , Linus Walleij , Will Deacon , Quentin Perret , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, Andy Lutomirski , Xin Li , Peter Zijlstra , Andrew Morton , David Hildenbrand , Lorenzo Stoakes , "Liam R. Howlett" , Vlastimil Babka , Mike Rapoport , Suren Baghdasaryan , Michal Hocko , Uladzislau Rezki , Kees Cook , linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: Re: [PATCH v2 00/13] Dynamic Kernel Stacks Message-ID: <20260629212822.14dbb27f@pumpkin> In-Reply-To: <5604a47b-9457-4162-bd23-720e29cf1983@intel.com> References: <20260424191456.2679717-1-stevensd@google.com> <6369e5ce-74e3-4c68-8053-d7d7d21b6955@zytor.com> <87pl1md7h0.ffs@fw13> <87qzm2b39k.ffs@fw13> <87mrwon5uw.ffs@fw13> <87cxxgly12.ffs@fw13> <5604a47b-9457-4162-bd23-720e29cf1983@intel.com> X-Mailer: Claws Mail 4.1.1 (GTK 3.24.38; arm-unknown-linux-gnueabihf) 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=UTF-8 Content-Transfer-Encoding: quoted-printable On Mon, 29 Jun 2026 09:02:08 -0700 Dave Hansen wrote: > On 6/23/26 14:58, Thomas Gleixner wrote: > > So as you already confirmed that the number of offenders is really low, > > it'd be definitely a worthwhile effort to fix that for everyone and also > > make the compiler people to get their act together =F0=9F=99=82 =20 >=20 > One other thing comes to mind... >=20 > We have debugging options for looking at max stack depth, like > CONFIG_DEBUG_STACK_USAGE. But no distros seem to turn that on. There's > also some ftrace stuff, but I assume none of that is used at runtime eith= er. >=20 > Do we need some max stack depth instrumentation that folks will actually > turn on? It would be nice if we spat out warnings when folks went > through 12k (or 8k) of stack so there was a chance of closing the loop > and getting feedback from them. >=20 > It could be done with really little overhead if the vmalloc()'d stacks > set Accessed=3D0 on their PTEs and then checked them near vfree(). The > PTEs are already getting touched there, so the cachelines should be hot > anyway. For testing purposes you'd probably want to do the check in other places. Possibly slow paths that might be called with a deep stack as well as context switch and return to uses. I guess you could copy the stack (to global data) so that it could be dumped for diagnostics (finding the relevant stack trace is left as an exercise to the reader). Similarly it might be worth allocating an extra 4k page so that stack could be offset so the warning happens at (say) 12k. David >=20 > The granularity would only be 4k, but it would be so cheap that we could > turn it on universally. It would also be 100% deterministic. >=20 > There are, of course, more games that could be played with stack depth > checks on normal interrupts or NMIs. But those would be less deterministi= c. >=20 > Thoughts? >=20