Re: [PATCH] spinlock: Get rid of spin_can_lock()
From: Peter Zijlstra
Date: Tue May 24 2016 - 06:21:38 EST
On Mon, May 23, 2016 at 06:54:02AM -0700, Davidlohr Bueso wrote:
> ... it has no users and we already have the the regular spin_is_lock()
> call anyway -- although iirc this was going to be different
> than the simple negation for lock elision implementations. Lets drop it.
>
> Signed-off-by: Davidlohr Bueso <dbueso@xxxxxxx>
> ---
> include/linux/spinlock.h | 11 -----------
> 1 file changed, 11 deletions(-)
>
> diff --git a/include/linux/spinlock.h b/include/linux/spinlock.h
> index 47dd0cebd204..047c6f6c3268 100644
> --- a/include/linux/spinlock.h
> +++ b/include/linux/spinlock.h
> @@ -264,12 +264,6 @@ static inline void do_raw_spin_unlock(raw_spinlock_t *lock) __releases(lock)
> 1 : ({ local_irq_restore(flags); 0; }); \
> })
>
> -/**
> - * raw_spin_can_lock - would raw_spin_trylock() succeed?
> - * @lock: the spinlock in question.
> - */
> -#define raw_spin_can_lock(lock) (!raw_spin_is_locked(lock))
Its also complete crack; there's absolutely no guarantee the trylock
would still succeed the instruction after we do this.
The only way to test if the trylock would work is actually doing it.
So yeah, queued and killed.