[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20231107090849.262070-1-aliceryhl@google.com>
Date: Tue, 7 Nov 2023 09:08:49 +0000
From: Alice Ryhl <aliceryhl@...gle.com>
To: Carlos Llamas <cmllamas@...gle.com>
Cc: "Arve Hjønnevåg" <arve@...roid.com>,
Christian Brauner <brauner@...nel.org>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
Joel Fernandes <joel@...lfernandes.org>,
kernel-team@...roid.com, linux-kernel@...r.kernel.org,
Martijn Coenen <maco@...roid.com>,
Suren Baghdasaryan <surenb@...gle.com>,
Todd Kjos <tkjos@...roid.com>
Subject: Re: [PATCH 21/21] binder: switch alloc->mutex to spinlock_t
Carlos Llamas <cmllamas@...gle.com> writes:
> The alloc->mutex is a highly contended lock that causes performance
> issues on Android devices. When a low-priority task is given this lock
> and it sleeps, it becomes difficult for the task to wakeup and complete
> its work. This delays other tasks that are also waiting on the mutex.
Grammar nit: "to wake up"
> The problem gets worse when there is memory pressure in the system,
> because this increases the contention on the alloc->mutex while the
> shrinker reclaims binder pages.
>
> Switching to a spinlock helps to keep the waiters running and avoids the
> overhead of waking up tasks. This significantly improves the transaction
> latency when the problematic scenario occurs.
>
> [snip]
>
> Note that it is only possible to convert this lock after a series of
> changes made by previous patches. These mainly include refactoring the
> sections that might_sleep() and changing the locking order with the
> mmap_lock amongst others.
>
> Signed-off-by: Carlos Llamas <cmllamas@...gle.com>
Nice!
Reviewed-by: Alice Ryhl <aliceryhl@...gle.com>
> * binder_free_buf_locked(). However, that could
> - * increase contention for the alloc mutex if clear_on_free
> - * is used frequently for large buffers. The mutex is not
> + * increase contention for the alloc->lock if clear_on_free
> + * is used frequently for large buffers. This lock is not
Grammar nit: Shouldn't this say "However, that could increase contention
on alloc->lock if clear_on_free is used frequently for large buffers."?
Alice
Powered by blists - more mailing lists