Re: [PATCH 1/2 v2] WARN_ON_SMP(): Allow use in if statements on UP

From: Steven Rostedt
Date: Fri Mar 18 2011 - 08:14:48 EST

On Fri, 2011-03-18 at 10:12 +0100, Peter Zijlstra wrote:
> On Thu, 2011-03-17 at 17:56 -0400, Steven Rostedt wrote:
> > + * WARN_ON(!spin_is_locked(&lock)) checks, as spin_is_locked()
> > + * returns 0 for uniprocessor settings.
> Arguably most spin_is_locked() usages should be removed in favour of
> something like lockdep_assert_held().
> The latter only emits code then built with lockdep enabled and it checks
> we are indeed the owner, not some random other cpu.

Perhaps we should have lockdep_assert_held() also be in
"spin_is_locked()". The warning with spin_is_locked() is still nice to
have because it can trigger on production systems that might find a code
path that it's not locked. lockdep is too heavy to run on production
systems. But if lockdep is enabled, the spin_is_locked() should probably
check ownership too.

-- Steve

To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at
Please read the FAQ at