Received: by 2002:ab2:69cc:0:b0:1fd:c486:4f03 with SMTP id n12csp350692lqp; Tue, 11 Jun 2024 06:35:31 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXWuZgiXiZ9I0eZ/Lc3ErPxvMk5tKUMxk+7ET4mAm/HgJHoHIBkKI/JGLWP7H58VsidbmfXI1cJN7lcCj2WLJa3S2Mc697lIX4HGdqIbA== X-Google-Smtp-Source: AGHT+IFfKRPjYUIMEafq2joJClwvrqGFlzJpVf+RCW3RvJ8hsjnxwDEQZz25wtWa1CHZEFndkStX X-Received: by 2002:a17:90a:cf15:b0:2c2:cfce:357f with SMTP id 98e67ed59e1d1-2c32b495c10mr3712577a91.10.1718112930884; Tue, 11 Jun 2024 06:35:30 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1718112930; cv=pass; d=google.com; s=arc-20160816; b=l0GpilIzuZQjXrGWb9Kmk72lJE+txSyHpvmeY50Zi9BaFtfnybqIr6aRjhpfh+rVuK 2HMF63ZrR9G29VjSo3fti9IWyCv+z2xhjkCAqnEqGPShRgO7Izdz17B6ZdQSH+SFNbuk HSA/i0CSbShFxBw9Y81JX3vUk2ojA550XlfSHCFl2nmb/2LaunLfmn7GsIEGQXKNx2Rf 9CvNVIFXjpwRg3Sf+IGPYskM2c9yVkxNsxlZYjgMJOZBDOxvin6konenZrcd8zkhFW9/ j0J7pGv3oRAsQA+tXsgMqyBIjWEGeF85ROKYC5r2z8TETBJRXN27tYKYvA3sz1Ypghyl ntuA== 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:date:dkim-signature; bh=zQ+BxX3PrQzzODbCatHqH6d2NIV0kiBDQVnXJqq7btA=; fh=q9L4RvGEVxmZmvoDcOw3gU5gmMJdbjKu335i+104Cx0=; b=cInfrMbX9RsClUesmuMCqK4R5bQMXLggGVzzNTtBwfZzJL3le9W+P+WMoeQVMIuKOQ CgD4DrQt3UsfApp6T5Yje+pCsm/umQqTUOblfgEj55V9wuXtXafkH/JD/w9bjSTnpPWp ky9xo+3FFRuerNhzZO0ETK1qhPmOs61Rxi2VW6NCFU4QxPNxM/6m9p1LveY7PcdKyI/4 96AbOhbE7Q36+5BNSLs3dIfEXT0LA6gY08kt5a6SUN+SRJmWBpgXN9BjLHwzzp2rkuNP EjXoirOprXvG0mpN5N/MdKdTpmVDY/iUuxGa0umeF2QaVIlRjInWCs/3u2HbeMVcecAL Dx0Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@alien8.de header.s=alien8 header.b=DxvdD84i; arc=pass (i=1 spf=pass spfdomain=alien8.de dkim=pass dkdomain=alien8.de dmarc=pass fromdomain=alien8.de); spf=pass (google.com: domain of linux-kernel+bounces-209927-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-209927-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=alien8.de Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id 98e67ed59e1d1-2c2806d2a75si5887692a91.163.2024.06.11.06.35.30 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Jun 2024 06:35:30 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-209927-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@alien8.de header.s=alien8 header.b=DxvdD84i; arc=pass (i=1 spf=pass spfdomain=alien8.de dkim=pass dkdomain=alien8.de dmarc=pass fromdomain=alien8.de); spf=pass (google.com: domain of linux-kernel+bounces-209927-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-209927-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=alien8.de 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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 2F247B23712 for ; Tue, 11 Jun 2024 13:21:42 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 7371117CA1F; Tue, 11 Jun 2024 13:21:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (4096-bit key) header.d=alien8.de header.i=@alien8.de header.b="DxvdD84i" Received: from mail.alien8.de (mail.alien8.de [65.109.113.108]) (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 123C11E49E; Tue, 11 Jun 2024 13:21:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=65.109.113.108 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718112083; cv=none; b=RYN1FUhQAMG2/S2vTbxfEgyrw4kqUFf3U/vsIreIvolJ2tfWFU4i/imCq5aP7+n11ZGAqIat5DdCXLdSrcLBRMKG5HxqBvgzpnyyg71GfDmIy/LRWxftQLbl/vBZNXWwt1TtMyvijD6uz2P6jhhM1fDfhkAHIODP8WuviSOo9Fk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718112083; c=relaxed/simple; bh=X1hSkvk6h7lhP8sMpTcZZ7DbBkJ7/im+J+Og9GUrz9g=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=J9bFYjaA7buVFWnsQ5CsIgzgxIPZ0EO2eMJNTD/vv3orkNUENsOYQn88Y+e8pYWBOKinp9GmmCmUXt/aKW3EBBLN/oTITsPIgtOrRsOj1FOChAlDygDMkcrI3eZAPp0ve64OY/NTSdvV4XXB5V6zueskLEAOOOc1ZF9+pfprUU8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=alien8.de; spf=pass smtp.mailfrom=alien8.de; dkim=pass (4096-bit key) header.d=alien8.de header.i=@alien8.de header.b=DxvdD84i; arc=none smtp.client-ip=65.109.113.108 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=alien8.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=alien8.de Received: from localhost (localhost.localdomain [127.0.0.1]) by mail.alien8.de (SuperMail on ZX Spectrum 128k) with ESMTP id 8AC4A40E0176; Tue, 11 Jun 2024 13:21:18 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at mail.alien8.de Authentication-Results: mail.alien8.de (amavisd-new); dkim=pass (4096-bit key) header.d=alien8.de Received: from mail.alien8.de ([127.0.0.1]) by localhost (mail.alien8.de [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id NZ1hmuE9M5Y4; Tue, 11 Jun 2024 13:21:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alien8.de; s=alien8; t=1718112075; bh=zQ+BxX3PrQzzODbCatHqH6d2NIV0kiBDQVnXJqq7btA=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=DxvdD84iZ7vkwy/GvG5iLU+PF24hOVegUPStZg5nj4tulE2nolmF/5l+Jg23Mzrb5 pKSKtGl5mNzmXW1VQxPq15vrql+olUD1H1M8KhNjltUoUp093Y51ig1IBgtN1lfQQE xLNjFs9Ayl547gAgAmk3p4p3ULlBgfCy/PL7V6laE062RfDkQUVAUh7atsd1BU9eIM 730R8GrY2PFFPqH7xxlFzcYqyg9un7lXmf2Gg9De99JYcLejzt4X3csmYu0PVv5Ut1 A+av9GKUlgUvANRvbIXCvc6XsByLhpEzigdXdK2Xzr79YOROzgrddx2Fm/M77dmn5V y4TulMB4/iPnm6hleHLUjlCBWVyF22p0OLnqEndmuOCuNo0lUeonGK5q6opIl3pw7A JojicZc0dVrVqCqlUzVfaHkwqeGbKoziUkrayZYt1KvJgfX/iu+SiYqlaCVtgBspM+ cnncKbWju/zrnotRrZeTlL7NSFiIe12cNXefqF2X7x9abige97bg82tL5ButTOPnVW icFgxAZ2/thJHuzTCeE4wQc56T6eiP0f0zzK2bLMsXfs1LB5YeWcxzcSPUhpiMW+1O D1jGWI6Tsi5Mxx3JtspmXlpKIPNGE9C87SeRbd43WLotmSDQ+x7LD9nn+F5jSWVEn/ 4lt9FT9kKutm2+i6Gv+afIsc= Received: from zn.tnic (p5de8ee85.dip0.t-ipconnect.de [93.232.238.133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature ECDSA (P-256) server-digest SHA256) (No client certificate requested) by mail.alien8.de (SuperMail on ZX Spectrum 128k) with ESMTPSA id 4E66540E0031; Tue, 11 Jun 2024 13:21:05 +0000 (UTC) Date: Tue, 11 Jun 2024 15:21:04 +0200 From: Borislav Petkov To: Linus Torvalds Cc: Peter Zijlstra , Peter Anvin , Ingo Molnar , Thomas Gleixner , Rasmus Villemoes , Josh Poimboeuf , Linux Kernel Mailing List , the arch/x86 maintainers , linux-arch Subject: Re: [PATCH] x86: add 'runtime constant' infrastructure Message-ID: <20240611132104.GDZmhPQNZm3vOBRA32@fat_crate.local> References: <20240608193504.429644-2-torvalds@linux-foundation.org> <20240610104352.GT8774@noisy.programming.kicks-ass.net> <20240610120201.GAZmbrOYmcA21kD8NB@fat_crate.local> 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=utf-8 Content-Disposition: inline In-Reply-To: /me saves a pointer to that mail to show to eager submitters who will want to jump on this new thing. On Mon, Jun 10, 2024 at 11:20:21AM -0700, Linus Torvalds wrote: > So for example, if the code could possibly be a module, it's never > going to be able to use runtime constants. Perfectly fine with that. > If the code doesn't show up as "noticeable percentage of kernel time > on real loads", it will not be a valid use for runtime constants. > > The reason I did __d_lookup_rcu() is that I have optimized that > function to hell and back before, and it *still* showed up at 14% of > kernel time on my "empty kernel build" benchmark. And the constant > load was a noticeable - but not dominant - part of that. I have seen mails from you, off and on, about __d_lookup_rcu() :-P > And yes, it shows up that high because it's all D$ misses, and the > machine I tested on has more CPU cores than cache, so it's all kinds > of broken. But the point ends up being that __d_lookup_rcu() is just > very very hot on loads that just do a lot of 'stat()' calls (and such > loads exist and aren't just microbenchmarks). Yap. > And yes, the benchmarks I run are odd ("why would anybody care about > an empty kernel build?") but somewhat real to me (since I do builds > between every pull even when they just change a couple of files). You're not the only one - I'm building every patch too so yeah, got a nice Threadripper for exactly that purpose too. :-) > And yes, to actually even see anything else than the CPU security > issues on x86, you need to build without debug support, and without > retpolines etc. So my profiles are "fake" in that sense, because they > are the best case profiles without a lot of the horror that people > enable. Right, I run with the default settings because, well, we must eat our own dogfood but yeah, all that zoo of config options to disable the mitigations wasn't added just for fun so others will run similar situtaions too, if they don't do that already. > Others will have other real benchmarks, which is why I do think we'd > end up with more uses of this. But I would expect a handful, not > "hundreds". That's a good rule. In talking to Peter I also didn't like the thing of having a single ELF section per variable but if we're doing handful, meh, ok, I guess. > I could imagine some runtime constant in the core networking socket > code, for example. Or in some scheduler thing. Or kernel entry code. > > But not ever in a driver or a filesystem, for example. Once you've > gotten that far off the core code path, the "load a variable" overhead > just isn't relevant any more. Yeah, that makes sense. Thx. -- Regards/Gruss, Boris. https://people.kernel.org/tglx/notes-about-netiquette