public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Jeff Garzik <jgarzik@pobox.com>
To: Dean Nelson <dcn@sgi.com>
Cc: linux-kernel@vger.kernel.org
Subject: Re: [RFC] replace assorted ASSERT()s by something officially  sanctioned
Date: Wed, 23 Jun 2004 15:46:36 -0400	[thread overview]
Message-ID: <40D9DE1C.8020005@pobox.com> (raw)
In-Reply-To: <40D9D09D.mailx49E1J10NF@aqua.americas.sgi.com>

Dean Nelson wrote:
> It doesn't appear that an officially 'sanctioned' version of ASSERT() or
> an ASSERT()-like macro exists.
> 
> And by the proliferation of its use in the linux 2.6 kernel (I saw over
> 3000 references to it), it would seem that BUG_ON() does not satisfy all
> of the requirements of the community.
> 
> One problem with BUG_ON() is that it is always enabled. And even though
> the compiler does a good job of minimizing the impact of the conditional
> expression, there are times when the conditional check requires the
> accessing of a cacheline that would not get accessed had the BUG_ON() not
> been enabled. And if that cacheline were one that is hotly contended for,
> one's performance can be adversely affected.
> 
> For debugging purposes it would be nice to have a version of BUG_ON() that
> was only enabled if DEBUG was set. This is what appears to be behind the use
> of the ASSERT()-like macros.
> 
> As an example of what I have in mind, I've included the following quilt
> patch.
> 
> Thanks,
> Dean
> 
> 
> Index: linux/include/asm-i386/bug.h
> ===================================================================
> --- linux.orig/include/asm-i386/bug.h
> +++ linux/include/asm-i386/bug.h
> @@ -21,6 +21,12 @@
>  
>  #define BUG_ON(condition) do { if (unlikely((condition)!=0)) BUG(); } while(0)
>  
> +#ifdef DEBUG
> +#define DBUG_ON(condition)	BUG_ON(condition)
> +#else
> +#define DBUG_ON(condition)
> +#endif

This won't work as it often needs to be driver-granular.  Also, 
WARN_ON() is often the closer implementation of assert(), than BUG_ON()

	Jeff




  parent reply	other threads:[~2004-06-23 19:47 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-06-23 18:49 [RFC] replace assorted ASSERT()s by something officially sanctioned Dean Nelson
2004-06-23 19:02 ` Michael Buesch
2004-06-23 19:46 ` Jeff Garzik [this message]
2004-06-28 17:27   ` Dean Nelson

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=40D9DE1C.8020005@pobox.com \
    --to=jgarzik@pobox.com \
    --cc=dcn@sgi.com \
    --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