public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Tim Chen <tim.c.chen@linux.intel.com>
To: herbert@gondor.apana.org.au
Cc: akpm@osdl.org, linux-kernel@vger.kernel.org, leonid.i.ananiev@intel.com
Subject: Re: [PATCH] Fix WARN_ON / WARN_ON_ONCE regression
Date: Tue, 03 Oct 2006 16:19:41 -0700	[thread overview]
Message-ID: <1159917581.8035.45.camel@localhost.localdomain> (raw)
In-Reply-To: <1159916644.8035.35.camel@localhost.localdomain>

Sorry my mailer screwed up the line-wrap.  Here's a resent of the patch.

Tim

The patch "Let WARN_ON/WARN_ON_ONCE return the condition"
http://kernel.org/git/?
p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=684f978347deb42d180373ac4c427f82ef963171

introduced 40% more 2nd level cache miss to tbench workload
being run in a loop back mode on a Core 2 machine.  I think the
introduction of the local variables to WARN_ON and WARN_ON_ONCE

typeof(x) __ret_warn_on = (x);
typeof(condition) __ret_warn_once = (condition);

results in the extra cache misses.  In our test workload profile, we see
heavily used functions like do_softirq and local_bh_enable 
takes a lot longer to execute.  

The modification below helps fix the problem.  I made a slight
modification to sched.c to get around a gcc bug.

Signed-off-by: Tim Chen <tim.c.chen@intel.com>
diff --git a/include/asm-generic/bug.h b/include/asm-generic/bug.h
index a525089..05ed388 100644
--- a/include/asm-generic/bug.h
+++ b/include/asm-generic/bug.h
@@ -17,13 +17,12 @@ #endif
 
 #ifndef HAVE_ARCH_WARN_ON
 #define WARN_ON(condition) ({						\
-	typeof(condition) __ret_warn_on = (condition);			\
-	if (unlikely(__ret_warn_on)) {					\
+	if (unlikely(condition)) {					\
 		printk("BUG: warning at %s:%d/%s()\n", __FILE__,	\
 			__LINE__, __FUNCTION__);			\
 		dump_stack();						\
 	}								\
-	unlikely(__ret_warn_on);					\
+	unlikely(condition);						\
 })
 #endif
 
@@ -43,12 +42,16 @@ #endif
 
 #define WARN_ON_ONCE(condition)	({			\
 	static int __warn_once = 1;			\
-	typeof(condition) __ret_warn_once = (condition);\
 							\
-	if (likely(__warn_once))			\
-		if (WARN_ON(__ret_warn_once)) 		\
-			__warn_once = 0;		\
-	unlikely(__ret_warn_once);			\
+	if (unlikely(condition)){ 			\
+		if (likely(__warn_once)){		\
+			__warn_once=0;			\
+			printk("BUG: warning at %s:%d/%s()\n", __FILE__, \
+				__LINE__, __FUNCTION__);\
+			dump_stack(); 			\
+		}					\
+	}						\
+	unlikely(condition);				\
 })
 
 #ifdef CONFIG_SMP
diff --git a/kernel/sched.c b/kernel/sched.c
index 5c848fd..8ae972c 100644
--- a/kernel/sched.c
+++ b/kernel/sched.c
@@ -5629,7 +5629,8 @@ static unsigned long domain_distance(int
 	struct sched_domain *sd;
 
 	for_each_domain(cpu1, sd) {
-		WARN_ON(!cpu_isset(cpu1, sd->span));
+		if (unlikely(!cpu_isset(cpu1, sd->span)))
+			WARN_ON(1);
 		if (cpu_isset(cpu2, sd->span))
 			return distance;
 		distance++;

  reply	other threads:[~2006-10-04  0:08 UTC|newest]

Thread overview: 44+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-10-03 23:04 [PATCH] Fix WARN_ON / WARN_ON_ONCE regression Tim Chen
2006-10-03 23:19 ` Tim Chen [this message]
2006-10-04  0:06 ` Jeremy Fitzhardinge
2006-10-03 23:47   ` Tim Chen
2006-10-04  4:39     ` Jeremy Fitzhardinge
2006-10-04 13:21       ` Tim Chen
2006-10-04 16:30         ` Andrew Morton
2006-10-04 16:22           ` Tim Chen
2006-10-04 17:34             ` Andrew Morton
2006-10-04 20:43               ` Tim Chen
2006-10-10  1:09               ` Tim Chen
2006-10-10 13:04                 ` Steven Rostedt
2006-10-10 15:41                   ` Tim Chen
2006-10-10 20:03                   ` Jeremy Fitzhardinge
2006-10-04  0:07 ` Andrew Morton
2006-10-03 23:42   ` Tim Chen
2006-10-04  0:09   ` Tim Chen
2006-10-04  1:14     ` Andrew Morton
2006-10-04  1:47       ` Nick Piggin
2006-10-04  3:24       ` Andrew James Wade
2006-10-04  3:32         ` Andrew Morton
2006-10-04 16:47           ` Andrew James Wade
2006-10-04 22:06             ` Andrew Morton
2006-10-05  8:13               ` Andrew James Wade
2006-10-05  8:36                 ` Andrew Morton
2006-10-05 21:31                   ` Andrew James Wade
2006-10-05 21:01                     ` Tim Chen
  -- strict thread matches above, loose matches on Subject: below --
2006-10-04 16:57 Ananiev, Leonid I
2006-10-04 17:28 ` Andrew Morton
2006-10-08  0:28   ` Steven Rostedt
2006-10-08  0:39     ` Jeremy Fitzhardinge
2006-10-04 21:55 Ananiev, Leonid I
2006-10-05 21:37 ` Andrew Morton
2006-10-05 21:43   ` Jeremy Fitzhardinge
2006-10-05 21:52     ` Andrew Morton
2006-10-05 22:02       ` Herbert Xu
2006-10-05 22:40         ` Jeremy Fitzhardinge
2006-10-05 21:51   ` Tim Chen
2006-10-06 16:11   ` Andrew James Wade
2006-10-06  4:06 Ananiev, Leonid I
2006-10-10 21:05 Ananiev, Leonid I
2006-10-10 21:17 ` Steven Rostedt
2006-10-10 21:41   ` Roland Dreier
2006-10-10 22:59   ` Jeremy Fitzhardinge

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=1159917581.8035.45.camel@localhost.localdomain \
    --to=tim.c.chen@linux.intel.com \
    --cc=akpm@osdl.org \
    --cc=herbert@gondor.apana.org.au \
    --cc=leonid.i.ananiev@intel.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