From: Matthew Wilcox <willy@infradead.org>
To: Suren Baghdasaryan <surenb@google.com>
Cc: akpm@linux-foundation.org, dave.hansen@linux.intel.com,
Liam.Howlett@oracle.com, ljs@kernel.org, david@kernel.org,
shakeel.butt@linux.dev, vbabka@kernel.org, jannh@google.com,
aliceryhl@google.com, arve@android.com, cmllamas@google.com,
christian@brauner.io, tkjos@android.com, dsahern@kernel.org,
davem@davemloft.net, gregkh@linuxfoundation.org,
linux-kernel@vger.kernel.org, linux-mm@kvack.org,
netdev@vger.kernel.org
Subject: Re: [PATCH v4 1/5] mm: Make per-VMA locks available universally
Date: Sat, 8 Aug 2026 02:12:50 +0100 [thread overview]
Message-ID: <anaCkrk55EQoE2aS@casper.infradead.org> (raw)
In-Reply-To: <20260806200548.3124802-2-surenb@google.com>
On Thu, Aug 06, 2026 at 01:05:44PM -0700, Suren Baghdasaryan wrote:
> +++ b/kernel/bpf/stackmap.c
> @@ -272,13 +272,8 @@ struct stack_map_vma_lock {
> /*
> * Acquire a stable read-side reference on the VMA covering @ip.
> *
> - * With CONFIG_PER_VMA_LOCK=y this returns a VMA with its per-VMA read
> - * lock held and mmap_lock dropped, so the caller may sleep.
> - *
> - * With CONFIG_PER_VMA_LOCK=n it returns a VMA with mmap_lock still
> - * held; the caller must snapshot any fields it needs and pin vm_file
> - * with get_file() before stack_map_unlock_vma() drops mmap_lock, as
> - * the VMA may be split, merged, or freed after that.
> + * This returns a VMA with its per-VMA read lock held and mmap_lock
> + * dropped, so the caller may sleep.
I don't know if BPF is compatible with !MMU or not, but the comment
is inconsistent with the code. How about:
* On NOMMU configurations, returns with the mmap_lock held. If the MMU
* is enabled, the per-VMA lock will be held instead. The lock
* should be released with stack_map_unlock_vma() which will release the
* appropriate lock. Once the lock is released, the VMA may be freed.
> * Returns NULL on failure, in which case no lock is held.
> */
> @@ -288,7 +283,6 @@ stack_map_lock_vma(struct stack_map_vma_lock *lock, unsigned long ip)
> struct mm_struct *mm = lock->mm;
> struct vm_area_struct *vma;
>
> - /* noop under !CONFIG_PER_VMA_LOCK */
> vma = lock_vma_under_rcu(mm, ip);
> if (vma) {
> lock->vma = vma;
> @@ -308,21 +302,20 @@ stack_map_lock_vma(struct stack_map_vma_lock *lock, unsigned long ip)
> return NULL;
> }
>
> -#ifdef CONFIG_PER_VMA_LOCK
> +#ifdef CONFIG_MMU
> if (!vma_start_read_locked(vma)) {
> mmap_read_unlock(mm);
> return NULL;
> }
> mmap_read_unlock(mm);
> #endif
> -
> lock->vma = vma;
> return vma;
> }
next prev parent reply other threads:[~2026-08-08 1:41 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-06 20:05 [PATCH v4 0/5] mm: Unconditional per-VMA locks and cleanups Suren Baghdasaryan
2026-08-06 20:05 ` [PATCH v4 1/5] mm: Make per-VMA locks available universally Suren Baghdasaryan
2026-08-07 15:37 ` Vlastimil Babka (SUSE)
2026-08-08 1:12 ` Matthew Wilcox [this message]
2026-08-08 6:08 ` Suren Baghdasaryan
2026-08-06 20:05 ` [PATCH v4 2/5] binder: Make shrinker rely solely on per-VMA lock Suren Baghdasaryan
2026-08-07 14:26 ` Alice Ryhl
2026-08-06 20:05 ` [PATCH v4 3/5] mm: Add RCU-based VMA lookup helper that waits for writers Suren Baghdasaryan
2026-08-07 15:39 ` Vlastimil Babka (SUSE)
2026-08-06 20:05 ` [PATCH v4 4/5] binder: Remove mmap_lock fallback Suren Baghdasaryan
2026-08-06 20:05 ` [PATCH v4 5/5] tcp: Remove mmap_lock fallback path Suren Baghdasaryan
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=anaCkrk55EQoE2aS@casper.infradead.org \
--to=willy@infradead.org \
--cc=Liam.Howlett@oracle.com \
--cc=akpm@linux-foundation.org \
--cc=aliceryhl@google.com \
--cc=arve@android.com \
--cc=christian@brauner.io \
--cc=cmllamas@google.com \
--cc=dave.hansen@linux.intel.com \
--cc=davem@davemloft.net \
--cc=david@kernel.org \
--cc=dsahern@kernel.org \
--cc=gregkh@linuxfoundation.org \
--cc=jannh@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=ljs@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=shakeel.butt@linux.dev \
--cc=surenb@google.com \
--cc=tkjos@android.com \
--cc=vbabka@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