Re: [PATCH v2] epoll: Use user_write_access_begin() and unsafe_put_user() in epoll_put_uevent().

From: Linus Torvalds

Date: Tue Oct 28 2025 - 15:12:57 EST


On Tue, 28 Oct 2025 at 12:02, Linus Torvalds
<torvalds@xxxxxxxxxxxxxxxxxxxx> wrote:
>
> Because I think the proper patch should look something like the
> attached.. For me, that generates
>
> movabs $0x123456789abcdef,%rcx
> cmp %rcx,%r15
> cmova %rcx,%r15
> stac
> mov %r12d,(%r15)
> mov %rax,0x4(%r15)
> clac
>
> which honestly should be pretty much optimal.

Side note: when I say "pretty much optimal", the truly optimal
situation would be to do the address masking entirely outside the loop
in ep_send_events(), but we don't expose that interface, and we have
absolutely horrible experiences with doing user address checking
separately from the actual code that does the access, so I'm really
loathe to add that kind of logic.

So the above is *not* optimal in the sense that the

movabs $0x123456789abcdef,%rcx
cmp %rcx,%r15
cmova %rcx,%r15

part certainly *could* be done outside the list_for_each_entry_safe()
loop in ep_send_events(), but I do not think that three simple
ALU-only instructions should make a difference here.

Linus