Re: [PATCH v2 1/3] locking: Document the semantics of spin_is_locked()
From: Randy Dunlap
Date: Tue Apr 03 2018 - 17:48:16 EST
On 04/03/2018 02:43 PM, David Howells wrote:
> Alan Stern <stern@xxxxxxxxxxxxxxxxxxx> wrote:
>> + * Returns: 1 if @lock is locked, 0 otherwise.
>> + * However, on !CONFIG_SMP builds with !CONFIG_DEBUG_SPINLOCK,
>> + * the return value is always 0 (see include/linux/spinlock_up.h).
>> + * Therefore you should not rely heavily on the return value.
> Seems reasonable.
> It might also want to include a note that the lock isn't necessarily held by
> your own CPU. I would also use "=n" rather than "!", so maybe something like:
> * Returns: 1 if @lock is locked, 0 otherwise.
> * Note that the function only tells you that the CPU is seen to be locked,
the CPU is locked??
> * not that it is locked on your CPU.
> * Further, on CONFIG_SMP=n builds with CONFIG_DEBUG_SPINLOCK=n, the return
> * value is always 0 (see include/linux/spinlock_up.h). Therefore you should
> * not rely heavily on the return value.