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]) by smtp.lore.kernel.org (Postfix) with ESMTP id A202DC4332F for ; Tue, 7 Nov 2023 23:39:35 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 276084401B8; Tue, 7 Nov 2023 18:39:35 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 2263B44017B; Tue, 7 Nov 2023 18:39:35 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0EE024401B8; Tue, 7 Nov 2023 18:39:35 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id F190C44017B for ; Tue, 7 Nov 2023 18:39:34 -0500 (EST) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id CCBCDB52A2 for ; Tue, 7 Nov 2023 23:39:34 +0000 (UTC) X-FDA: 81432777468.20.615BB36 Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by imf30.hostedemail.com (Postfix) with ESMTP id 8C03B8001E for ; Tue, 7 Nov 2023 23:39:32 +0000 (UTC) Authentication-Results: imf30.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=rAPIXaHI; spf=pass (imf30.hostedemail.com: domain of kees@kernel.org designates 145.40.73.55 as permitted sender) smtp.mailfrom=kees@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1699400373; 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=+C+hxF5se7H0Zn3VsVDbfc4CaLODaUATsvtBNCA4QnU=; b=s/NMFptA/TX9qbBTcakRBS742IMF6s1WYZaUu09m1warQiAJamtLz/UUaEouNCbXt6DYlW aMdiUtAhA3+pTP55kzi14QH60ag0wrTuI8ufOvxmXwhmnY2ZASaFBzHRZC+A/GgbR1r1WQ fgPAD0pDLhFbxG+pmD0PKpgSnrR5ZP4= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1699400373; a=rsa-sha256; cv=none; b=5gQ1Iii1D9Fdh9RAKT/NSVN9BAhn0NwTuOQMtpDzawlueziH1FuAVxUh8hL3KwbjLY8xxt ORhUBKKai3kIcEzcocoIc0htD89cW84sAZfpChBqjJxjnCkRHq3X0QkmETLKJK1GcTGwvf kip1m6ZbvDuyMPtTXGTSOrDrr9A+bXA= ARC-Authentication-Results: i=1; imf30.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=rAPIXaHI; spf=pass (imf30.hostedemail.com: domain of kees@kernel.org designates 145.40.73.55 as permitted sender) smtp.mailfrom=kees@kernel.org; dmarc=pass (policy=none) header.from=kernel.org Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id 04D1CCE0FD4; Tue, 7 Nov 2023 23:39:29 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2CC3DC433C8; Tue, 7 Nov 2023 23:39:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1699400368; bh=Mj2pwAn8Ayyso+nFqVs/qWRLklVo1CoXY6S2HNE1B58=; h=Date:From:To:CC:Subject:In-Reply-To:References:From; b=rAPIXaHIDgIZQR3P2JuU+NcVe9EuOwlx1iNGZeG2Xi0sJ1W4HVZWsehsjhPNPtE8V 5snCqAbXmW73htMvn4b9I2v5cLJixZj8rJP4xRliGNmioL1VP13RRGTuL9yzdbXYyp KHzgmLAy8w804FnWscmh1RaG400zjPNJNVoyIzNf56CNMsMOdEgJNYCOuGT20J7+XR Jvav0JCcHP3SguaQ27D756T7GOQ/TCVxzViillu0sUNXYblFiuu2IsIBfch33DoVAF qfkNysMAoD7qQuVW11YeGV8t4ZIQslOJ4fLOXSO6HJ3b5S6xIQhx1iZ6MWZZNRk3jq I53rTUVpcsKXg== Date: Tue, 07 Nov 2023 15:39:28 -0800 From: Kees Cook To: Mateusz Guzik , Kees Cook CC: Josh Triplett , Eric Biederman , Alexander Viro , linux-mm@kvack.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: =?US-ASCII?Q?Re=3A_=5BPATCH=5D_fs/exec=2Ec=3A_Add_fast_path_for_?= =?US-ASCII?Q?ENOENT_on_PATH_search_before_allocating_mm?= User-Agent: K-9 Mail for Android In-Reply-To: References: <5c7333ea4bec2fad1b47a8fa2db7c31e4ffc4f14.1663334978.git.josh@joshtriplett.org> <202311071228.27D22C00@keescook> <20231107205151.qkwlw7aarjvkyrqs@f> <202311071445.53E5D72C@keescook> Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Rspamd-Queue-Id: 8C03B8001E X-Rspam-User: X-Stat-Signature: rorskg8ddrjsosydkxmh4htiidsk4nam X-Rspamd-Server: rspam03 X-HE-Tag: 1699400372-528636 X-HE-Meta: U2FsdGVkX18SYkhlEcMkzLeoJ1GMOdNHvJJONe5us/Qe6ZrN+Oa1EEK+3CtR8YrAhqTmwdYLwsH9usZQv8XIhuBIUcK/4b2bQqjWaBVTfGksOPqNSE0PMhjW92prcte7OUH/0S5ITFFb2vQ4V/2Q3Yl+FatuWODuGxK9oa2QzvEdaiJ1c91GPXnefsTbEt2Rf2/pkj7+XVNNjfBMVyApM7qNcv1nnB6h/GKPLggYTBXxUVKMWDa7JXuT4DMzWTzVBBmP7nU47LRqLxzIaMYBy6OlIJhXtVmeHZu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 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: On November 7, 2023 3:08:47 PM PST, Mateusz Guzik wr= ote: >On 11/7/23, Kees Cook wrote: >> On Tue, Nov 07, 2023 at 10:23:16PM +0100, Mateusz Guzik wrote: >>> If the patch which dodges second lookup still somehow appears slower a >>> flamegraph or other profile would be nice=2E I can volunteer to take a >>> look at what's going on provided above measurements will be done and >>> show funkyness=2E >> >> When I looked at this last, it seemed like all the work done in >> do_filp_open() (my patch, which moved the lookup earlier) was heavier >> than the duplicate filename_lookup()=2E >> >> What I didn't test was moving the sched_exec() before the mm creation, >> which Peter confirmed shouldn't be a problem, but I think that might be >> only a tiny benefit, if at all=2E >> >> If you can do some comparisons, that would be great; it always takes me >> a fair bit of time to get set up for flame graph generation, etc=2E :) >> > >So I spawned *one* process executing one statocally linked binary in a >loop, test case from http://apollo=2Ebackplane=2Ecom/DFlyMisc/doexec=2Ec = =2E > >The profile is definitely not what I expected: > 5=2E85% [kernel] [k] asm_exc_page_fault > 5=2E84% [kernel] [k] __pv_queued_spin_lock_slowpath >[snip] > >I'm going to have to recompile with lock profiling, meanwhile >according to bpftrace >(bpftrace -e 'kprobe:__pv_queued_spin_lock_slowpath { @[kstack()] =3D cou= nt(); }') >top hits would be: > >@[ > __pv_queued_spin_lock_slowpath+1 > _raw_spin_lock+37 > __schedule+192 > schedule_idle+38 > do_idle+366 > cpu_startup_entry+38 > start_secondary+282 > secondary_startup_64_no_verify+381 >]: 181 >@[ > __pv_queued_spin_lock_slowpath+1 > _raw_spin_lock_irq+43 > wait_for_completion+141 > stop_one_cpu+127 > sched_exec+165 There's the suspicious sched_exec() I was talking about! :) I think it needs to be moved, and perhaps _later_ instead of earlier? Hmm= =2E=2E=2E -Kees > bprm_execve+328 > do_execveat_common=2Eisra=2E0+429 > __x64_sys_execve+50 > do_syscall_64+46 > entry_SYSCALL_64_after_hwframe+110 >]: 206 > >I did not see this coming for sure=2E I'll poke around maybe this weekend= =2E > --=20 Kees Cook