[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CAHk-=wiA9S61o0WiDcuKXPvqadT4Os5GHHLMFnzGNGrmuEjyiA@mail.gmail.com>
Date: Tue, 28 Oct 2025 12:44:46 -0700
From: Linus Torvalds <torvalds@...ux-foundation.org>
To: Kuniyuki Iwashima <kuniyu@...gle.com>
Cc: axboe@...nel.dk, brauner@...nel.org, dave.hansen@...el.com, 
	dave.hansen@...ux.intel.com, david.laight.linux@...il.com, 
	edumazet@...gle.com, kuni1840@...il.com, linux-kernel@...r.kernel.org
Subject: Re: [PATCH v2] epoll: Use user_write_access_begin() and
 unsafe_put_user() in epoll_put_uevent().
On Tue, 28 Oct 2025 at 12:27, Kuniyuki Iwashima <kuniyu@...gle.com> wrote:
>
> Oh sorry, this was my copy-and-paste mistake, and it should have
> been can_do_masked_user_access() + masked_user_access_begin().
Ok.
> I used the diff below as the masked version.
That looks fine.
> I noticed user_access_begin() is used in "else if ()", but I
> think it should not matter as long as tested on x86_64 platform
> where can_do_masked_user_access() is true.
Correct. It's designed to be just optimized away statically based on
whether the architecture supports address masking or not.
> So, I think the diff is basically the same with the attached one.
Yes, looks fine.
> I had this with the masked version, taken from perf + 'a'.
>
> ---8<---
>         │       movabs $0x7ffffffff000,%rcx
>    0.05 │       cmp    %rcx,%r15
>    0.18 │       cmova  %rcx,%r15
>   72.69 │       stac
>    0.08 │       lea    0x28(%rsp),%r12
>    0.09 │       mov    %r14d,(%r15)
>    0.06 │       mov    %rax,0x4(%r15)
>    6.42 │       clac
> ---8<---
>
> One possibility that Eric mentioned 2 weeks ago is that cmov
> might be expensive on the Zen 2 platform.
Hmm. I have a Zen 2 myself, and I haven't seen that being particularly
problematic, but admittedly I did most of my profiling with the
original address masking (back when it just used a plain 'or'
instruction to set all bits in the address).
Without the user address masking, you should be seeing a 'lfence'
(from the user_write_access_begin) instead, which has typically been
*much* more expensive.
I wonder if it's some random instruction scheduling thing.
               Linus
Powered by blists - more mailing lists
 
