mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v3] eventpoll: Convert epoll_put_uevent() to scoped user access
@ 2026-03-07 20:07 Eric Dumazet
  2026-03-07 23:33 ` Linus Torvalds
  2026-03-08 16:18 ` Christophe Leroy (CS GROUP)
  0 siblings, 2 replies; 6+ messages in thread
From: Eric Dumazet @ 2026-03-07 20:07 UTC (permalink / raw)
  To: Linus Torvalds
  Cc: linux-kernel, Thomas Gleixner, Eric Dumazet, Eric Dumazet,
	Christophe Leroy, Dave Hansen, Kuniyuki Iwashima

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 <edumazet@google.com>
Cc: Christophe Leroy <christophe.leroy@csgroup.eu>
Cc: Dave Hansen <dave.hansen@intel.com>
Cc: Kuniyuki Iwashima <kuniyu@google.com>
---
Prior attempts by Kuniyuki, in case some background is needed:

v2 : https://lkml.org/lkml/2025/10/28/1553
v1:  https://lore.kernel.org/lkml/20251023000535.2897002-1-kuniyu@google.com/

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) {
+		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
-- 
2.53.0.473.g4a7958ca14-goog


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2026-03-08 16:18 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-03-07 20:07 [PATCH v3] eventpoll: Convert epoll_put_uevent() to scoped user access Eric Dumazet
2026-03-07 23:33 ` Linus Torvalds
2026-03-07 23:45   ` Linus Torvalds
2026-03-08  5:19     ` Eric Dumazet
2026-03-08 10:08       ` David Laight
2026-03-08 16:18 ` Christophe Leroy (CS GROUP)

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®