Is spin_is_locked() safe to use with BUG_ON()/WARN_ON()?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



We are using spin_is_locked() in a few places to give a warning or an oops if
either a spinlock is not held or if it is held.  I'm not sure all of these are
safe.

Take uas_try_complete() in drivers/usb/storage/uas.c which does:

	WARN_ON(!spin_is_locked(&devinfo->lock));

or fscache_start_operations() which does:

	ASSERT(spin_is_locked(&object->lock));

These will unconditionally fail under sometimes because under certain
conditions spin_is_locked() is hardwired to 0 (ie. not locked) when actually
we're in a place where the spinlock _should_ be locked, and we should get a
non-zero return.


Would it be reasonable to add a spin_is_not_locked() function for use when we
expect it not to be locked and then use spin_is_locked() only when we expect it
to be locked?

Thanks to Milosz Tanski for spotting this one.

David
--
To unsubscribe from this list: send the line "unsubscribe linux-arch" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Kernel]     [Kernel Newbies]     [x86 Platform Driver]     [Netdev]     [Linux Wireless]     [Netfilter]     [Bugtraq]     [Linux Filesystems]     [Yosemite Discussion]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Device Mapper]

  Powered by Linux