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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 38ECAC54E60 for ; Thu, 14 Mar 2024 19:53:51 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id BE5A5800E0; Thu, 14 Mar 2024 15:53:50 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B9546800B4; Thu, 14 Mar 2024 15:53:50 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A369D800E0; Thu, 14 Mar 2024 15:53:50 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 8E8FB800B4 for ; Thu, 14 Mar 2024 15:53:50 -0400 (EDT) Received: from smtpin13.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 56D8440364 for ; Thu, 14 Mar 2024 19:53:50 +0000 (UTC) X-FDA: 81896695020.13.6A2DCAC Received: from out-185.mta0.migadu.com (out-185.mta0.migadu.com [91.218.175.185]) by imf01.hostedemail.com (Postfix) with ESMTP id 9EB9A40012 for ; Thu, 14 Mar 2024 19:53:48 +0000 (UTC) Authentication-Results: imf01.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=nQS6Y8Uw; dmarc=pass (policy=none) header.from=linux.dev; spf=pass (imf01.hostedemail.com: domain of kent.overstreet@linux.dev designates 91.218.175.185 as permitted sender) smtp.mailfrom=kent.overstreet@linux.dev ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1710446028; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=4kApU2kLAOZt4fs1XzI38Cc/RPp9WtA/5TCETh/ESiU=; b=iWM43CD/JwuIJpBmqGgknTRY0fRyro1PisIXpZf3A7JIW2UO475wqTICf6P0VwX6a+E9j1 Ck0085vFtZ2APGSXulsPVkLeoIMNJ/kyCIgn8D1kFaZWPPoavQeOsT7scOMslycK9zDe39 UPCWIQ/0KiMcalsbY6EN7F9HOTStd4o= ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=nQS6Y8Uw; dmarc=pass (policy=none) header.from=linux.dev; spf=pass (imf01.hostedemail.com: domain of kent.overstreet@linux.dev designates 91.218.175.185 as permitted sender) smtp.mailfrom=kent.overstreet@linux.dev ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1710446028; a=rsa-sha256; cv=none; b=t3GLpeghtvokjArrfT9foBz/kT8U3QBh9hYANRY53jKmTux4WtrPn3JQ0B8rfyQExEvlns dp3sv8eeNZ9fb87DOV1X6AUwsAZhguWvYQkRNEymRylt04c/rHTbgkSL1EWLmRIfafLLq0 hhSutAO42mq5+QzscVuckLrqlYQDpFw= Date: Thu, 14 Mar 2024 15:53:39 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1710446026; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=4kApU2kLAOZt4fs1XzI38Cc/RPp9WtA/5TCETh/ESiU=; b=nQS6Y8UwhmnyERjhKozWTXENnHnLiuHjK4gk2g20jfiTt32jcBKQXcrSmhHPd+QFrVsCMB Q68W1CTWG17m8+B49rpyPjels7FLaBnxgLQZbx7L0VOoXn9DZ3lK2jqHlWARbdgpMpU/gQ pt+ISGginzImGTNpqv9Hm+JWfsvu4Do= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Kent Overstreet To: Matthew Wilcox Cc: "H. Peter Anvin" , Pasha Tatashin , linux-kernel@vger.kernel.org, linux-mm@kvack.org, akpm@linux-foundation.org, x86@kernel.org, bp@alien8.de, brauner@kernel.org, bristot@redhat.com, bsegall@google.com, dave.hansen@linux.intel.com, dianders@chromium.org, dietmar.eggemann@arm.com, eric.devolder@oracle.com, hca@linux.ibm.com, hch@infradead.org, jacob.jun.pan@linux.intel.com, jgg@ziepe.ca, jpoimboe@kernel.org, jroedel@suse.de, juri.lelli@redhat.com, kinseyho@google.com, kirill.shutemov@linux.intel.com, lstoakes@gmail.com, luto@kernel.org, mgorman@suse.de, mic@digikod.net, michael.christie@oracle.com, mingo@redhat.com, mjguzik@gmail.com, mst@redhat.com, npiggin@gmail.com, peterz@infradead.org, pmladek@suse.com, rick.p.edgecombe@intel.com, rostedt@goodmis.org, surenb@google.com, tglx@linutronix.de, urezki@gmail.com, vincent.guittot@linaro.org, vschneid@redhat.com Subject: Re: [RFC 00/14] Dynamic Kernel Stacks Message-ID: <2qp4uegb4kqkryihqyo6v3fzoc2nysuhltc535kxnh6ozpo5ni@isilzw7nth42> References: <20240311164638.2015063-1-pasha.tatashin@soleen.com> <2cb8f02d-f21e-45d2-afe2-d1c6225240f3@zytor.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Migadu-Flow: FLOW_OUT X-Rspamd-Queue-Id: 9EB9A40012 X-Rspam-User: X-Rspamd-Server: rspam04 X-Stat-Signature: 61y4jfss3ps3y145awyabnipk4p59foe X-HE-Tag: 1710446028-907753 X-HE-Meta: U2FsdGVkX191C6p0mNuaieFFWV4PIif7LewvqHWiTd7mitYwcxS8vqXVVMxiKQD5hQSPTEotXVdqHxpBvzSEKQ5dGYBfD5lv827yFFaf0Iln8pd2oqONjF6/c3n18xHTEVcaWrtKUTKrzzIJwYzDFDI2XuT+aSUE7/k59asUXWMEjWWYLo39MFLiimCS2+rkICHss+j3DwbK3BM/UN73FH+Zfiq149B1wj4Rv8UWQ2RY8KMIoLV0+GkguJs982Ycfjq9mHF0Wa1suZoNP/O07nOb1N8QoNSuZcCoFmoRpVhnVFcB87IXP8vuK7sS9llttQ+z1BoxpHH7TigbnS6x4T15WlC41BK0H4KL0R5coH9LF6cDAPUD4V+IP7vfXNNXlhUemU27L9nInUFFL1h1O0tskxAOTslIoab1bwYPfKS4n5lkv4iVi3IhlM1a6GnpsxQUt4IPZHwnkxk2K24FOXNSTb2z8Bcp7a2pS8dOiAzTzI3VGr0Y3DDFoVl90A3yZ1L1k53YIDRcaFzz4n64lEeYsrNUqZ5jPfKB8lnfIz6RTnlIJD3nwDAMzvRYzwyU3U9u+3t5/ePN86MDCIJVvUVLRnpyE6GnQv7pHPe9dcm4NJZxV7pNa82rXwDI+JKNsUnoNj/G8wFAZlK1FRrpEAK9naFeiH5OMkxIn3zooMldEdAmh1nr+3UpAXU/5A+8dpuA69SNM+oOFD7yGA5w8dn96UnTnjynzDzUrZ1RUZILcoScZA9UyqLGR9kWiUBwFt0jw3DQVGVUvBXkI5rwIXYbt5MEWfeWmi8EC0R2pi55a+MOqrmpuOT66XRBP49tUIOiJvGNQtG1x/l1VanucvCU1rin2MawEkBp1xsOkKneO1xuMoET0/kWNL0ZVxX7B7r0jbw9AEbR37v3u+mxlQc/NlQS70QV4pwdkdCYevptE3yU7QKHzc7iNFK+4sejJ0rMd5qdkSG1dL6tP/2 fLGsaHzJ AfdyTF49xMWh0a2IWXbDtm+6ec3kTiTUhGiv99U+C04+ZkPuSUhi4FcdzUuN57wAs1i/qG1l38fgnv3BOWxKFwjFOQQ== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: On Thu, Mar 14, 2024 at 07:43:06PM +0000, Matthew Wilcox wrote: > On Tue, Mar 12, 2024 at 10:18:10AM -0700, H. Peter Anvin wrote: > > Second, non-dynamic kernel memory is one of the core design decisions in > > Linux from early on. This means there are lot of deeply embedded assumptions > > which would have to be untangled. > > I think there are other ways of getting the benefit that Pasha is seeking > without moving to dynamically allocated kernel memory. One icky thing > that XFS does is punt work over to a kernel thread in order to use more > stack! That breaks a number of things including lockdep (because the > kernel thread doesn't own the lock, the thread waiting for the kernel > thread owns the lock). > > If we had segmented stacks, XFS could say "I need at least 6kB of stack", > and if less than that was available, we could allocate a temporary > stack and switch to it. I suspect Google would also be able to use this > API for their rare cases when they need more than 8kB of kernel stack. > Who knows, we might all be able to use such a thing. > > I'd been thinking about this from the point of view of allocating more > stack elsewhere in kernel space, but combining what Pasha has done here > with this idea might lead to a hybrid approach that works better; allocate > 32kB of vmap space per kernel thread, put 12kB of memory at the top of it, > rely on people using this "I need more stack" API correctly, and free the > excess pages on return to userspace. No complicated "switch stacks" API > needed, just an "ensure we have at least N bytes of stack remaining" API. Why would we need an "I need more stack" API? Pasha's approach seems like everything we need for what you're talking about.