Received: by 2002:ab2:2994:0:b0:1ef:ca3e:3cd5 with SMTP id n20csp319513lqb; Thu, 14 Mar 2024 12:06:01 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXsRmtT3eRFmuZyD6+13eaYm8XhJJE14+UBvdvC9ayE+altCKKYusMk7M86p6vpW5ghAW/HtjLujx5SW1Zm1S7AKJelKOxjBCSQlD5ndg== X-Google-Smtp-Source: AGHT+IH1o6jrg2X+IMWWaa11YVX+6l9iiL4ygQjf1gFNF7C91i3slLJ8zTilwnQtUKPRkq1FOzxh X-Received: by 2002:a05:6a20:4daf:b0:1a3:1048:3dfe with SMTP id gj47-20020a056a204daf00b001a310483dfemr886499pzb.38.1710443160728; Thu, 14 Mar 2024 12:06:00 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710443160; cv=pass; d=google.com; s=arc-20160816; b=OaCc0ln0EKmnFpoB8k/aPw9uNvL8eR8yolxNIES0PYtKZsiSDTctTr0GDW2cwjb4Nc UWqiQu8gzXnPUh81xbG75khtkml1R321XGhMkMLwJylzSGFUT6Hp3KZVAxnb5k2eba0o F5Z8HjcVDAXAmkWRugk4n9reQPCCseMzHPfG7EEnD6k5JbJoGVEaVZQM6JaTmRXsZ57U Ui18UotIrwKW7IfXkvgkQsYLacojrXXQ9vwoSOgzmpweFP0ya0hfZGm/+/95UPppJU3C 5DMW4LmeL+ArS0todaZLTCW/ZmGrveCITqmuxwiIJww4iib4629/dADUjJxhP5gEd8oW 96KQ== 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=troX3X8HuvTilW6NgLCfSK9nrQd3wvTH0v9DPQHyR8M=; fh=dKQrM0SUKAoQp3uc3t2vQ8eUBjpjc/GIJUa0tl96ego=; b=W3e0K9lXZpxQnlVV8jniIIRKWtCJfkjLb1wYyCXpocWYu8xQhn44TO5oX01GbrhSFQ 7lnXPlYNaiwsIjC5m/j0aHXyt6095jUuUc2SieUsWoDiAX8UY3pGK0G+5cDzKSa3Q06L mDZ7azHg8pA7h1GrM34Tghhh/JIQjVWz+C0Xl9EOLE+4IR96EQs2t71f995zKCT7j9GC 2hpPJ7+zYc4xUseNHG7JIUdKr2kVM7MxtKJCDh9JmEdMhlge47/dR1DzvuvIIKX+UyfH DWbdmcEUFWpcLyxkf5OqQqfGLROuFazrc7pNilgRu6Jc8P+C9N2xozL54u3Z9qzPhXoE W+rQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=lHtoAmqU; 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-103714-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-103714-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id p19-20020a056a000b5300b006e6bbc471d5si2087777pfo.257.2024.03.14.12.06.00 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Mar 2024 12:06:00 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-103714-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=lHtoAmqU; 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-103714-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-103714-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 4DAC1282E93 for ; Thu, 14 Mar 2024 19:06:00 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id AD6C8757F4; Thu, 14 Mar 2024 19:05:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="lHtoAmqU" Received: from out-187.mta0.migadu.com (out-187.mta0.migadu.com [91.218.175.187]) (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 9F7A274E23 for ; Thu, 14 Mar 2024 19:05:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.187 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710443157; cv=none; b=ZDz7UqCFjkNwXGjqEcWAFdnVT2wZDMTAVqGLq/M2Epn73jcSQkZzawA5svsNGwXO4ncF/HTMmy2Td11pMFYxRmeZf1SsAi0OQJgpbaN2sn53c++OevSI+U0v9RptEHdXwCdqLV2o6/EXPfiVxGU0XTzxHkMCHkFP89e+ix4e2tc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710443157; c=relaxed/simple; bh=IT9eLdbpe91FhfBPJR5qulj0qHeEACU6NqDEvgqyDW4=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=uZBhYLxYL+U9ZyjYMSBl6CzJI0kbY1cEibjyCAuc8gnh9Pha6fXdwYrv5RrJCYkM+J5QC8Je4ew1uwuvEb1cNOQNXCOSuF7aB2mSB52umWzN9NXLNFUBBO9UB8aoxvpfOxK5sxG370cpav+Pbn7IHAEOi1VSpRUjILbAo/hzOYw= 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=lHtoAmqU; arc=none smtp.client-ip=91.218.175.187 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: Thu, 14 Mar 2024 15:05:44 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1710443152; 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=troX3X8HuvTilW6NgLCfSK9nrQd3wvTH0v9DPQHyR8M=; b=lHtoAmqUIojCK2jPtn9uqGtrJW+6IvhqHqUKqyQDf7NHJmuqJjy/W+x2a7AAXH+7hkUNzH Br5u6MBOqEW3aFoO2R+YLGVNy6A+mUgZ+78EHK5t21DNKyfXdAXuYn02RoQqPJi6KcAeeJ jn15DnwPDOe9CHsRu4tkcVsZdEBBQdg= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Kent Overstreet 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, 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> 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 Tue, Mar 12, 2024 at 02:36:27PM -0700, H. Peter Anvin wrote: > On 3/12/24 12:45, Pasha Tatashin wrote: > > > > > > Ok, first of all, talking about "kernel memory" here is misleading. > > > > Hi Peter, > > > > I re-read my cover letter, and I do not see where "kernel memory" is > > mentioned. We are talking about kernel stacks overhead that is > > proportional to the user workload, as every active thread has an > > associated kernel stack. The idea is to save memory by not > > pre-allocating all pages of kernel-stacks, but instead use it as a > > safeguard when a stack actually becomes deep. Come-up with a solution > > that can handle rare deeper stacks only when needed. This could be > > done through faulting on the supported hardware (as proposed in this > > series), or via pre-map on every schedule event, and checking the > > access when thread goes off cpu (as proposed by Andy Lutomirski to > > avoid double faults on x86) . > > > > In other words, this feature is only about one very specific type of > > kernel memory that is not even directly mapped (the feature required > > vmapped stacks). > > > > > Unless your threads are spending nearly all their time sleeping, the > > > threads will occupy stack and TLS memory in user space as well. > > > > Can you please elaborate, what data is contained in the kernel stack > > when thread is in user space? My series requires thread_info not to be > > in the stack by depending on THREAD_INFO_IN_TASK. > > > > My point is that what matters is total memory use, not just memory used in > the kernel. Amdahl's law. If userspace is running a few processes with many threads and the userspace stacks are small, kernel stacks could end up dominating. I'd like to see some numbers though.