From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 664292FFDD8 for ; Sun, 8 Mar 2026 16:18:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772986706; cv=none; b=IeVvqfPO8LQeFgIjUc/kgFJabQPwpGMqByN+2Sf4ymU4I2LBZPiRZOSylgN2+CeJSrdQj5s5e7cq8W3TfpGOi9+h9nMFNOW4g7WRG8dG7aDgbwL+AW8CR7U8kfDYZ6ycQSEGfkjj1Srymjw7jRvNNcmmxYH7taM//ETy6Lxqi94= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772986706; c=relaxed/simple; bh=ye+cmRxnQBXrmy8BkQwrd8fVCtWWNwPqfVb0yEsTjpA=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=Pzw/HJ2m5jSmQV52C6CR4Is5cdVCjqbK7eEOrm2FH7Wl8ozXS1oAn4jx2EZY+aCtf8zpayLPkgMztv5A7NYlyQstxODAfedJhqJqBm4oB051eyaYxvZwjinE7njeGAVeYtNNMacy+5T5pjJHNHapVudkOoK9MNGxMLEBpIIZsjI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=LlX7AOCM; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="LlX7AOCM" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0D66FC116C6; Sun, 8 Mar 2026 16:18:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1772986706; bh=ye+cmRxnQBXrmy8BkQwrd8fVCtWWNwPqfVb0yEsTjpA=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=LlX7AOCMgGOOdm1BeI5xyx6xRhr5eq3Gqwj9qzfpBSdleEi8jRf9m/J1BtA83WDkf h5hdtQy/zhbSx/LLjSwWqRJFOU62+XJEzrZsbixDncNmJMQp9/iUvC56kOugebmfc/ xcC7gj2j/XebIlFv51YeDi6kqVyzk3hszLKvSpNyk3d1YIDeEd6USU7chUbSha59Kw 9GFwh2MhP1Xm4XuftsXdaM9Od0+Z56H2MmbXwKT/rPn3lNsLnWhFPiYAHzxLWEJgrm y+05PYhUaVazxGzxougDSGYDfDRD9NqSJcjUHFPgis2iQrox0T9m7Gd8p5qnqBTXNY isJqxJ/OteDnQ== Message-ID: <8170fcc1-6882-4f0e-baeb-023d27ac9c4c@kernel.org> Date: Sun, 8 Mar 2026 17:18:17 +0100 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v3] eventpoll: Convert epoll_put_uevent() to scoped user access To: Eric Dumazet , Linus Torvalds Cc: linux-kernel , Thomas Gleixner , Eric Dumazet , Dave Hansen , Kuniyuki Iwashima References: <20260307200715.1464206-1-edumazet@google.com> Content-Language: fr-FR From: "Christophe Leroy (CS GROUP)" In-Reply-To: <20260307200715.1464206-1-edumazet@google.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Le 07/03/2026 à 21:07, Eric Dumazet a écrit : > Saves two function calls, and one stac/clac pair. > > stac/clac is rather expensive on older cpus like Zen 2. > > A synthetic network stress test gives a ~1.5% increase of pps > on AMD Zen 2. > > Signed-off-by: Eric Dumazet > Cc: Christophe Leroy > Cc: Dave Hansen > Cc: Kuniyuki Iwashima > --- > Prior attempts by Kuniyuki, in case some background is needed: > > v2 : https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Flkml.org%2Flkml%2F2025%2F10%2F28%2F1553&data=05%7C02%7Cchristophe.leroy%40csgroup.eu%7C85a6664e663a4b224ce208de7c852734%7C8b87af7d86474dc78df45f69a2011bb5%7C0%7C0%7C639085108483835748%7CUnknown%7CTWFpbGZsb3d8eyJFbXB0eU1hcGkiOnRydWUsIlYiOiIwLjAuMDAwMCIsIlAiOiJXaW4zMiIsIkFOIjoiTWFpbCIsIldUIjoyfQ%3D%3D%7C0%7C%7C%7C&sdata=tYX5SAFAkM%2B4b2ooJnd8A%2FCO3hp8Evn1AmB0R5TFI4M%3D&reserved=0 > v1: https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Flore.kernel.org%2Flkml%2F20251023000535.2897002-1-kuniyu%40google.com%2F&data=05%7C02%7Cchristophe.leroy%40csgroup.eu%7C85a6664e663a4b224ce208de7c852734%7C8b87af7d86474dc78df45f69a2011bb5%7C0%7C0%7C639085108483859728%7CUnknown%7CTWFpbGZsb3d8eyJFbXB0eU1hcGkiOnRydWUsIlYiOiIwLjAuMDAwMCIsIlAiOiJXaW4zMiIsIkFOIjoiTWFpbCIsIldUIjoyfQ%3D%3D%7C0%7C%7C%7C&sdata=wfPZz01ZLu%2B4HABR941GaOE6PnsLlsAnm%2F0xVEsjM8g%3D&reserved=0 > > Thanks ! > --- > include/linux/eventpoll.h | 11 +++++++---- > 1 file changed, 7 insertions(+), 4 deletions(-) > > diff --git a/include/linux/eventpoll.h b/include/linux/eventpoll.h > index ccb478eb174bc2e4454cee59f805f10cfd5bb5fb..ea9ca0e4172aab13b8e576258e1d457a913dcebf 100644 > --- a/include/linux/eventpoll.h > +++ b/include/linux/eventpoll.h > @@ -82,11 +82,14 @@ static inline struct epoll_event __user * > epoll_put_uevent(__poll_t revents, __u64 data, > struct epoll_event __user *uevent) > { > - if (__put_user(revents, &uevent->events) || > - __put_user(data, &uevent->data)) > - return NULL; > - > + scoped_user_write_access_size(uevent, sizeof(*uevent), efault) { You can use scoped_user_write_access() instead which is defined as #define scoped_user_write_access(udst, elbl) \ scoped_user_write_access_size(udst, sizeof(*(udst)), elbl) > + unsafe_put_user(revents, &uevent->events, efault); > + unsafe_put_user(data, &uevent->data, efault); > + } > return uevent+1; > + > +efault: > + return NULL; > } > #endif > > > base-commit: 4ae12d8bd9a830799db335ee661d6cbc6597f838 > prerequisite-patch-id: f6002c357582927a383603a22e69bc0d7a5b9528