Re: [PATCH] binder: use lockless list for deferred_work

From: Greg Kroah-Hartman
Date: Mon Jan 22 2018 - 10:44:34 EST


On Mon, Jan 08, 2018 at 02:55:18PM +0100, Vitaly Wool wrote:
> Binder uses hlist for deferred list, which isn't a good match.
> It's slow and requires mutual exclusion mechanism to protect its
> operations. Moreover, having schedule_work() called under a mutex
> may cause significant delays and creates noticeable adverse effect
> on Binder performance.
>
> Deferred list in Binder is actually treated in a very simple way:
> either add an entry to it or delete the first entry from it. llist
> (lockless list) is a good match for such usage pattern, and it is
> of course quite a bit faster and doesn't require locking.
>
> To be able to add an entry to an llist only if it's not already on
> another llist, this patch adds two small helper functions. That is,
> llist_add_exclusive would only add a node if it's not already on a
> list, and llist_del_first_exclusive will delete the first node off
> the list and mark it as not being on any list.
>
> Signed-off-by: Vitaly Vul <vitaly.vul@xxxxxxxx>
> ---
> drivers/android/binder.c | 87 ++++++++++++++++++++++++++++++++++++------------
> 1 file changed, 66 insertions(+), 21 deletions(-)

Martijn and Todd, any objections to this patch?

thanks,

greg k-h