linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Is spin_is_locked() safe to use with BUG_ON()/WARN_ON()?
@ 2013-05-23 14:50 David Howells
  2013-05-23 14:59 ` Linus Torvalds
  2013-05-23 15:12 ` David Howells
  0 siblings, 2 replies; 6+ messages in thread
From: David Howells @ 2013-05-23 14:50 UTC (permalink / raw)
  To: torvalds, mingo; +Cc: dhowells, milosz, linux-arch, linux-kernel


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

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2014-08-11  6:41 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-05-23 14:50 Is spin_is_locked() safe to use with BUG_ON()/WARN_ON()? David Howells
2013-05-23 14:59 ` Linus Torvalds
2014-08-11  6:41   ` sanjeev sharma
2013-05-23 15:12 ` David Howells
2013-05-24  1:29   ` Ryan Mallon
2013-05-28  8:07     ` Ingo Molnar

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).