public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Josh Triplett <josh@joshtriplett.org>
To: Bart Van Assche <bvanassche@acm.org>
Cc: Arnd Bergmann <arnd@arndb.de>,
	Andrew Morton <akpm@linux-foundation.org>,
	linux-kernel <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] bug: Fix CONFIG_BUG=n BUG_ON()
Date: Thu, 19 Jun 2014 08:22:28 -0700	[thread overview]
Message-ID: <20140619152228.GA16426@thin> (raw)
In-Reply-To: <53A2E573.6080407@acm.org>

On Thu, Jun 19, 2014 at 03:28:19PM +0200, Bart Van Assche wrote:
> Patch "bug: Make BUG() always stop the machine" changed the
> behavior of BUG() with CONFIG_BUG=n from a no-op into an infinite
> loop. Modify the definition of BUG_ON() accordingly such that the
> behavior of BUG_ON(1) is identical to that of BUG().

No, this patch should not go in.  CONFIG_BUG=n exists for this exact
purpose; if you want BUG_ON to do something then use CONFIG_BUG=y with
BUGVERBOSE disabled instead.

Making BUG() stop the machine even with CONFIG_BUG=n eliminated a number
of compiler warnings about code that should be unreachable, and added
fairly little size to the kernel.  BUG_ON, on the other hand, occurs in
far more places, adds much more size if enabled, and tends to serve as
an assert of a condition; it makes perfect sense to allow compiling out
an assert, and compiling it out does not introduce any compiler
warnings.

What problem are you trying to solve here?  With this change,
CONFIG_BUG=n and CONFIG_BUG=y would become effectively equivalent.

Also:

> --- a/include/asm-generic/bug.h
> +++ b/include/asm-generic/bug.h
> @@ -142,7 +142,7 @@ extern void warn_slowpath_null(const char *file, const int line);
>  #endif
>  
>  #ifndef HAVE_ARCH_BUG_ON
> -#define BUG_ON(condition) do { if (condition) ; } while (0)
> +#define BUG_ON(condition) do { } while (unlikely(condition))

Even if making this change, it should not take this form, which would
evaluate the conditional repeatedly.  See the form used with
CONFIG_BUG=y (without HAVE_ARCH_BUG_ON), defined earlier in the same
file.

- Josh Triplett

  reply	other threads:[~2014-06-19 15:22 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-06-19 13:28 [PATCH] bug: Fix CONFIG_BUG=n BUG_ON() Bart Van Assche
2014-06-19 15:22 ` Josh Triplett [this message]
2014-06-19 17:00 ` Arnd Bergmann
2014-06-19 17:21   ` josh
2014-06-19 17:51     ` Bart Van Assche
2014-06-19 18:12       ` josh

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=20140619152228.GA16426@thin \
    --to=josh@joshtriplett.org \
    --cc=akpm@linux-foundation.org \
    --cc=arnd@arndb.de \
    --cc=bvanassche@acm.org \
    --cc=linux-kernel@vger.kernel.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