From: David Laight <david.laight.linux@gmail•com>
To: Linus Torvalds <torvalds@linux-foundation•org>
Cc: Kuniyuki Iwashima <kuniyu@google•com>,
Catalin Marinas <catalin.marinas@arm•com>,
Will Deacon <will@kernel•org>,
Madhavan Srinivasan <maddy@linux•ibm.com>,
Michael Ellerman <mpe@ellerman•id.au>,
Paul Walmsley <pjw@kernel•org>,
Palmer Dabbelt <palmer@dabbelt•com>,
Albert Ou <aou@eecs•berkeley.edu>,
Thomas Gleixner <tglx@linutronix•de>,
Ingo Molnar <mingo@redhat•com>, Borislav Petkov <bp@alien8•de>,
Dave Hansen <dave.hansen@linux•intel.com>,
Jens Axboe <axboe@kernel•dk>,
Christian Brauner <brauner@kernel•org>,
Nicholas Piggin <npiggin@gmail•com>,
Christophe Leroy <christophe.leroy@csgroup•eu>,
Alexandre Ghiti <alex@ghiti•fr>, "H. Peter Anvin" <hpa@zytor•com>,
Eric Dumazet <edumazet@google•com>,
Kuniyuki Iwashima <kuni1840@gmail•com>,
x86@kernel•org, linux-arm-kernel@lists•infradead.org,
linuxppc-dev@lists•ozlabs.org, linux-riscv@lists•infradead.org,
linux-kernel@vger•kernel.org
Subject: Re: [PATCH v1 1/2] uaccess: Add __user_write_access_begin().
Date: Thu, 23 Oct 2025 09:29:10 +0100 [thread overview]
Message-ID: <20251023092910.2ed9cf15@pumpkin> (raw)
In-Reply-To: <CAHk-=wjXGvUnmN5ZL3nhj_J0cbiVfeHsM9Z54A55rgHRUaVOfA@mail.gmail.com>
On Wed, 22 Oct 2025 19:37:27 -1000
Linus Torvalds <torvalds@linux-foundation•org> wrote:
> On Wed, 22 Oct 2025 at 14:05, Kuniyuki Iwashima <kuniyu@google•com> wrote:
> >
> > unsafe_put_user() can be used to save a stac/clac pair, but
> > masked_user_access_begin() or user_access_begin() introduces
> > an unnecessary address masking or access_ok().
> >
> > Add a low-level helper for such a use case.
>
> I really suspect that you cannot actually measure the cost of the
> extra masking, and would be much happier if you just used a regular
> "user_access_begin()" (perhaps the "user_write_access_begin()"
> variant).
Or wait for scoped_user_write_access() to get committed and then use that.
David
>
> The masking is very cheap - literally just a couple of ALU
> instructions. And unless you can actually measure some real advantage
> of avoiding it, let's not add another helper to this area.
>
> We spent a fair amount of time undoing years of "__get_user()" and
> "__put_user()" cases that didn't actually help, and sometimes only
> made it hard to see where the actual user pointer validation was done.
>
> Linus
>
next prev parent reply other threads:[~2025-10-23 8:29 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-23 0:04 [PATCH v1 0/2] epoll: Save one stac/clac pair in epoll_put_uevent() Kuniyuki Iwashima
2025-10-23 0:04 ` [PATCH v1 1/2] uaccess: Add __user_write_access_begin() Kuniyuki Iwashima
2025-10-23 5:37 ` Linus Torvalds
2025-10-23 8:29 ` David Laight [this message]
2025-10-24 5:31 ` Kuniyuki Iwashima
2025-10-23 0:04 ` [PATCH v1 2/2] epoll: Use __user_write_access_begin() and unsafe_put_user() in epoll_put_uevent() Kuniyuki Iwashima
2025-10-23 19:40 ` Dave Hansen
2025-10-24 5:16 ` Kuniyuki Iwashima
2025-10-24 14:05 ` Dave Hansen
2025-10-24 14:47 ` David Laight
2025-10-28 5:32 ` Kuniyuki Iwashima
2025-10-28 9:54 ` David Laight
2025-10-28 16:42 ` Kuniyuki Iwashima
2025-10-28 16:58 ` Linus Torvalds
2025-10-29 1:42 ` Andrew Cooper
2025-10-28 22:30 ` David Laight
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20251023092910.2ed9cf15@pumpkin \
--to=david.laight.linux@gmail$(echo .)com \
--cc=alex@ghiti$(echo .)fr \
--cc=aou@eecs$(echo .)berkeley.edu \
--cc=axboe@kernel$(echo .)dk \
--cc=bp@alien8$(echo .)de \
--cc=brauner@kernel$(echo .)org \
--cc=catalin.marinas@arm$(echo .)com \
--cc=christophe.leroy@csgroup$(echo .)eu \
--cc=dave.hansen@linux$(echo .)intel.com \
--cc=edumazet@google$(echo .)com \
--cc=hpa@zytor$(echo .)com \
--cc=kuni1840@gmail$(echo .)com \
--cc=kuniyu@google$(echo .)com \
--cc=linux-arm-kernel@lists$(echo .)infradead.org \
--cc=linux-kernel@vger$(echo .)kernel.org \
--cc=linux-riscv@lists$(echo .)infradead.org \
--cc=linuxppc-dev@lists$(echo .)ozlabs.org \
--cc=maddy@linux$(echo .)ibm.com \
--cc=mingo@redhat$(echo .)com \
--cc=mpe@ellerman$(echo .)id.au \
--cc=npiggin@gmail$(echo .)com \
--cc=palmer@dabbelt$(echo .)com \
--cc=pjw@kernel$(echo .)org \
--cc=tglx@linutronix$(echo .)de \
--cc=torvalds@linux-foundation$(echo .)org \
--cc=will@kernel$(echo .)org \
--cc=x86@kernel$(echo .)org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox