Re: [PATCH v4 07/16] locking/rwsem: Implement lock handoff to prevent lock starvation

From: Peter Zijlstra
Date: Wed Apr 17 2019 - 04:17:48 EST


On Sat, Apr 13, 2019 at 01:22:50PM -0400, Waiman Long wrote:
> +/*
> + * This is safe to be called without holding the wait_lock.

Because.... @waiter is *our* waiter and it's not going anywhere. So when
it's first, it stays first until we do something about it.

> + */
> +static inline bool
> +rwsem_waiter_is_first(struct rw_semaphore *sem, struct rwsem_waiter *waiter)
> +{
> + return list_first_entry(&sem->wait_list, struct rwsem_waiter, list)
> + == waiter;
> +}