Skip to content

Commit 4ce5443

Browse files
hansendcKernel Patches Daemon
authored andcommitted
binder: Remove mmap_lock fallback
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. 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" <Liam.Howlett@oracle.com> 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
1 parent dcc6501 commit 4ce5443

1 file changed

Lines changed: 5 additions & 12 deletions

File tree

drivers/android/binder_alloc.c

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -259,21 +259,14 @@ static int binder_page_insert(struct binder_alloc *alloc,
259259
struct vm_area_struct *vma;
260260
int ret = -ESRCH;
261261

262-
/* attempt per-vma lock first */
263-
vma = lock_vma_under_rcu(mm, addr);
264-
if (vma) {
265-
if (binder_alloc_is_mapped(alloc))
266-
ret = vm_insert_page(vma, addr, page);
267-
vma_end_read(vma);
262+
vma = vma_start_read_unlocked(mm, addr);
263+
if (!vma)
268264
return ret;
269-
}
270265

271-
/* fall back to mmap_lock */
272-
mmap_read_lock(mm);
273-
vma = vma_lookup(mm, addr);
274-
if (vma && binder_alloc_is_mapped(alloc))
266+
if (binder_alloc_is_mapped(alloc))
275267
ret = vm_insert_page(vma, addr, page);
276-
mmap_read_unlock(mm);
268+
269+
vma_end_read(vma);
277270

278271
return ret;
279272
}

0 commit comments

Comments
 (0)