Thread (33 messages) 33 messages, 7 authors, 2026-06-16

Re: [PATCH v2 4/5] binder: Remove mmap_lock fallback

From: Suren Baghdasaryan <surenb@google.com>
Date: 2026-06-11 20:40:50
Also in: linux-mm, lkml

On Wed, Jun 10, 2026 at 4:04 PM Dave Hansen [off-list ref] wrote:

From: Dave Hansen <dave.hansen@linux.intel.com>

Previously, the per-VMA locking could fail in the face of writers
which necessitate a fallback to mmap_lock. The new
vma_start_read_unlocked() will wait for writers instead of failing.

Use the new helper. Wait for writers. Remove the fallback to mmap_lock.
Nice!
quoted hunk ↗ jump to hunk
Signed-off-by: Dave Hansen <dave.hansen@linux.intel.com>
Acked-by: Lorenzo Stoakes <ljs@kernel.org>
Reviewed-by: Suren Baghdasaryan <surenb@google.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: "Liam R. Howlett" <redacted>
Cc: Vlastimil Babka <vbabka@kernel.org>
Cc: Shakeel Butt <shakeel.butt@linux.dev>
Cc: linux-mm@kvack.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Arve Hjønnevåg <arve@android.com>
Cc: Todd Kjos <tkjos@android.com>
Cc: Christian Brauner <christian@brauner.io>
Cc: Carlos Llamas <cmllamas@google.com>
Cc: Alice Ryhl <aliceryhl@google.com>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: David Ahern <dsahern@kernel.org>
Cc: netdev@vger.kernel.org

---

 b/drivers/android/binder_alloc.c |   17 +++++------------
 1 file changed, 5 insertions(+), 12 deletions(-)

diff -puN drivers/android/binder_alloc.c~binder-vma-waiter drivers/android/binder_alloc.c
--- a/drivers/android/binder_alloc.c~binder-vma-waiter  2026-06-10 15:57:56.419452721 -0700
+++ b/drivers/android/binder_alloc.c    2026-06-10 15:57:56.423452863 -0700
@@ -259,21 +259,14 @@ static int binder_page_insert(struct bin
        struct vm_area_struct *vma;
        int ret = -ESRCH;

-       /* attempt per-vma lock first */
-       vma = lock_vma_under_rcu(mm, addr);
-       if (vma) {
-               if (binder_alloc_is_mapped(alloc))
-                       ret = vm_insert_page(vma, addr, page);
-               vma_end_read(vma);
+       vma = vma_start_read_unlocked(mm, addr);
+       if (!vma)
                return ret;
-       }

-       /* fall back to mmap_lock */
-       mmap_read_lock(mm);
-       vma = vma_lookup(mm, addr);
-       if (vma && binder_alloc_is_mapped(alloc))
+       if (binder_alloc_is_mapped(alloc))
                ret = vm_insert_page(vma, addr, page);
-       mmap_read_unlock(mm);
+
+       vma_end_read(vma);

        return ret;
 }
_
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help