Re: [PATCH 1/5] eventpoll: Convert epoll_put_uevent() to scoped user access
From: David Laight
Date: Tue Mar 10 2026 - 06:37:44 EST
On Tue, 10 Mar 2026 09:32:53 +0100
Eric Dumazet <edumazet@xxxxxxxxxx> wrote:
> On Tue, Mar 10, 2026 at 9:29 AM Christophe Leroy (CS GROUP)
> <chleroy@xxxxxxxxxx> wrote:
> >
> >
> >
> > Le 10/03/2026 à 08:54, renpanpan a écrit :
> > > [Vous ne recevez pas souvent de courriers de renpanpan@xxxxxxxxxx. Découvrez pourquoi ceci est important à https://aka.ms/LearnAboutSenderIdentification ]
> > >
> > > From: Eric Dumazet <edumazet@xxxxxxxxxx>
> > >
> > > 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@xxxxxxxxxx>
> > > Cc: Christophe Leroy <christophe.leroy@xxxxxxxxxx>
> > > Cc: Dave Hansen <dave.hansen@xxxxxxxxx>
> > > Cc: Kuniyuki Iwashima <kuniyu@xxxxxxxxxx>
> > > Signed-off-by: Linus Torvalds <torvalds@xxxxxxxxxxxxxxxxxxxx>
> > > ---
> > > 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