* [PATCH 1/5] eventpoll: Convert epoll_put_uevent() to scoped user access @ 2026-03-10 7:54 renpanpan 2026-03-10 8:28 ` Christophe Leroy (CS GROUP) 0 siblings, 1 reply; 6+ messages in thread From: renpanpan @ 2026-03-10 7:54 UTC (permalink / raw) To: linux-kernel Cc: edumazet, Christophe Leroy, Dave Hansen, Kuniyuki Iwashima, Linus Torvalds From: Eric Dumazet <edumazet@google.com> 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> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> --- 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 ccb478eb174b..ea9ca0e4172a 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 -- 2.25.1 ^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH 1/5] eventpoll: Convert epoll_put_uevent() to scoped user access 2026-03-10 7:54 [PATCH 1/5] eventpoll: Convert epoll_put_uevent() to scoped user access renpanpan @ 2026-03-10 8:28 ` Christophe Leroy (CS GROUP) 2026-03-10 8:32 ` Eric Dumazet 0 siblings, 1 reply; 6+ messages in thread From: Christophe Leroy (CS GROUP) @ 2026-03-10 8:28 UTC (permalink / raw) To: renpanpan, linux-kernel Cc: edumazet, Dave Hansen, Kuniyuki Iwashima, Linus Torvalds Le 10/03/2026 à 08:54, renpanpan a écrit : > [Vous ne recevez pas souvent de courriers de renpanpan@kylinos.cn. Découvrez pourquoi ceci est important à https://aka.ms/LearnAboutSenderIdentification ] > > From: Eric Dumazet <edumazet@google.com> > > 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> > Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> > --- > 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 ccb478eb174b..ea9ca0e4172a 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) { As already mentionned this could be simplified: scoped_user_write_access(uevent, efault) { > + unsafe_put_user(revents, &uevent->events, efault); > + unsafe_put_user(data, &uevent->data, efault); > + } > return uevent+1; > + > +efault: > + return NULL; > } > #endif > > -- > 2.25.1 > ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 1/5] eventpoll: Convert epoll_put_uevent() to scoped user access 2026-03-10 8:28 ` Christophe Leroy (CS GROUP) @ 2026-03-10 8:32 ` Eric Dumazet 2026-03-10 10:25 ` Christophe Leroy (CS GROUP) 2026-03-10 10:36 ` David Laight 0 siblings, 2 replies; 6+ messages in thread From: Eric Dumazet @ 2026-03-10 8:32 UTC (permalink / raw) To: Christophe Leroy (CS GROUP) Cc: renpanpan, linux-kernel, Dave Hansen, Kuniyuki Iwashima, Linus Torvalds On Tue, Mar 10, 2026 at 9:29 AM Christophe Leroy (CS GROUP) <chleroy@kernel.org> wrote: > > > > Le 10/03/2026 à 08:54, renpanpan a écrit : > > [Vous ne recevez pas souvent de courriers de renpanpan@kylinos.cn. Découvrez pourquoi ceci est important à https://aka.ms/LearnAboutSenderIdentification ] > > > > From: Eric Dumazet <edumazet@google.com> > > > > 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> > > Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> > > --- > > 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 ccb478eb174b..ea9ca0e4172a 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) { > > As already mentionned this could be simplified: Note the patch was already merged in Linus tree. Honestly having two different macros while we have 4 users for both of them seems a bit overkill to me. ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 1/5] eventpoll: Convert epoll_put_uevent() to scoped user access 2026-03-10 8:32 ` Eric Dumazet @ 2026-03-10 10:25 ` Christophe Leroy (CS GROUP) 2026-03-10 14:30 ` David Laight 2026-03-10 10:36 ` David Laight 1 sibling, 1 reply; 6+ messages in thread From: Christophe Leroy (CS GROUP) @ 2026-03-10 10:25 UTC (permalink / raw) To: Eric Dumazet Cc: renpanpan, linux-kernel, Dave Hansen, Kuniyuki Iwashima, Linus Torvalds Le 10/03/2026 à 09:32, Eric Dumazet a écrit : > On Tue, Mar 10, 2026 at 9:29 AM Christophe Leroy (CS GROUP) > <chleroy@kernel.org> wrote: >> >> >> >> Le 10/03/2026 à 08:54, renpanpan a écrit : >>> [Vous ne recevez pas souvent de courriers de renpanpan@kylinos.cn. Découvrez pourquoi ceci est important à https://aka.ms/LearnAboutSenderIdentification ] >>> >>> From: Eric Dumazet <edumazet@google.com> >>> >>> 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> >>> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> >>> --- >>> 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 ccb478eb174b..ea9ca0e4172a 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) { >> >> As already mentionned this could be simplified: > > Note the patch was already merged in Linus tree. > > Honestly having two different macros while we have 4 users for both > of them seems a bit overkill to me. There have at the time beeing (v7.0-rc3) 66 caller of user_...access_begin(), I expect most of them being converted to scoped user access over time. In addition the simplicity of scoped user access should help grow the numbre of users of user access by block. I find it quite convenient to not have to add the size when it can be extracted from the pointer type. Christophe ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 1/5] eventpoll: Convert epoll_put_uevent() to scoped user access 2026-03-10 10:25 ` Christophe Leroy (CS GROUP) @ 2026-03-10 14:30 ` David Laight 0 siblings, 0 replies; 6+ messages in thread From: David Laight @ 2026-03-10 14:30 UTC (permalink / raw) To: Christophe Leroy (CS GROUP) Cc: Eric Dumazet, renpanpan, linux-kernel, Dave Hansen, Kuniyuki Iwashima, Linus Torvalds On Tue, 10 Mar 2026 11:25:48 +0100 "Christophe Leroy (CS GROUP)" <chleroy@kernel.org> wrote: > Le 10/03/2026 à 09:32, Eric Dumazet a écrit : > > On Tue, Mar 10, 2026 at 9:29 AM Christophe Leroy (CS GROUP) > > <chleroy@kernel.org> wrote: > >> > >> > >> > >> Le 10/03/2026 à 08:54, renpanpan a écrit : > >>> [Vous ne recevez pas souvent de courriers de renpanpan@kylinos.cn. Découvrez pourquoi ceci est important à https://aka.ms/LearnAboutSenderIdentification ] > >>> > >>> From: Eric Dumazet <edumazet@google.com> > >>> > >>> 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> > >>> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> > >>> --- > >>> 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 ccb478eb174b..ea9ca0e4172a 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) { > >> > >> As already mentionned this could be simplified: > > > > Note the patch was already merged in Linus tree. > > > > Honestly having two different macros while we have 4 users for both > > of them seems a bit overkill to me. > > There have at the time beeing (v7.0-rc3) 66 caller of > user_...access_begin(), I expect most of them being converted to scoped > user access over time. In addition the simplicity of scoped user access > should help grow the numbre of users of user access by block. > > I find it quite convenient to not have to add the size when it can be > extracted from the pointer type. Lets see if it possible to support both: foo(ptr, label) and: foo(ptr, size, label) #define foo(p, ...) foo_1(p, __VA_ARGS__, sizeof *p) #define foo_1(p, s_or_l, l_or_ps, ...) \ foo_2(p, __VA_OPT__(s_or_l, l_or_ps, foo_x(__VA_ARGS__)) l_or_ps, s_or_pl) #define foo_x(one_arg) #define foo_2(p, s, l, ...) foo_real(p, s, l) untested - but might work! (foo_x() is there to error foo(a, b, c, d)) David > > Christophe > ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 1/5] eventpoll: Convert epoll_put_uevent() to scoped user access 2026-03-10 8:32 ` Eric Dumazet 2026-03-10 10:25 ` Christophe Leroy (CS GROUP) @ 2026-03-10 10:36 ` David Laight 1 sibling, 0 replies; 6+ messages in thread From: David Laight @ 2026-03-10 10:36 UTC (permalink / raw) To: Eric Dumazet Cc: Christophe Leroy (CS GROUP), renpanpan, linux-kernel, Dave Hansen, Kuniyuki Iwashima, Linus Torvalds On Tue, 10 Mar 2026 09:32:53 +0100 Eric Dumazet <edumazet@google.com> wrote: > On Tue, Mar 10, 2026 at 9:29 AM Christophe Leroy (CS GROUP) > <chleroy@kernel.org> wrote: > > > > > > > > Le 10/03/2026 à 08:54, renpanpan a écrit : > > > [Vous ne recevez pas souvent de courriers de renpanpan@kylinos.cn. Découvrez pourquoi ceci est important à https://aka.ms/LearnAboutSenderIdentification ] > > > > > > From: Eric Dumazet <edumazet@google.com> > > > > > > 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> > > > Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> > > > --- > > > 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 ccb478eb174b..ea9ca0e4172a 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) { > > > > As already mentionned this could be simplified: > > Note the patch was already merged in Linus tree. > > Honestly having two different macros while we have 4 users for both > of them seems a bit overkill to me. > I'm also not sure all the 'hidden size' macros really help readability. (especially of the header file that defines them all.) It isn't as though the source lines would get overlong - especially if the macro name was shorter. But now is the time to change anything - before there are too many users. David ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2026-03-10 14:30 UTC | newest] Thread overview: 6+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2026-03-10 7:54 [PATCH 1/5] eventpoll: Convert epoll_put_uevent() to scoped user access renpanpan 2026-03-10 8:28 ` Christophe Leroy (CS GROUP) 2026-03-10 8:32 ` Eric Dumazet 2026-03-10 10:25 ` Christophe Leroy (CS GROUP) 2026-03-10 14:30 ` David Laight 2026-03-10 10:36 ` David Laight
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox