Re: [PATCH v2 19/28] binder: perform page installation outside of locks

From: Alice Ryhl
Date: Mon Dec 04 2023 - 06:57:34 EST


> Split out the insertion of pages to be outside of the alloc->mutex in a
> separate binder_install_buffer_pages() routine. Since this is no longer
> serialized, we must look at the full range of pages used by the buffers.
> The installation is protected with mmap_sem in write mode since multiple
> tasks might race to install the same page.
>
> Besides avoiding unnecessary nested locking this helps in preparation of
> switching the alloc->mutex into a spinlock_t in subsequent patches.
>
> Signed-off-by: Carlos Llamas <cmllamas@xxxxxxxxxx>

Reviewed-by: Alice Ryhl <aliceryhl@xxxxxxxxxx>

> +static inline struct page *
> +binder_get_installed_page(struct binder_lru_page *lru_page)
> +{
> + /* Pairs with release in binder_set_installed_page() */
> + return smp_load_acquire(&lru_page->page_ptr);
> +}

Technically some of the uses of this method do not actually need to be
atomic (because they never race with `binder_set_installed_page`), but I
don't mind using it anyway.

Alice