mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-03-21 23:16:50 +08:00
rust_binder: use lock_vma_under_rcu() in use_page_slow()
There's no reason to lock the whole mm when we are doing operations on the vma if we can help it, so to reduce contention, use the lock_vma_under_rcu() abstraction. Signed-off-by: Alice Ryhl <aliceryhl@google.com> Reviewed-by: Jann Horn <jannh@google.com> Reviewed-by: Liam R. Howlett <Liam.Howlett@oracle.com> Link: https://patch.msgid.link/20260218-binder-vma-rcu-v1-1-8bd45b2b1183@google.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
2e303f0feb
commit
a0b9b0f143
@@ -435,24 +435,25 @@ impl ShrinkablePageRange {
|
||||
//
|
||||
// Using `mmput_async` avoids this, because then the `mm` cleanup is instead queued to a
|
||||
// workqueue.
|
||||
check_vma(
|
||||
MmWithUser::into_mmput_async(self.mm.mmget_not_zero().ok_or(ESRCH)?)
|
||||
.mmap_read_lock()
|
||||
.vma_lookup(vma_addr)
|
||||
.ok_or(ESRCH)?,
|
||||
self,
|
||||
)
|
||||
.ok_or(ESRCH)?
|
||||
.vm_insert_page(user_page_addr, &new_page)
|
||||
.inspect_err(|err| {
|
||||
pr_warn!(
|
||||
"Failed to vm_insert_page({}): vma_addr:{} i:{} err:{:?}",
|
||||
user_page_addr,
|
||||
vma_addr,
|
||||
i,
|
||||
err
|
||||
)
|
||||
})?;
|
||||
let mm = MmWithUser::into_mmput_async(self.mm.mmget_not_zero().ok_or(ESRCH)?);
|
||||
{
|
||||
let vma_read;
|
||||
let mmap_read;
|
||||
let vma = if let Some(ret) = mm.lock_vma_under_rcu(vma_addr) {
|
||||
vma_read = ret;
|
||||
check_vma(&vma_read, self)
|
||||
} else {
|
||||
mmap_read = mm.mmap_read_lock();
|
||||
mmap_read
|
||||
.vma_lookup(vma_addr)
|
||||
.and_then(|vma| check_vma(vma, self))
|
||||
};
|
||||
|
||||
match vma {
|
||||
Some(vma) => vma.vm_insert_page(user_page_addr, &new_page)?,
|
||||
None => return Err(ESRCH),
|
||||
}
|
||||
}
|
||||
|
||||
let inner = self.lock.lock();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user