Received: by 2002:a05:7412:e794:b0:fa:551:50a7 with SMTP id o20csp709496rdd; Tue, 9 Jan 2024 18:21:41 -0800 (PST) X-Google-Smtp-Source: AGHT+IHTMPueMTeyMfwVTPT7q/PBEExm6XY5pTtK5+g3cn7bY/cGIcHJuJdOWeF+FZvhyUV83Goe X-Received: by 2002:ac8:5a10:0:b0:429:7c62:99dd with SMTP id n16-20020ac85a10000000b004297c6299ddmr607624qta.0.1704853300863; Tue, 09 Jan 2024 18:21:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704853300; cv=none; d=google.com; s=arc-20160816; b=hsMJVMrXWweBSt7jikvGWdHDSIVSrEwK7LzN8ZdR7BWqFjfbQXfOGY/w+YLovPmNsr 1EdydWjFMVxVcm0F3iAx9Qf+M5ilyQinBIjxjnIYe2KVJh1i0WToZNFowM0XT1tpKPvL SLOsC49VcQd8g8YQ9btFCvTZS0YAhT078pyVSzC7eEzSnpzVmxPeOLmp37zRlNRfM9dJ iIQhH48GqIXW1AI0mxZFf9xamskJ6qZa1q3VV5DJLNagdeAYNOY5tSEtkUp7+PYVx/d0 Xd4Cx0DQ/Ch0OhzYCF+TTomdwLx5GR1wHTj2eBQ1MW/rZvUCmczYCAC1KbnEEEb4ylKu cOVw== ARC-Message-Signature: i=1; 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:feedback-id:dkim-signature:dkim-signature; bh=+EPYgfAmtFY42lGNnY07XOeiD5ZtD7yHEq0BdfanLnY=; fh=56jOSXiXvZ2b2RtCa3CShd1r8Rh47FPXf4yEcthvjUk=; b=fbXdBWrJMZT+SZrmNp+jMtFZd/gyllWNCL7NSnZR84fcLnWKqFThRZK22nSRZ7O6Q8 +BZrYE+yJoZw/256/FDKBGDkZEbpRQbeHaxt6bJV6Y/u4THNkFRhvPlrKF8mthoERFAb cznQv+jK616SlgfYll48QaMp69AXCS50gPkVQkc7/wSmevvldbhQabDLY7h/LnUPsv/u Sujq4X39hox6U9WbIoqR6C8K4kUVcGxWGhETRCcd4AT2xb+gKkd01Gh+MYebgz3KVvrE 9BXXm0+WT0DDs27XvMcWIP3+9Q5GXrgjc2THo7Q6m1BYBImqIoxc4LgFx1IoUTmQ9ZJx iUZA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@joshtriplett.org header.s=fm1 header.b=IZvpS5rb; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b=lQj9qlMX; spf=pass (google.com: domain of linux-kernel+bounces-21652-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-21652-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id jd13-20020a05622a718d00b00429a21c4982si3571957qtb.425.2024.01.09.18.21.40 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Jan 2024 18:21:40 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-21652-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@joshtriplett.org header.s=fm1 header.b=IZvpS5rb; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b=lQj9qlMX; spf=pass (google.com: domain of linux-kernel+bounces-21652-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-21652-linux.lists.archive=gmail.com@vger.kernel.org" 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 8FF161C25483 for ; Wed, 10 Jan 2024 02:21:40 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B1A531871; Wed, 10 Jan 2024 02:21:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=joshtriplett.org header.i=@joshtriplett.org header.b="IZvpS5rb"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="lQj9qlMX" Received: from wout1-smtp.messagingengine.com (wout1-smtp.messagingengine.com [64.147.123.24]) (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 04E6B17C6 for ; Wed, 10 Jan 2024 02:21:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=joshtriplett.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=joshtriplett.org Received: from compute7.internal (compute7.nyi.internal [10.202.2.48]) by mailout.west.internal (Postfix) with ESMTP id 837823200ADA; Tue, 9 Jan 2024 21:21:28 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute7.internal (MEProxy); Tue, 09 Jan 2024 21:21:29 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= joshtriplett.org; h=cc:cc:content-type:content-type:date:date :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to; s=fm1; t=1704853288; x=1704939688; bh=+EPYgfAmtFY42lGNnY07XOeiD5ZtD7yHEq0BdfanLnY=; b= IZvpS5rbsMV7m6VAvFsfpOeHPlCMEVUvtgGeXM4opGKmVYvXehQd6zXiMunzAbBu FZBuUx0TK3VTYkk/sqvWag8qM0sxTgwd4zNFQV32V3vAeC4j2zONn7Mg4kuXhMCt iGd4S0gLUlaUBbHYl8ckCl1cn0eoKWN2W+WWQrauZTVq89f+POWTBXYKaHzfcTEE w++b611gwJW+qyu1VIyBnfuSrBHkMDZyQwckgmg0Cl08hQo3cntpw0R9IbZXm5J7 5c/9KM2WSupLGr+apZhB5o972y333c3rrC3D8zWlg19Z2VmU2S0k5saTKnag31E4 ZaHF3GkvuaUfxv/l4TIdlg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:subject:subject:to :to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm2; t=1704853288; x=1704939688; bh=+EPYgfAmtFY42lGNnY07XOeiD5Zt D7yHEq0BdfanLnY=; b=lQj9qlMXrRILtujM/EurCRX6rSUm+eMPqjd0pCHdPPir 1kA2WIS2eT3eAWq/m8Wsr31H0vzvBpndxrTyp3DuWoubJQC3FYC5mvxCJrNc6WRr +dAnFYC3lkLwnEDWNflyp5f547ZfaASf1GmZR+rFcyYQi2ItPCG1EfT+nPSjHVLp CDFroTHX67jXqczFveLR6RY1kEL85f2tbnCfY/SnCY9hRJ1cSQaMk0TcS2A9g0dH jVaJm+GArb5iVgZJHJ6ZtrnfcMJbpyRjbhIPBFc5eFHJZu0jAcIiAcMUU0Oiom9x EXO2qy6Kux+xIA7MZcfBa2TEpkIB0CFntqPXnPO7HA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvkedrvdeitddggeeiucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepfffhvfevuffkfhggtggujgesmhdtreertddtvdenucfhrhhomheplfhoshhh ucfvrhhiphhlvghtthcuoehjohhshhesjhhoshhhthhrihhplhgvthhtrdhorhhgqeenuc ggtffrrghtthgvrhhnpedtffffvdeuleeifeevleeltddtueffheelffdvveetjeevueff fffhgeettefhfeenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfh hrohhmpehjohhshhesjhhoshhhthhrihhplhgvthhtrdhorhhg X-ME-Proxy: Feedback-ID: i83e94755:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 9 Jan 2024 21:21:27 -0500 (EST) Date: Tue, 9 Jan 2024 18:21:26 -0800 From: Josh Triplett To: Linus Torvalds Cc: Kees Cook , Kees Cook , linux-kernel@vger.kernel.org, Alexey Dobriyan Subject: Re: [GIT PULL] execve updates for v6.8-rc1 Message-ID: References: <202401081028.0E908F9E0A@keescook> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="8ZxgmFvOhzj0HYkM" Content-Disposition: inline In-Reply-To: --8ZxgmFvOhzj0HYkM Content-Type: text/plain; charset=us-ascii Content-Disposition: inline I'm not going to spend a lot of time and energy attempting to argue that spawnbench is a representative benchmark, or that scheduling overhead is a relevant part of program launch. Instead, here are some numbers from Linus's suggested benchmark (modified to use execvpe, and to count down rather than up so it doesn't need two arguments; modified version and benchmark driver script attached; compiled with `musl-gcc -Wall -O3 -s -static`): With no patch (for-next/execve before the top two patches, 21ca59b365c091d583f36ac753eaa8baf947be6f): === With only PATH === 0.32user 4.08system 0:04.55elapsed 96%CPU (0avgtext+0avgdata 1280maxresident)k 0inputs+0outputs (0major+1294599minor)pagefaults 0swaps === With 64 extra environment variables === 0.29user 5.33system 0:05.76elapsed 97%CPU (0avgtext+0avgdata 1280maxresident)k 0inputs+0outputs (0major+1312477minor)pagefaults 0swaps With my fastpath patch (for-next/execve, 0a8a952a75f2c5c140939c1616423e240677666c): === With only PATH === 0.27user 2.40system 0:02.73elapsed 98%CPU (0avgtext+0avgdata 1152maxresident)k 0inputs+0outputs (0major+695002minor)pagefaults 0swaps === With 64 extra environment variables === 0.29user 2.59system 0:02.94elapsed 98%CPU (0avgtext+0avgdata 1152maxresident)k 0inputs+0outputs (0major+712606minor)pagefaults 0swaps With Linus's fastpath patch ("no patch" with Linus's applied, and the followup -ENOMEM fix applied): === With only PATH === 0.28user 2.44system 0:02.80elapsed 97%CPU (0avgtext+0avgdata 1152maxresident)k 0inputs+0outputs (0major+694706minor)pagefaults 0swaps === With 64 extra environment variables === 0.29user 2.68system 0:03.06elapsed 97%CPU (0avgtext+0avgdata 1152maxresident)k 0inputs+0outputs (0major+712431minor)pagefaults 0swaps I can reliably reproduce the differences between these three kernels; the differences are well outside the noise. Both fastpaths are *much* faster than the baseline, but the double-lookup version is still consistently faster than the single-lookup version. I'm sure it's *possible* to create a benchmark in which the single-lookup version is faster. But in this benchmark of *just* execvpe, it's still the case that double-lookup is faster, for *some* reason. I agree that it *shouldn't* be, and yet. --8ZxgmFvOhzj0HYkM Content-Type: text/x-csrc; charset=us-ascii Content-Disposition: attachment; filename="t-linus-modified.c" #include #include #include int main(int argc, char **argv, char **envp) { char buffer[12]; int n; if (argc != 2) return 1; n = atoi(argv[1]); if (n <= 0) return 0; snprintf(buffer, sizeof(buffer), "%d", n-1); argv[1] = buffer; execvpe("t", argv, envp); return 3; } --8ZxgmFvOhzj0HYkM Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=bench #!/bin/sh echo === With only PATH === /usr/bin/time env -i PATH=/home/josh/.local/bin:/usr/lib/ccache:/sbin:/bin:/usr/sbin:/usr/bin:. t 100000 echo echo === With 64 extra environment variables === /usr/bin/time env -i $(seq 1 64 | sed 's/.*/x&=&/') PATH=/home/josh/.local/bin:/usr/lib/ccache:/sbin:/bin:/usr/sbin:/usr/bin:. t 100000 --8ZxgmFvOhzj0HYkM--