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 18686C54E60 for ; Thu, 14 Mar 2024 19:43:21 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 74C94800DE; Thu, 14 Mar 2024 15:43:21 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 6D47F800B4; Thu, 14 Mar 2024 15:43:21 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5759E800DE; Thu, 14 Mar 2024 15:43:21 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 4557D800B4 for ; Thu, 14 Mar 2024 15:43:21 -0400 (EDT) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 1405EA15FA for ; Thu, 14 Mar 2024 19:43:21 +0000 (UTC) X-FDA: 81896668602.06.832CB82 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf20.hostedemail.com (Postfix) with ESMTP id F0A5C1C0016 for ; Thu, 14 Mar 2024 19:43:18 +0000 (UTC) Authentication-Results: imf20.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=PXKa+GjK; dmarc=none; spf=none (imf20.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1710445399; 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=E9BvhamXKJX05OcN9tCjn3On3HSbyhQhWQ81yVSQ8uI=; b=iC31cCNgzqMkOqEdzGQT4YWSLJ3T4K51tm3jREJTx30n52twQuMa5jqc+QgYYp74NKPE0o nSyyQATs/noITxzg36mTWz1OCsHXUHS9oJZf+PI7ZbYtclRFdU0PshdKC+C4zyJ88eioDV et8O4Hm4fIDdOyG+mM0HF83pozcjn+g= ARC-Authentication-Results: i=1; imf20.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=PXKa+GjK; dmarc=none; spf=none (imf20.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1710445399; a=rsa-sha256; cv=none; b=HD9NF/HRogR74N6NlGaejf5epOYJ8rODqOKw4ZFW8MU7mKhirpoa/YoCbHMbIY8XejDBag b6MPMo18/gyNuCIA0oZ/IZQ40sn/XB3/4IcsTUHl3tghCHU8ktKxNNvz4qfi0T0aGc1w99 dPfE2o87+IFSUl9AJofkoq0z5pNbJzc= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=E9BvhamXKJX05OcN9tCjn3On3HSbyhQhWQ81yVSQ8uI=; b=PXKa+GjKY61OcrlhWj3bB/bEYi nrUgJYpqUezH4DLxvWLCSas5mJX87L04tmLT268yxqtveuFFlTmcEq39npftna3flVqo+gfoyMfEw 99fWRpJ36maVj78ZnNRl97NZb6VeF5uv/6cr278h7SvwF31ln23mPU6sk7FmirlftT76Z8ZEL5xQx PuLd/9hjj63f1OS+hpM6NgO84aKes86Ke0n2FCFTgrcfyxUBRZ1cvE0JkQg1cgkY/uLz0F9zFXTtK boLlHJr9/TQTbezQUamsFmf9gADQJJQVM4qr7mDC1ZH+RFaTdQhDCbkDRtRSx3DkBiE3ViYWDZ22y K48DNxHQ==; Received: from willy by casper.infradead.org with local (Exim 4.97.1 #2 (Red Hat Linux)) id 1rkqyo-00000008YLq-1JWa; Thu, 14 Mar 2024 19:43:06 +0000 Date: Thu, 14 Mar 2024 19:43:06 +0000 From: Matthew Wilcox To: "H. Peter Anvin" Cc: 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, kent.overstreet@linux.dev, 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: 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: <2cb8f02d-f21e-45d2-afe2-d1c6225240f3@zytor.com> X-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: F0A5C1C0016 X-Stat-Signature: 83mrd9uw4kgbwhwgsjxgnffzz3eut58q X-HE-Tag: 1710445398-917698 X-HE-Meta: U2FsdGVkX1+bncvVLX4eGzp1m2sBkjISTckTAGz5FlTtm/ozXz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ity: 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 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.