From: Peter Zijlstra <peterz@infradead.org>
To: Steven Rostedt <rostedt@goodmis.org>
Cc: LKML <linux-kernel@vger.kernel.org>,
Andrew Morton <akpm@linux-foundation.org>,
Ingo Molnar <mingo@kernel.org>
Subject: Re: [PATCH] bug: Set warn variable before calling WARN()
Date: Tue, 1 Mar 2016 17:35:31 +0100 [thread overview]
Message-ID: <20160301163531.GW6356@twins.programming.kicks-ass.net> (raw)
In-Reply-To: <20160301110939.1b786f49@gandalf.local.home>
On Tue, Mar 01, 2016 at 11:09:39AM -0500, Steven Rostedt wrote:
> This has hit me a couple of times already. I would be debugging code
> and the system would simply hang and then reboot. Finally, I found that
> the problem was caused by WARN_ON_ONCE() and friends.
>
> The macro WARN_ON_ONCE(condition) is defined as:
>
> static bool __section(.data.unlikely) __warned;
> int __ret_warn_once = !!(condition);
>
> if (unlikely(__ret_warn_once))
> if (WARN_ON(!__warned))
> __warned = true;
>
> unlikely(__ret_warn_once);
>
> Which looks great and all. But what I have hit, is an issue when
> WARN_ON() itself hits the same WARN_ON_ONCE() code. Because, the
> variable __warned is not yet set. Then it too calls WARN_ON() and that
> triggers the warning again. It keeps doing this until the stack is
> overflowed and the system crashes.
>
> By setting __warned first before calling WARN_ON() makes the original
> WARN_ON_ONCE() really only warn once, and not an infinite amount of
> times if the WARN_ON() also triggers the warning.
>
> Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org>
next prev parent reply other threads:[~2016-03-01 16:35 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-03-01 16:09 Steven Rostedt
2016-03-01 16:35 ` Peter Zijlstra [this message]
2016-03-01 16:36 ` 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=20160301163531.GW6356@twins.programming.kicks-ass.net \
--to=peterz@infradead.org \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=rostedt@goodmis.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®