[<prev] [next>] [day] [month] [year] [list]
Message-ID: <B41635854730A14CA71C92B36EC22AAC3F3F28@mssmsx411>
Date: Wed, 4 Oct 2006 17:19:42 +0400
From: "Ananiev, Leonid I" <leonid.i.ananiev@...el.com>
To: "Andrew Morton" <akpm@...l.org>, <andrew.j.wade@...il.com>
Cc: <tim.c.chen@...ux.intel.com>, <herbert@...dor.apana.org.au>,
<linux-kernel@...r.kernel.org>
Subject: [PATCH] Cache miss eliminating in WARN_ON_ONCE
The static variable __warn_once was "never" read (until there is no bug)
before patch "Let WARN_ON/WARN_ON_ONCE return the condition"
http://kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commi
t;h=684f978347deb42d180373ac4c427f82ef963171
in WARN_ON_ONCE's line
- if (unlikely((condition) && __warn_once)) { \
because 'condition' is false. There was no cache miss as a result.
Cache miss for __warn_once is happened in new lines
+ if (likely(__warn_once)) \
+ if (WARN_ON(__ret_warn_once)) \
Proposed patch is tested by tbench.
>From Leonid Ananiev
Cache miss eliminating in WARN_ON_ONCE by testing expression value
before static variable value.
Signed-off-by: Leonid Ananiev <leonid.i.ananiev@...el.com>
--- linux-2.6.18-git14/include/asm-generic/bug.h
+++ linux-2.6.18-git14b/include/asm-generic/bug.h
@@ -45,9 +45,12 @@
static int __warn_once = 1; \
typeof(condition) __ret_warn_once = (condition);\
\
- if (likely(__warn_once)) \
- if (WARN_ON(__ret_warn_once)) \
+ /* check 'condition' first to avoid cache miss with __warn_once
*/\
+ if (unlikely(__ret_warn_once)) \
+ if (__warn_once) { \
__warn_once = 0; \
+ WARN_ON(1); \
+ } \
unlikely(__ret_warn_once); \
})
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists