From: Ingo Molnar <mingo@elte.hu>
To: Alexey Dobriyan <adobriyan@gmail.com>
Cc: Steven Rostedt <rostedt@goodmis.org>,
Linus Torvalds <torvalds@linux-foundation.org>,
mingo@redhat.com, hpa@zytor.com, linux-kernel@vger.kernel.org,
dvhart@linux.intel.com, peterz@infradead.org,
akpm@linux-foundation.org, srostedt@redhat.com,
tglx@linutronix.de, laijs@cn.fujitsu.com,
linux-tip-commits@vger.kernel.org
Subject: Re: [tip:core/urgent] WARN_ON_SMP(): Allow use in if() statements on UP
Date: Fri, 25 Mar 2011 20:56:43 +0100 [thread overview]
Message-ID: <20110325195643.GB7346@elte.hu> (raw)
In-Reply-To: <20110325194729.GA6192@p183.telecom.by>
* Alexey Dobriyan <adobriyan@gmail.com> wrote:
> On Fri, Mar 25, 2011 at 03:40:34PM -0400, Steven Rostedt wrote:
> > On Fri, 2011-03-25 at 21:31 +0200, Alexey Dobriyan wrote:
> >
> > > > Would you like me to add a comment that states:
> > > >
> > > > /*
> > > > * Use ({0;}) as just "0" will cause gcc to output:
> > > > * warning: statement with no effect
> > > > */
> > >
> > > Try ((void)0)
> >
> > Maybe I should update the comment to stop further confusion:
>
> Ah!
>
> I always thought if (WARN_ON(x)) is confusing and should be banned.
I'd encourage you to read kernel/lockdep.c one day:
return DEBUG_LOCKS_WARN_ON(1);
DEBUG_LOCKS_WARN_ON(1);
if (DEBUG_LOCKS_WARN_ON(class->subclass != subclass))
if (DEBUG_LOCKS_WARN_ON(!irqs_disabled()))
if (DEBUG_LOCKS_WARN_ON(id >= MAX_LOCKDEP_KEYS))
if (DEBUG_LOCKS_WARN_ON(unlikely(early_boot_irqs_disabled)))
if (DEBUG_LOCKS_WARN_ON(!irqs_disabled()))
if (DEBUG_LOCKS_WARN_ON(current->hardirq_context))
if (DEBUG_LOCKS_WARN_ON(!irqs_disabled()))
if (DEBUG_LOCKS_WARN_ON(!irqs_disabled()))
if (DEBUG_LOCKS_WARN_ON(!irqs_disabled()))
DEBUG_LOCKS_WARN_ON(!softirq_count());
if (DEBUG_LOCKS_WARN_ON(irqs_disabled_flags(flags)))
if (DEBUG_LOCKS_WARN_ON(!name)) {
if (DEBUG_LOCKS_WARN_ON(!key))
DEBUG_LOCKS_WARN_ON(1);
if (DEBUG_LOCKS_WARN_ON(!irqs_disabled()))
if (DEBUG_LOCKS_WARN_ON(depth >= MAX_LOCK_DEPTH))
if (DEBUG_LOCKS_WARN_ON(!class))
if (DEBUG_LOCKS_WARN_ON(id >= MAX_LOCKDEP_KEYS))
if (DEBUG_LOCKS_WARN_ON(chain_key != 0))
if (DEBUG_LOCKS_WARN_ON(!irqs_disabled()))
if (DEBUG_LOCKS_WARN_ON(!class))
if (DEBUG_LOCKS_WARN_ON(!hlock->nest_lock))
if (DEBUG_LOCKS_WARN_ON(!depth))
if (DEBUG_LOCKS_WARN_ON(curr->lockdep_depth != depth))
if (DEBUG_LOCKS_WARN_ON(!depth))
if (DEBUG_LOCKS_WARN_ON(curr->lockdep_depth != depth - 1))
if (DEBUG_LOCKS_WARN_ON(!depth && (hlock->prev_chain_key != 0)))
if (DEBUG_LOCKS_WARN_ON(current->hardirqs_enabled)) {
if (DEBUG_LOCKS_WARN_ON(!current->hardirqs_enabled)) {
DEBUG_LOCKS_WARN_ON(current->softirqs_enabled);
DEBUG_LOCKS_WARN_ON(!current->softirqs_enabled);
if (DEBUG_LOCKS_WARN_ON(!depth))
if (DEBUG_LOCKS_WARN_ON(!depth))
These conditional warnings made the flow a lot clearer and simpler - while
still giving us a very robust lockdep machinery that wont crash no matter what
kind of anomaly happens.
But yes, i can imagine such constructs being misused as well when mixed into
real, non-debug functionality. As usual, it's just a tool, with good and evil
uses as well - so your 'it should be banned' position is too extreme IMHO.
Thanks,
Ingo
next prev parent reply other threads:[~2011-03-25 19:57 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-03-17 19:21 [PATCH 0/2] [GIT PULL] futex: Fix WARN_ON triggering " Steven Rostedt
2011-03-17 19:21 ` [PATCH 1/2] WARN_ON_SMP(): Allow use in if statements " Steven Rostedt
2011-03-17 20:46 ` Darren Hart
2011-03-25 9:35 ` Peter Zijlstra
2011-03-25 10:48 ` [tip:core/urgent] WARN_ON_SMP(): Allow use in if() " tip-bot for Steven Rostedt
2011-03-25 16:45 ` Linus Torvalds
2011-03-25 18:16 ` Steven Rostedt
2011-03-25 18:19 ` Steven Rostedt
2011-03-25 19:31 ` Alexey Dobriyan
2011-03-25 19:36 ` Steven Rostedt
2011-03-25 19:40 ` Steven Rostedt
2011-03-25 19:47 ` Alexey Dobriyan
2011-03-25 19:53 ` Steven Rostedt
2011-03-25 19:56 ` Ingo Molnar [this message]
2011-03-17 19:21 ` [PATCH 2/2] futex: Fix WARN_ON() test for UP Steven Rostedt
2011-03-17 20:00 ` Darren Hart
2011-03-25 9:35 ` Peter Zijlstra
2011-03-25 10:49 ` [tip:core/urgent] " tip-bot for Steven Rostedt
2011-03-17 19:27 ` [PATCH 0/2] [GIT PULL] futex: Fix WARN_ON triggering on UP Steven Rostedt
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=20110325195643.GB7346@elte.hu \
--to=mingo@elte.hu \
--cc=adobriyan@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=dvhart@linux.intel.com \
--cc=hpa@zytor.com \
--cc=laijs@cn.fujitsu.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-tip-commits@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=peterz@infradead.org \
--cc=rostedt@goodmis.org \
--cc=srostedt@redhat.com \
--cc=tglx@linutronix.de \
--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
all inboxes | Powered by JetHome®