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]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 25DC3CD4F26 for ; Tue, 23 Jun 2026 07:50:14 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id AC3D16B0088; Tue, 23 Jun 2026 03:50:13 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A74726B008A; Tue, 23 Jun 2026 03:50:13 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 930C66B008C; Tue, 23 Jun 2026 03:50:13 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 627FF6B0088 for ; Tue, 23 Jun 2026 03:50:13 -0400 (EDT) Received: from smtpin13.hostedemail.com (lb01a-stub [10.200.18.249]) by unirelay09.hostedemail.com (Postfix) with ESMTP id CB5ED8D5F2 for ; Tue, 23 Jun 2026 07:50:12 +0000 (UTC) X-FDA: 84910404264.13.0538CA2 Received: from tor.source.kernel.org (tor.source.kernel.org [172.105.4.254]) by imf24.hostedemail.com (Postfix) with ESMTP id 080FD18000D for ; Tue, 23 Jun 2026 07:50:10 +0000 (UTC) Authentication-Results: imf24.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20260515 header.b=OPR4U6tK; spf=pass (imf24.hostedemail.com: domain of david@kernel.org designates 172.105.4.254 as permitted sender) smtp.mailfrom=david@kernel.org; dmarc=pass (policy=quarantine) header.from=kernel.org ARC-Seal: i=1; a=rsa-sha256; d=hostedemail.com; s=arc-20220608; cv=none; t=1782201011; b=R79OKMHiJF9d4t1HVezPKqmYR447xPm0hb9i0duT0f8+PfL3BFlSqPBX4ipP5j55zYqo3b c9Pf50axKxB3ASzi780arNEQpKg2QR2AvFXaZEgFcBUUla1cjL+PD259mHfp1BJWdHuZKL lAvc8395gPJVbm3koAgSq1x4+vMT3FU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1782201011; 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:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=aRZgnHp3vWPKvY+OhddSqzZ6Xb2MgcroWOqVWlw/iSM=; b=20mVe6PIHc44hXutZivEJYBmOEEH/Mdtk96K4xJW0ld7lsP67q9lAhNr0t0rvsUJjv2SMv IKSC/big7i/i0IiKLtQjk4uCQJ08rNSeihKhy16ooetC/eIBegpL2hm214D1xBwy0JYJO7 2a8NhGqueTNOwNGxUU6oKUF3fk6H7JM= ARC-Authentication-Results: i=1; imf24.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20260515 header.b=OPR4U6tK; spf=pass (imf24.hostedemail.com: domain of david@kernel.org designates 172.105.4.254 as permitted sender) smtp.mailfrom=david@kernel.org; dmarc=pass (policy=quarantine) header.from=kernel.org Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by tor.source.kernel.org (Postfix) with ESMTP id 7B57F6001D; Tue, 23 Jun 2026 07:50:10 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 06E281F000E9; Tue, 23 Jun 2026 07:50:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1782201010; bh=aRZgnHp3vWPKvY+OhddSqzZ6Xb2MgcroWOqVWlw/iSM=; h=Date:Subject:To:Cc:References:From:In-Reply-To; b=OPR4U6tKdwXmWBc8A9pDEZwar5IrIaNRo0eFZlmF5sh7Yll8uDpailB1OGPW/e2ba pJkVpUXosNijxf4wqTWliWYpab5dBPb+sWyE9e8MwGPs6Ejcqq/ynzmnfjqklSENPJ /yPi8PXmbMbAM1B5ie8+tWfHSHNlk28Ta5iVTFnlpqbqnAvHCzWHWNewqOyS1o1atO ReLaqZbdEjQM7N7oi5gR4Ev793oSPNyd7aoPU0GzzoQx4L+7PwCz7ay1MCMUStC/Pk eoJ5VrPy5YAb5J4PzWUeczMtIZYUYXS58IkpF+oYjDD5trjTHpX1DfjYeJUIGtu+/5 azh4kB0ilrlXQ== Message-ID: Date: Tue, 23 Jun 2026 09:50:00 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2 00/13] Dynamic Kernel Stacks To: Zach O'Keefe , Thomas Gleixner Cc: Dave Hansen , "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 , 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, Matthew Wilcox References: <20260424191456.2679717-1-stevensd@google.com> <6369e5ce-74e3-4c68-8053-d7d7d21b6955@zytor.com> <87pl1md7h0.ffs@fw13> <87qzm2b39k.ffs@fw13> <87mrwon5uw.ffs@fw13> From: "David Hildenbrand (Arm)" Content-Language: en-US Autocrypt: addr=david@kernel.org; keydata= xsFNBFXLn5EBEAC+zYvAFJxCBY9Tr1xZgcESmxVNI/0ffzE/ZQOiHJl6mGkmA1R7/uUpiCjJ dBrn+lhhOYjjNefFQou6478faXE6o2AhmebqT4KiQoUQFV4R7y1KMEKoSyy8hQaK1umALTdL QZLQMzNE74ap+GDK0wnacPQFpcG1AE9RMq3aeErY5tujekBS32jfC/7AnH7I0v1v1TbbK3Gp XNeiN4QroO+5qaSr0ID2sz5jtB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KQu+P/vts IfUb1UNMfMV76BicGa5NCZnJNQASDP/+bFg6O3gx5NbhHHPeaWz/VxlOmYHokHodOvtL0WCC 8A5PEP8tOk6029Z+J+xUcMrJClNVFpzVvOpb1lCbhjwAV465Hy+NUSbbUiRxdzNQtLtgZzOV Zw7jxUCs4UUZLQTCuBpFgb15bBxYZ/BL9MbzxPxvfUQIPbnzQMcqtpUs21CMK2PdfCh5c4gS sDci6D5/ZIBw94UQWmGpM/O1ilGXde2ZzzGYl64glmccD8e87OnEgKnH3FbnJnT4iJchtSvx yJNi1+t0+qDti4m88+/9IuPqCKb6Stl+s2dnLtJNrjXBGJtsQG/sRpqsJz5x1/2nPJSRMsx9 5YfqbdrJSOFXDzZ8/r82HgQEtUvlSXNaXCa95ez0UkOG7+bDm2b3s0XahBQeLVCH0mw3RAQg r7xDAYKIrAwfHHmMTnBQDPJwVqxJjVNr7yBic4yfzVWGCGNE4DnOW0vcIeoyhy9vnIa3w1uZ 3iyY2Nsd7JxfKu1PRhCGwXzRw5TlfEsoRI7V9A8isUCoqE2Dzh3FvYHVeX4Us+bRL/oqareJ CIFqgYMyvHj7Q06kTKmauOe4Nf0l0qEkIuIzfoLJ3qr5UyXc2hLtWyT9Ir+lYlX9efqh7mOY qIws/H2t In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Stat-Signature: cypamibhhqkxj5iugbhgrmmqd6wewkyi X-Rspamd-Queue-Id: 080FD18000D X-Rspam-User: X-Rspamd-Server: rspam01 X-HE-Tag: 1782201010-367288 X-HE-Meta: U2FsdGVkX1/ygcqIl/my324vqyaYn/z1e9s2Z6hPRaT+hEr9cX+h7+aCVt8c7W5aTRjsFFD0rTKMVW51VCF8vR2uGQ2Vgan206G7EugzAKxvOhdBdj2zri0axG9xgPWC654RctnO66QenPgFMmLz9+g9R6noodUcVk4d37ZP+ljaRP7bug69I4tpprKThhGBeZ5fFMd71LP3b6cLEP3BLeJ9KiVLr18nXoZtjageloEIt3vj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.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: On 6/23/26 01:00, Zach O'Keefe wrote: > On Sat, Jun 20, 2026 at 4:34 PM Thomas Gleixner wrote: > > Thomas, thanks for taking the time, as always, for such a thoughtful response. > >> On Sat, Jun 20 2026 at 12:33, Zach O'Keefe wrote: >>> >>> Ya, that's my concern as well, as I don't have a good intuition for >>> how perf critical kernel #PF is for real workloads. If this is your >>> primary concern, I'll take that as a _good_ thing ; i.e. there's >>> nothing architecturally stopping us from doing this downgrade safely. >>> We'll still need the analysis, but that can be a later stage -- we're >>> more than happy to get this data for all. >> >> No. That's not a later stage optional requirement. >> >> You have a PoC which works for you otherwise you wouldn't have posted >> it. So you can trivially microbenchmark the costs of the >> up/downgrade. And that's critical information for us but also for >> you. If the costs are significant then you really have to think about >> the tradeoffs. >> >> Care to read Documentation/process/* carefully? It applies to you as it >> applies to anyone else. >> >>> >>> This is actually the most understood aspect. With O(100B) active tasks >>> fleetwide at any point, it only takes an average savings of O(10KiB) >>> per task to get to 1PiB. At least for our fleet, we know the % of >>> tasks that use only 4KiB, 8KiB, or require the full 16KiB, and the >>> math confirms that we expect O(PiB) aggregate savings. The % of stacks >>> requiring the full 16KiB is minuscule, but it still occurs at a rate >>> higher than what we can tolerate for SO panics. Given the vast >>> majority of stacks never exceed the first 4KiB, this enables the >>> significant opportunity. >> >> I know that the potential savings are well understood and my >> understanding of math is sufficient to calculate how much tasks and >> average saving it takes to save 1PiB on a fleet. >> >> That's a no-brainer, but this is an aggregate saving, which sounds WOW >> but does not tell much about anything else. >> >> 1) What's the actual percentage of savings in relation to the overall >> memory? >> >> 2) Does the saving allow you to get more stuff done on a machine, pack >> more threads on it? >> >> 3) Can you actually downsize the memory on the machines? >> >> 4) What is the performance tradeoff for that? >> >> IOW, you fail to tell what the actual benefit of such an intrusive >> change is. Just boasting an aggregate Petabyte number does not tell >> anything at all. >> >> Let me give you a trivial example with a scenario which I have access >> to: >> >> 256 CPUs >> 256 GiB Memory >> 64k Threads >> >> Let's assume the full saving of 12k per thread. That sums up to >> >> 64k * 12k = 768MB of memory >> >> which is 0.29% of the total 256 GiB of memory. Not so impressive as the >> petabyte aggregate number, right? >> >> The workload consumes about 80% of the overall memory and is already >> constraint on close to 100% CPU utilization. >> >> Now let's assume that the runtime overhead of this amounts to 1% then >> this is a net loss. >> >> Let me turn that around and use a made up example assuming the 1Mio >> threads per compute unit taken from some reply in this thread. >> >> Now the full saving of 12k per thread amounts to: >> >> 1M * 12k = 12G >> >> which is 4.7% of the overall available memory. Agreed that's a >> substantial number. >> >> That 12G saving does not do anything in terms of hardware downsizing. >> >> The only way that has a benefit is when the system is constraint by >> overall memory consumption, but has quite some compute capacity left. >> >> IOW, if 1M threads hit the memory limit that means that the savings in >> kernel stack consumed memory allows you to add about 4% (~40k) more >> threads. If that ups the CPU utilization accordingly then yes, I can see >> the benefit. But TBH, if that's the case then you are trying to fix a >> user space implementation problem in the kernel. >> >> That said you really have to describe the scenarios where there is a >> benefit and I do not buy this "fleet level" argument at all because >> there is no single fleet which has a uniform workload distribution. > > These are good thoughts, thank you. Perhaps I've been too biased by > our particular environment—apologies for that. > > We (mostly) punt this problem to cluster-level scheduling, which > ironically exploits this non-uniformity of workload dynamics to > appropriately bin-pack machines and materialize these small savings. > > In the general case, I guess a lot hinges on that overhead cost -- in > the best (memory-constrained) case. > >> Aside of that. If your argument holds that there are only a few >> scenarios which require a deep stack, then we are better off to identify >> them and fix them up rather than trying to hack around the occacional >> insanity of deep stack usage by adding complexity for complexity sake. >> >> As you say that you have numbers of your fleet which confirm that the >> vast majority of the stack depth is below 4k, you can surely figure out >> the information which call chains are actually exceeding the limit. >> >> I prefer to fix such shitty code and downgrade the stacksize in general >> instead of papering over the underlying issues which probably have been >> ignored for years if not decades. >> >> Have you ever thought about that instead of adding complexity with a >> dubious value? There was some (hallway?) talk at LSF/MM about possibly removing direct reclaim, similar to how other operating systems handle it. Now, I don't know how feasible it is (I guess devil is in the detail ;) ), or any details how that would work, but direct reclaim was repeatedly called out as one of the main reasons we can get huge stacks. So I guess direct reclaim (incl. compaction) is one of the main problematic pieces. Are we aware of other scenarios where we (easily) trigger consumption of larger stacks? Wild idea: as a first step to test the waters, use smaller stacks on selected kernel threads and disallow direct reclaim/compaction if the stack for the thread is small? -- Cheers, David