Re: [PATCH RFC v3 1/6] x86/mm: add untagged_addr_remote_unlocked()
From: Usama Arif
Date: Mon Jul 20 2026 - 07:21:35 EST
On Fri, 17 Jul 2026 13:00:31 -0400 Rik van Riel <riel@xxxxxxxxxxx> wrote:
> __access_remote_vm() reads another process's memory under the mmap lock. On
> large machines that lock is contended by tasks polling /proc/PID/cmdline,
> /proc/PID/environ, or calling process_vm_readv(), even though the memory
> they read is almost always resident and could be reached under the per-VMA
> lock instead.
>
> Looking up the VMA first requires untagging the address.
> untagged_addr_remote() asserts the mmap lock only because it reads
> mm->context.untag_mask, which can race with the write in mm_enable_lam().
>
> That mask is set once, when LAM is enabled, and never changes afterwards,
> so the read itself does not need the lock. It is already read without it,
> from the context switch path and /proc/PID/status.
>
> Add untagged_addr_remote_unlocked() for callers that have not taken the
> mmap lock, and annotate access to mm->context.untag_mask with READ_ONCE()
> and WRITE_ONCE() so the existing lockless reads are explicit and
> KCSAN-clean. untagged_addr_remote() keeps its assertion and shares the same
> code.
>
> Assisted-by: Claude:claude-opus-4.8
> Acked-by: Usama Arif <usamaarif642@xxxxxxxxx>
Hi Rik,
Would you mind changing this to
Acked-by: Usama Arif <usama.arif@xxxxxxxxx>
in the next revision
Thanks!