LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Matt Mackall <mpm@selenic.com>
To: Andrew Morton <akpm@osdl.org>
Cc: Michael Buesch <mbuesch@freenet.de>,
	akpm@digeo.com, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2.6.6] bootmem.c cleanup
Date: Tue, 18 May 2004 14:50:26 -0500	[thread overview]
Message-ID: <20040518195026.GS5414@waste.org> (raw)
In-Reply-To: <20040514133353.236acf3a.akpm@osdl.org>

On Fri, May 14, 2004 at 01:33:53PM -0700, Andrew Morton wrote:
> Michael Buesch <mbuesch@freenet.de> wrote:
> >
> >  -		if (!test_and_clear_bit(i, bdata->node_bootmem_map))
> >  -			BUG();
> >  +		BUG_ON(!test_and_clear_bit(i, bdata->node_bootmem_map));
> 
> Please don't put expressions whihc actually change state inside BUG_ON(). 
> Someone may decide to make BUG_ON() a no-op to save space.

I've done it and it's fine, we just need to evaluate the condition and
let the compiler optimize it away if it has no side effects.

configurable no-op of BUG and WARN


 tiny-mpm/include/asm-i386/bug.h |    7 +++++++
 tiny-mpm/init/Kconfig           |   11 ++++++++++-
 2 files changed, 17 insertions(+), 1 deletion(-)

Index: tiny/include/asm-i386/bug.h
===================================================================
--- tiny.orig/include/asm-i386/bug.h	2004-04-19 14:42:45.000000000 -0500
+++ tiny/include/asm-i386/bug.h	2004-04-19 14:46:19.000000000 -0500
@@ -9,6 +9,12 @@
  * undefined" opcode for parsing in the trap handler.
  */
 
+#ifndef CONFIG_BUG
+#define BUG()
+#define WARN_ON(condition) do { if (condition) ; } while(0)
+#define BUG_ON(condition) do { if (condition) ; } while(0)
+#define PAGE_BUG(page)
+#else
 #ifdef CONFIG_FULL_BUG
 #define BUG()				\
  __asm__ __volatile__(	"ud2\n"		\
@@ -40,3 +46,4 @@
 } while (0)
 
 #endif
+#endif
Index: tiny/init/Kconfig
===================================================================
--- tiny.orig/init/Kconfig	2004-04-19 14:42:49.000000000 -0500
+++ tiny/init/Kconfig	2004-04-19 14:46:19.000000000 -0500
@@ -274,8 +274,17 @@
           very difficult to diagnose system problems, saying N here on
           non-embedded systems is strongly discouraged.
 
+config BUG
+ 	depends X86
+ 	default y
+	bool "Enable BUG and WARN code" if EMBEDDED
+	help
+	  Disabling this completely removes BUG and WARN checking
+          code. Warning: this may result in data loss if a bug goes
+          undetected.
+
 config FULL_BUG
-	depends X86
+	depends X86 && BUG
 	default y
 	bool "Full BUG reporting code" if EMBEDDED
 	help

> 
> I'm not aware of anyone actually trying that, but it's a good objective.
> -
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/

-- 
Matt Mackall : http://www.selenic.com : Linux development and consulting

      parent reply	other threads:[~2004-05-18 19:52 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-05-14 20:05 Michael Buesch
2004-05-14 20:33 ` Andrew Morton
2004-05-14 20:43   ` Michael Buesch
2004-05-17  0:43   ` H. Peter Anvin
2004-05-18 19:50   ` Matt Mackall [this message]

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=20040518195026.GS5414@waste.org \
    --to=mpm@selenic.com \
    --cc=akpm@digeo.com \
    --cc=akpm@osdl.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mbuesch@freenet.de \
    --subject='Re: [PATCH 2.6.6] bootmem.c cleanup' \
    /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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).