From: Rik van Riel <riel@surriel.com>
To: "David Hildenbrand (Arm)" <david@kernel.org>,
linux-kernel@vger.kernel.org
Cc: x86@kernel.org, linux-mm@kvack.org,
Thomas Gleixner <tglx@kernel.org>,
Ingo Molnar <mingo@redhat.com>, Dmitry Ilvokhin <d@ilvokhin.com>,
Borislav Petkov <bp@alien8.de>,
Dave Hansen <dave.hansen@linux.intel.com>,
Andrew Morton <akpm@linux-foundation.org>,
Lorenzo Stoakes <ljs@kernel.org>,
"Liam R. Howlett" <liam@infradead.org>,
Vlastimil Babka <vbabka@kernel.org>,
Suren Baghdasaryan <surenb@google.com>,
kernel-team@meta.com
Subject: Re: [PATCH v2 0/3] mm: __access_remote_vm with per-VMA lock
Date: Fri, 26 Jun 2026 18:55:35 -0400 [thread overview]
Message-ID: <ec196457675cf2feb65cc729090f958080cca052.camel@surriel.com> (raw)
In-Reply-To: <05538f68-c3ec-422d-babb-7427068f79f4@kernel.org>
On Fri, 2026-06-26 at 22:33 +0200, David Hildenbrand (Arm) wrote:
>
> We really need someone to look into this with some GUP experience or
> the
> willingness to properly think the GUP lookup+fault path through,
> instead of
> adding some creative workarounds to selective GUP user.
>
> I will try to find some time to think it through, but my time would
> be better
> spent guiding someone (and definitely not someones LLM) to understand
>
> (1) which interface we could start with (as I said, a GUP interface
> where we
> pass a VMA-lcoked / mm-read-lcoked VMA instead of the MM)
__access_remote_vm seems like a decent place to start,
since that is a pain point for several people, and also
the path into remote get_user_pages with the most callers.
After that there are a few more callers in performance
sensitive paths:
- execve / argv setup -> new mm, no lock contention?
- KVM async pagefault path -> most/all of these to the same VMA?
- make_device_exclusive -> ???
- pin_user_pages_remote -> probably a good target?
>
> (2) which faults we could automatically resolve under VMA lock (I
> mentioned
> userfaultfd is tricky but the existing GUP call already doesn't
> trigger uffd)
It looks like for normal pages, any access that
does not require expanding the stack could be
done using just the per-VMA locks.
That might allow us to implement a locking
function for __access_remote_vm() that
takes the appropriate lock for the situation,
and also takes care of the expand_stack()
calls, if needed.
We could also take the slow path for an
access that spans multiple VMAs.
Then we could have an inner loop that does
only the page accessing and copying, with
no calls to expand_stack() in the while (len)
loop.
At the end of __access_remote_vm() we can
then unlock according to the way we locked.
Adjusting the locking assertions in __get_user_pages_locked
and untagged_addr_remote to allow the per-VMA lock seem
fairly straightforward.
Passing the starting vma all the way into __get_user_pages
would also allow us to skip looking up the VMA a second
time after the first lookup in __access_remote_vm().
>
> (3) whether gup-fast could be reused to some degree, or what it would
> take in
> order to do that.
If an access is entirely inside a single VMA,
it looks like using gup-fast could be possible?
The whole "look up VMA permissions" thing inside
get_user_pages() should not be necessary for callers
like __access_remote_vm() that have already done
that.
That could be a nice speedup for thing like
ptrace, BPF copy_from_user_task, etc
Another question is whether switching right
to gup-fast would be cleaner than trying to
elide the first VMA lookup from __get_user_pages,
but answering that may require looking at some
prototype code and figuring out more of the
details.
Thank you for asking the questions above.
Looking into those made things a little
clearer.
This looks a whole lot more manageable now.
Are there any major things I overlooked?
Are there any pending patches in -mm or
elsewhere that I should pull into my tree
before starting?
--
All Rights Reversed.
next prev parent reply other threads:[~2026-06-26 22:55 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-25 1:50 Rik van Riel
2026-06-25 1:50 ` [PATCH 1/3] x86/mm: use READ_ONCE/WRITE_ONCE for mm->context.untag_mask Rik van Riel
2026-06-25 1:50 ` [PATCH 2/3] mm/pagewalk: let folio_walk_start() run under the per-VMA lock Rik van Riel
2026-06-25 7:34 ` Lorenzo Stoakes
2026-06-25 11:20 ` Rik van Riel
2026-07-07 12:24 ` Lorenzo Stoakes
2026-07-07 13:52 ` Rik van Riel
2026-06-25 1:50 ` [PATCH 3/3] mm: read remote memory without the mmap lock where possible Rik van Riel
2026-06-25 7:39 ` Lorenzo Stoakes
2026-06-25 6:32 ` [PATCH v2 0/3] mm: __access_remote_vm with per-VMA lock David Hildenbrand (Arm)
2026-06-25 7:47 ` Lorenzo Stoakes
2026-06-25 11:22 ` Rik van Riel
2026-06-26 20:33 ` David Hildenbrand (Arm)
2026-06-26 22:55 ` Rik van Riel [this message]
2026-06-27 7:09 ` Lorenzo Stoakes
2026-06-27 8:59 ` Lorenzo Stoakes
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=ec196457675cf2feb65cc729090f958080cca052.camel@surriel.com \
--to=riel@surriel.com \
--cc=akpm@linux-foundation.org \
--cc=bp@alien8.de \
--cc=d@ilvokhin.com \
--cc=dave.hansen@linux.intel.com \
--cc=david@kernel.org \
--cc=kernel-team@meta.com \
--cc=liam@infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=ljs@kernel.org \
--cc=mingo@redhat.com \
--cc=surenb@google.com \
--cc=tglx@kernel.org \
--cc=vbabka@kernel.org \
--cc=x86@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
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
all inboxes | Powered by JetHome®