Received: by 2002:ab2:620c:0:b0:1ef:ffd0:ce49 with SMTP id o12csp367614lqt; Mon, 18 Mar 2024 10:01:47 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWPbabjXlU/+7zTmHnToUxNvwgdBDaOg02EANzGi8O4vvuv58f20WY+2Xub0CceS01KN2nfqbZB7/GTe8cZk5tQCYpFPFKKqeaq8wquZQ== X-Google-Smtp-Source: AGHT+IF98Szep+hjjVXndK/DiodR7OxoKfs4HyHWauS5scdUBtAT9mcuPKnjxNZZ+LAQwgKW8erJ X-Received: by 2002:a05:6402:3908:b0:568:b4b6:1e5e with SMTP id fe8-20020a056402390800b00568b4b61e5emr5683433edb.0.1710781303302; Mon, 18 Mar 2024 10:01:43 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710781303; cv=pass; d=google.com; s=arc-20160816; b=K5WQILlmURLs1zSPm2UE+ejnhm5WzfUZw1tNYp6qWY2culmg7oG09X9U8oTSkSSAdE oSt4a00DE0oTJE2Ix0goMVEB8edw3D+tipGssvsDTMwV8VJ7vwjX6wqf6zTNBmqPCwOi 5MwEajkGDwsr+xTA65WyXrL3JsipgpAoj2Or0GKS4K/T7Z9/cVeFHqdt3XSVRjNauxbX DldRjRlNwPqdXhA60161tLjLV2QtJQ8PS/esIEAP0zI0p6rYbCNKHN7E+19yEWMu4O9f UwxiKP1lw3/693NSzkcaDXJWA4YDJoWPJb18trDVg9eqDTIrWz6lLPi0+0xLjnxsoyL7 sWEg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=n33MLXZoglDyHrWKjv9agU9CQY4n6w7XF7nYX+56vfA=; fh=57AbsnStFQ45Wp8415WESYxyT193pJfDJ5ffm8yDetk=; b=r2WUR+oWLnlWLmNLfRnMmQa1cCXp5k9lGpkZDSB1jxYoRAkloqVgf6QD0cid4ox+/M q9WMJzr9ogjgg/HHVbJ59VoYV6vB/nEDwqZE9O3w3gjWzx9cN9WsilYFOsO3bi6Xv/M8 ZvRz8jaMfkQATjIFuFWXGeF8fbYi2lUw/AY1njKrje11j8pt0fDHN9GB2aW0cCDAoQw7 w4GEVpebJNA5tGB1c6cR0nFVdzLA2jWHQw18nr1CbHV2cG2Ro48Ui3SPm498iMoj2dNV 21JYRif+Jq0LfGmNIXGxFq1crz9EKregSmT1xOmoCaMqbc2X8KWdvyDoxZ9TvYQkY3aV fd7g==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@soleen-com.20230601.gappssmtp.com header.s=20230601 header.b="d2pC0zQ/"; arc=pass (i=1 spf=pass spfdomain=soleen.com dkim=pass dkdomain=soleen-com.20230601.gappssmtp.com dmarc=pass fromdomain=soleen.com); spf=pass (google.com: domain of linux-kernel+bounces-106413-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-106413-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=soleen.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id p1-20020a056402500100b0056856a08fd6si4596139eda.281.2024.03.18.10.01.42 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Mar 2024 10:01:43 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-106413-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@soleen-com.20230601.gappssmtp.com header.s=20230601 header.b="d2pC0zQ/"; arc=pass (i=1 spf=pass spfdomain=soleen.com dkim=pass dkdomain=soleen-com.20230601.gappssmtp.com dmarc=pass fromdomain=soleen.com); spf=pass (google.com: domain of linux-kernel+bounces-106413-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-106413-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=soleen.com 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 am.mirrors.kernel.org (Postfix) with ESMTPS id 3DFB91F24F88 for ; Mon, 18 Mar 2024 17:01:42 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9CE8654F84; Mon, 18 Mar 2024 17:01:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=soleen-com.20230601.gappssmtp.com header.i=@soleen-com.20230601.gappssmtp.com header.b="d2pC0zQ/" Received: from mail-qt1-f182.google.com (mail-qt1-f182.google.com [209.85.160.182]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 362BE54BC8 for ; Mon, 18 Mar 2024 17:01:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.182 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710781293; cv=none; b=fvaCLpUtM0Sd9xbirFPSSSRf5PXqeLPtqwN8jCJtY04r8ezfn6zAwWXsJ69sOALJR8Ygtc8HL0fwGxtUmCKecZoMOrE3Al5FRyKwTBmeoidHyR0o4ExQDj2qQintKsQJeboIWBQnz31tOINiGLGRa6m4cDfMrq7STarpEMx7Xkk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710781293; c=relaxed/simple; bh=w7GgSb9S2Enoq5taIUw0h1ISrSxBQIt+nkuhzqbWFhQ=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=FPD5bdhNbVKd4S/M2UmyLlOWSt0fLQ8VS+0V68sOdQNatNfrYh5kVCWoEVJIrFf5vOxr8g6ebcudMGZDQVF2FrMGH0XZWaccTDHyhoj9zhZ81mDeJ+QRFCPkzknYo32gMSyGlQ1UND4WuVHIVDNcek7HOGcB4rEuJsbvphCSLoc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=soleen.com; spf=pass smtp.mailfrom=soleen.com; dkim=pass (2048-bit key) header.d=soleen-com.20230601.gappssmtp.com header.i=@soleen-com.20230601.gappssmtp.com header.b=d2pC0zQ/; arc=none smtp.client-ip=209.85.160.182 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=soleen.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=soleen.com Received: by mail-qt1-f182.google.com with SMTP id d75a77b69052e-430c45ab240so11527261cf.0 for ; Mon, 18 Mar 2024 10:01:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=soleen-com.20230601.gappssmtp.com; s=20230601; t=1710781291; x=1711386091; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=n33MLXZoglDyHrWKjv9agU9CQY4n6w7XF7nYX+56vfA=; b=d2pC0zQ/Pvr/OPXRZfNkz7mEVs1yYGTR4Xin5rZ84xtEukWv0S3SQbQEWZDKOHtlpt LEovb85BBUJkw4EAeK0Qli29kaTGslKlFZ1vRVT0Nijtn2y8x3AXf+Urmraoyn6tQNFj CNPM4aPkj6NCpg8nv7k4HNae+cWoX+MZ1V5WiI5h4GY9ULmwmU25EoF9b2bG0CDknBFM 304Ad3wcENmtAu7f4pEru+YrkwLdDhc9pZLSx4HcVbvx4CYDPua7EfkHfLgChOm1LmKP PTwCPp/D9PyWnZ7RoiZ5BFq9eyi7CCPdLP+Npi/Y/E6/29X2vMI3L1U/uYQydaGqfgVo l7dA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710781291; x=1711386091; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=n33MLXZoglDyHrWKjv9agU9CQY4n6w7XF7nYX+56vfA=; b=nniy3kNjFdcdPCRB+kbMlC2xcyUCjQE99Keq0S5xgZj577ljS1pHJf8PASnDY1lIuz v12rjmFFK4oJHbeHpYihux4CVUAIRjz42PQX/L4VM+zg+2mwCdyptUS1itHBztqis+Gv 43hcwBZ9yhHxsK7+mD9nP0zfmZc25XaohYctuN89msYYn417NvHpurkaBPUffA5WStIu 9f9wmwO14V11Myos3fovnoYg5oq7ihrrxVkRIVj6r+WuikqmozYjtWyFYVNyAMCBpXDZ FsJiCnnKAzmpgAk7RmId1/s7kTjYDTGQgGe7KgBncM4cHPfRXQoNKJ2m7YBp/WT7MzLx zUoA== X-Forwarded-Encrypted: i=1; AJvYcCW0Z3JmH9wH2CYJluIzAN/wCD16tjVpOrQga/qKB31TgYdLdSfoNq7laDYjDyala+mSluJn/LoT6wd27nVsP9wkWks4V+TCdhUzFfwx X-Gm-Message-State: AOJu0YyiegVIkuNXdaRm/97NIV0S0IzXOGztCv5SOGCFudqEZHUO/J4w C6ZWzw26oy9V/7gjFVxsffe3yfKtKx6pZtJ9eji4sSBYfTdZIt1xyV8JuWZopAE5MAXh181z9J4 iN7vujTuOJCWiV5+Bq8mT04I/eqiislHA4S1VKQ== X-Received: by 2002:ac8:5cc3:0:b0:430:c1e4:2cb7 with SMTP id s3-20020ac85cc3000000b00430c1e42cb7mr8266936qta.43.1710781291061; Mon, 18 Mar 2024 10:01:31 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240311164638.2015063-1-pasha.tatashin@soleen.com> <2cb8f02d-f21e-45d2-afe2-d1c6225240f3@zytor.com> <2qp4uegb4kqkryihqyo6v3fzoc2nysuhltc535kxnh6ozpo5ni@isilzw7nth42> <39F17EC4-7844-4111-BF7D-FFC97B05D9FA@zytor.com> <74c82d8a6b5f490784cc8f16fa7d2c12@AcuMS.aculab.com> In-Reply-To: <74c82d8a6b5f490784cc8f16fa7d2c12@AcuMS.aculab.com> From: Pasha Tatashin Date: Mon, 18 Mar 2024 13:00:52 -0400 Message-ID: Subject: Re: [RFC 00/14] Dynamic Kernel Stacks To: David Laight Cc: "H. Peter Anvin" , Matthew Wilcox , Kent Overstreet , "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" Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Mon, Mar 18, 2024 at 11:39=E2=80=AFAM David Laight wrote: > > ... > > - 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. > > Why bother? > The number of tasks running in user_mode is limited to the number > of cpu. So the most you save is a few pages per cpu. > > Plausibly a context switch from an interrupt (eg timer tick) > could suspend a task without saving anything on its kernel stack. > But how common is that in reality? > In a well behaved system most user threads will be sleeping on > some event - so with an active kernel stack. > > I can also imagine that something like sys_epoll() actually > sleeps with not (that much) stack allocated. > But the calls into all the drivers to check the status > could easily go into another page. > You really wouldn't to keep allocating and deallocating > physical pages (which I'm sure has TLB flushing costs) > all the time for those processes. > > Perhaps a 'garbage collection' activity that reclaims stack > pages from processes that have been asleep 'for a while' or > haven't used a lot of stack recently (if hw 'page accessed' > bit can be used) might make more sense. > > Have you done any instrumentation to see which system calls > are actually using more than (say) 8k of stack? > And how often the user threads that make those calls do so? None of our syscalls, AFAIK. Pasha > > David > > - > Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1= 1PT, UK > Registration No: 1397386 (Wales)