mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: David Howells <dhowells@redhat.com>
To: torvalds@linux-foundation.org, mingo@kernel.org
Cc: dhowells@redhat.com, milosz@adfin.com,
	linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Is spin_is_locked() safe to use with BUG_ON()/WARN_ON()?
Date: Thu, 23 May 2013 15:50:36 +0100	[thread overview]
Message-ID: <6402.1369320636@warthog.procyon.org.uk> (raw)


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

             reply	other threads:[~2013-05-23 14:50 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-05-23 14:50 David Howells [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=6402.1369320636@warthog.procyon.org.uk \
    --to=dhowells@redhat.com \
    --cc=linux-arch@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=milosz@adfin.com \
    --cc=mingo@kernel.org \
    --cc=torvalds@linux-foundation.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome