Received: by 2002:ab2:6486:0:b0:1ef:eae8:a797 with SMTP id de6csp579641lqb; Sat, 16 Mar 2024 18:33:08 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUCBWk4i/in0aI9Ntj6hg5W3TiSMxxgmEjKoTS3Z9BW4Ai7WlD/lUwZwg1WVPT/8R3bbAqj2zo8ZcfZv+8fzd6RHSRNnSB3MTu/5j0eXQ== X-Google-Smtp-Source: AGHT+IG245eWAlrv5hhBXn9sMoTTvTwehZDNKkIgLVYIeHBkN227LVMMuvRZzlH7HwcEi5UmIjVV X-Received: by 2002:ac8:5bd5:0:b0:430:bca9:89 with SMTP id b21-20020ac85bd5000000b00430bca90089mr4048528qtb.10.1710639187956; Sat, 16 Mar 2024 18:33:07 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710639187; cv=pass; d=google.com; s=arc-20160816; b=c6OUzHkPiPs9DmTgQGBgDHTgtSu/urVLKuToXx9n3mzCJFnr+0rp2zN/6F6Bt+v5QO 3v7tdB2GjqkwedTYqYull1wOGy0rz4mdl4x9b+ZHGC3IPg8XOyJvp2kH4sqz+1J/GUds 6OJVPPBy3FcaNFOC3I14s/DDWH7OpdlwWKhGWozv1UxzvV1IjDOdZ9sBTsVcQaWbcmCx VRBa21u0M8c0WipAcBbOGIw6+u4VWvilS/gHDnPlWn37ss3cntmnHwT2sKBZB6MeeXA6 g4TjjnkaCcKo8jGkMLkSNxxYF2M6ToDcSGR1P4LFgysTk51gcyH6Apq/QHjVWB23NRH1 JIOA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:dkim-signature:date; bh=9RlAJsRV/7U7lgZ5geJYDyxKFcsxulrG2wQ1uwCXd3A=; fh=A6clS/Jffca9f+gqaX4oeuPOumckZbWRcY0++qpX28g=; b=sl9UFZJkySBWZCVQOB0HFOOZgFxsMNdHGkUNUbJ7xaCmdgrx5ikQ1dtez6ujbI5fxl 4mQHhK60xQSDhECo0rwOhlLO7g9yFMFX8sUyBQVql9Pt78Hz3XdirEyERMl+YKtdvqj4 wp6El07J/YEFBs5K+imjnVPyHfjTB7lAtpMsTgnz5Rx8b5kXARUkLfsl/XgQ53MJJOjJ KGuLe3RtjGG2CRsoocindw7hUfabC3v+QiJDKMLVX6zezqmDhijrOyQYHhxKCJSUpMBO iwIPlKHpLbC9WedRYm+P1YVlbKSrVmRCllg0lK7C6i87MdzRFeCcLVnTWk8Ibpll/An+ whKA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=fTnOSCXa; arc=pass (i=1 spf=pass spfdomain=linux.dev dkim=pass dkdomain=linux.dev dmarc=pass fromdomain=linux.dev); spf=pass (google.com: domain of linux-kernel+bounces-105316-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-105316-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id c4-20020ac85a84000000b0042eef7c29a6si6941661qtc.681.2024.03.16.18.33.07 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 16 Mar 2024 18:33:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-105316-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=fTnOSCXa; arc=pass (i=1 spf=pass spfdomain=linux.dev dkim=pass dkdomain=linux.dev dmarc=pass fromdomain=linux.dev); spf=pass (google.com: domain of linux-kernel+bounces-105316-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-105316-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id AA97A1C20B8D for ; Sun, 17 Mar 2024 01:33:07 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 528F7139F; Sun, 17 Mar 2024 01:33:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="fTnOSCXa" Received: from out-189.mta0.migadu.com (out-189.mta0.migadu.com [91.218.175.189]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 521791852 for ; Sun, 17 Mar 2024 01:32:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.189 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710639182; cv=none; b=Tnt2krFuVkMbHzu4mkQ1vPF53d7S/DiyXD57umR1QnQ3uQugsUe5OznbzGDhBd4PIRJyQOLVW/cjpCN4fvWKuSXTROiNdHGiPSzphkMFzhx+rtknUkzE/ZWVn4CJ90oZg60LCb87DAGLgPZgcNWuxafG1D9eue9AepYpCpaPv8o= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710639182; c=relaxed/simple; bh=ztvZQB2SUsNN94SIigkB3GyLNdK/4B2aC2dVRh4M3F4=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=X5vnEsa7PSy+WITPPPSPBHT/IZdJyMogtYoaWEIcl4zjjI30X+iyk0eMPG0W8/u61gIy/kRAR+IVmuUMjgEzK+Qk7oiSkR//sP9s4f/sUQ9xneYoWGQ53ATCw+k8Mefkoy1vlbqC+Rg4vf644NcSouMcm1YDGChi5ICl/ZluHz0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=fTnOSCXa; arc=none smtp.client-ip=91.218.175.189 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Date: Sat, 16 Mar 2024 21:32:48 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1710639176; 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=9RlAJsRV/7U7lgZ5geJYDyxKFcsxulrG2wQ1uwCXd3A=; b=fTnOSCXa0vNTItXRaHzGWsogIux8/TRMBoUZeZ77MCC5BxT+nJLCCwj+Kkzle0qZXb1TGN vUEd2QnaqB49FXQSikVQAibEBp6/pRjivXEs2ocIX8gXUM92lY0ncF0270mJ+Dq+vCZYn0 A1lRaThqY9ve3acajFkNUVC/hDbv0es= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Kent Overstreet To: Matthew Wilcox Cc: Pasha Tatashin , "H. Peter Anvin" , 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: References: <20240311164638.2015063-1-pasha.tatashin@soleen.com> <2cb8f02d-f21e-45d2-afe2-d1c6225240f3@zytor.com> <2qp4uegb4kqkryihqyo6v3fzoc2nysuhltc535kxnh6ozpo5ni@isilzw7nth42> <39F17EC4-7844-4111-BF7D-FFC97B05D9FA@zytor.com> 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: X-Migadu-Flow: FLOW_OUT On Sun, Mar 17, 2024 at 12:41:33AM +0000, Matthew Wilcox wrote: > On Sat, Mar 16, 2024 at 03:17:57PM -0400, Pasha Tatashin wrote: > > Expanding on Mathew's idea of an interface for dynamic kernel stack > > sizes, here's what I'm thinking: > > > > - Kernel Threads: Create all kernel threads with a fully populated > > THREAD_SIZE stack. (i.e. 16K) > > - User Threads: Create all user threads with THREAD_SIZE kernel stack > > but only the top page mapped. (i.e. 4K) > > - In enter_from_user_mode(): Expand the thread stack to 16K by mapping > > three additional pages from the per-CPU stack cache. This function is > > called early in kernel entry points. > > - exit_to_user_mode(): Unmap the extra three pages and return them to > > the per-CPU cache. This function is called late in the kernel exit > > path. > > > > Both of the above hooks are called with IRQ disabled on all kernel > > entries whether through interrupts and syscalls, and they are called > > early/late enough that 4K is enough to handle the rest of entry/exit. > > At what point do we replenish the per-CPU stash of pages? If we're > 12kB deep in the stack and call mutex_lock(), we can be scheduled out, > and then the new thread can make a syscall. Do we just assume that > get_free_page() can sleep at kernel entry (seems reasonable)? I don't > think this is an infeasible problem, I'd just like it to be described. schedule() or return to userspace, I believe was mentioned