From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <linux-kernel-owner+w=401wt.eu-S1753622AbYACV2t@vger.kernel.org>
Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand
	id S1753622AbYACV2t (ORCPT <rfc822;w@1wt.eu>);
	Thu, 3 Jan 2008 16:28:49 -0500
Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1752226AbYACV2l
	(ORCPT <rfc822;linux-kernel-outgoing>);
	Thu, 3 Jan 2008 16:28:41 -0500
Received: from mga06.intel.com ([134.134.136.21]:15475 "EHLO
	orsmga101.jf.intel.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org
	with ESMTP id S1752195AbYACV2l (ORCPT
	<rfc822;linux-kernel@vger.kernel.org>);
	Thu, 3 Jan 2008 16:28:41 -0500
X-ExtLoop1: 1
X-IronPort-AV: E=Sophos;i="4.24,240,1196668800"; 
   d="scan'208";a="248526159"
Message-ID: <477D52ED.7000403@linux.intel.com>
Date: Thu, 03 Jan 2008 22:26:05 +0100
From: Arjan van de Ven <arjan@linux.intel.com>
User-Agent: Thunderbird 1.5 (Windows/20051201)
MIME-Version: 1.0
To: linux-kernel@vger.kernel.org
CC: mingo@elte.hu, akpm@linux-foundation.org, olof@lixom.net, mpm@selenic.com
Subject: [patch 1/2] move WARN_ON() out of line
Content-Type: multipart/mixed;
 boundary="------------040405010005000301070402"
Sender: linux-kernel-owner@vger.kernel.org
List-ID: <linux-kernel.vger.kernel.org>
X-Mailing-List: linux-kernel@vger.kernel.org

This is a multi-part message in MIME format.
--------------040405010005000301070402
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

Subject: move WARN_ON() out of line
From: Arjan van de Ven <arjan@linux.intel.com>
CC: Ingo Molnar <mingo@elte.hu>
CC: Andrew Morton <akpm@linux-foundation.org>
CC: Olof Johansson <olof@lixom.net>
CC: Matt Meckall <mpm@selenic.com>

A quick grep shows that there are currently 1145 instances of WARN_ON
in the kernel. Currently, WARN_ON is pretty much entirely inlined,
which makes it hard to enhance it without growing the size of the kernel
(and getting Andrew rightfully unhappy).

This patch build on top of Olof's patch that introduces __WARN,
and places the slowpath out of line. It also uses Ingo's suggestion
to not use __FUNCTION__ but to use kallsyms to do the lookup;
this saves a ton of extra space since gcc doesn't need to store the function
string twice now:

3936367  833603  624736 5394706  525112 vmlinux.before
3917508  833603  624736 5375847  520767 vmlinux-slowpath

15Kb savings...

Signed-off-by: Arjan van de Ven <arjan@linux.intel.com>


---
  include/asm-generic/bug.h |    7 ++-----
  kernel/panic.c            |   14 ++++++++++++++
  2 files changed, 16 insertions(+), 5 deletions(-)

Index: linux-2.6.24-rc6/include/asm-generic/bug.h
===================================================================
--- linux-2.6.24-rc6.orig/include/asm-generic/bug.h
+++ linux-2.6.24-rc6/include/asm-generic/bug.h
@@ -32,11 +32,8 @@ struct bug_entry {
  #endif

  #ifndef __WARN
-#define __WARN() do {							\
-	printk("WARNING: at %s:%d %s()\n", __FILE__,			\
-		__LINE__, __FUNCTION__);				\
-	dump_stack();							\
-} while (0)
+extern void warn_on_slowpath(const char *file, const int line);
+#define __WARN() warn_on_slowpath(__FILE__, __LINE__)
  #endif

  #ifndef WARN_ON
Index: linux-2.6.24-rc6/kernel/panic.c
===================================================================
--- linux-2.6.24-rc6.orig/kernel/panic.c
+++ linux-2.6.24-rc6/kernel/panic.c
@@ -20,6 +20,7 @@
  #include <linux/kexec.h>
  #include <linux/debug_locks.h>
  #include <linux/random.h>
+#include <linux/kallsyms.h>

  int panic_on_oops;
  int tainted;
@@ -292,6 +293,19 @@ void oops_exit(void)
  		(unsigned long long)oops_id);
  }

+
+void warn_on_slowpath(const char *file, int line)
+{
+	char function[KSYM_SYMBOL_LEN];
+	unsigned long caller = (unsigned long) __builtin_return_address(0);
+
+	sprint_symbol(function, caller);
+	printk(KERN_WARNING "WARNING: at %s:%d %s()\n", file,
+		line, function);
+	dump_stack();
+}
+EXPORT_SYMBOL(warn_on_slowpath);
+
  #ifdef CONFIG_CC_STACKPROTECTOR
  /*
   * Called when gcc's -fstack-protector feature is used, and

--------------040405010005000301070402
Content-Type: text/x-patch;
 name="out_of_line_WARN_ON.patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="out_of_line_WARN_ON.patch"

Subject: move WARN_ON() out of line
From: Arjan van de Ven <arjan@linux.intel.com>
CC: Ingo Molnar <mingo@elte.hu>
CC: Andrew Morton <akpm@linux-foundation.org>
CC: Olof Johansson <olof@lixom.net>
CC: Matt Meckall <mpm@selenic.com>

A quick grep shows that there are currently 1145 instances of WARN_ON
in the kernel. Currently, WARN_ON is pretty much entirely inlined,
which makes it hard to enhance it without growing the size of the kernel
(and getting Andrew unhappy).

This patch build on top of Olof's patch that introduces __WARN,
and places the slowpath out of line. It also uses Ingo's suggestion
to not use __FUNCTION__ but to use kallsyms to do the lookup;
this saves a ton of extra space since gcc doesn't need to store the function
string twice now:

3936367  833603  624736 5394706  525112 vmlinux.before
3917508  833603  624736 5375847  520767 vmlinux-slowpath

15Kb savings...

Signed-off-by: Arjan van de Ven <arjan@linux.intel.com>


---
 include/asm-generic/bug.h |    7 ++-----
 kernel/panic.c            |   14 ++++++++++++++
 2 files changed, 16 insertions(+), 5 deletions(-)

Index: linux-2.6.24-rc6/include/asm-generic/bug.h
===================================================================
--- linux-2.6.24-rc6.orig/include/asm-generic/bug.h
+++ linux-2.6.24-rc6/include/asm-generic/bug.h
@@ -32,11 +32,8 @@ struct bug_entry {
 #endif
 
 #ifndef __WARN
-#define __WARN() do {							\
-	printk("WARNING: at %s:%d %s()\n", __FILE__,			\
-		__LINE__, __FUNCTION__);				\
-	dump_stack();							\
-} while (0)
+extern void warn_on_slowpath(const char *file, const int line);
+#define __WARN() warn_on_slowpath(__FILE__, __LINE__)
 #endif
 
 #ifndef WARN_ON
Index: linux-2.6.24-rc6/kernel/panic.c
===================================================================
--- linux-2.6.24-rc6.orig/kernel/panic.c
+++ linux-2.6.24-rc6/kernel/panic.c
@@ -20,6 +20,7 @@
 #include <linux/kexec.h>
 #include <linux/debug_locks.h>
 #include <linux/random.h>
+#include <linux/kallsyms.h>
 
 int panic_on_oops;
 int tainted;
@@ -292,6 +293,19 @@ void oops_exit(void)
 		(unsigned long long)oops_id);
 }
 
+
+void warn_on_slowpath(const char *file, int line)
+{
+	char function[KSYM_SYMBOL_LEN];
+	unsigned long caller = (unsigned long) __builtin_return_address(0);
+
+	sprint_symbol(function, caller);
+	printk(KERN_WARNING "WARNING: at %s:%d %s()\n", file,
+		line, function);
+	dump_stack();
+}
+EXPORT_SYMBOL(warn_on_slowpath);
+
 #ifdef CONFIG_CC_STACKPROTECTOR
 /*
  * Called when gcc's -fstack-protector feature is used, and

--------------040405010005000301070402--

From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <linux-kernel-owner+w=401wt.eu-S1756597AbYACW3c@vger.kernel.org>
Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand
	id S1756597AbYACW3c (ORCPT <rfc822;w@1wt.eu>);
	Thu, 3 Jan 2008 17:29:32 -0500
Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1754753AbYACW3Q
	(ORCPT <rfc822;linux-kernel-outgoing>);
	Thu, 3 Jan 2008 17:29:16 -0500
Received: from waste.org ([66.93.16.53]:42474 "EHLO waste.org"
	rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP
	id S1753967AbYACW3P (ORCPT <rfc822;linux-kernel@vger.kernel.org>);
	Thu, 3 Jan 2008 17:29:15 -0500
Subject: Re: [patch 1/2] move WARN_ON() out of line
From: Matt Mackall <mpm@selenic.com>
To: Arjan van de Ven <arjan@linux.intel.com>
Cc: linux-kernel@vger.kernel.org, mingo@elte.hu, akpm@linux-foundation.org,
       olof@lixom.net
In-Reply-To: <477D52ED.7000403@linux.intel.com>
References: <477D52ED.7000403@linux.intel.com>
Content-Type: text/plain
Date: Thu, 03 Jan 2008 16:27:55 -0600
Message-Id: <1199399275.7815.1.camel@cinder.waste.org>
Mime-Version: 1.0
X-Mailer: Evolution 2.12.2 
Content-Transfer-Encoding: 7bit
Sender: linux-kernel-owner@vger.kernel.org
List-ID: <linux-kernel.vger.kernel.org>
X-Mailing-List: linux-kernel@vger.kernel.org


On Thu, 2008-01-03 at 22:26 +0100, Arjan van de Ven wrote:
> Subject: move WARN_ON() out of line
> From: Arjan van de Ven <arjan@linux.intel.com>
> CC: Ingo Molnar <mingo@elte.hu>
> CC: Andrew Morton <akpm@linux-foundation.org>
> CC: Olof Johansson <olof@lixom.net>
> CC: Matt Meckall <mpm@selenic.com>
> 
> A quick grep shows that there are currently 1145 instances of WARN_ON
> in the kernel. Currently, WARN_ON is pretty much entirely inlined,
> which makes it hard to enhance it without growing the size of the kernel
> (and getting Andrew rightfully unhappy).
> 
> This patch build on top of Olof's patch that introduces __WARN,
> and places the slowpath out of line. It also uses Ingo's suggestion
> to not use __FUNCTION__ but to use kallsyms to do the lookup;
> this saves a ton of extra space since gcc doesn't need to store the function
> string twice now:
>
> 3936367  833603  624736 5394706  525112 vmlinux.before
> 3917508  833603  624736 5375847  520767 vmlinux-slowpath

Nice!

Acked-by: Matt Mackall <mpm@selenic.com>

-- 
Mathematics is the supreme nostalgia of our time.


From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <linux-kernel-owner+w=401wt.eu-S1758186AbYADHmW@vger.kernel.org>
Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand
	id S1758186AbYADHmW (ORCPT <rfc822;w@1wt.eu>);
	Fri, 4 Jan 2008 02:42:22 -0500
Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1753082AbYADHmP
	(ORCPT <rfc822;linux-kernel-outgoing>);
	Fri, 4 Jan 2008 02:42:15 -0500
Received: from mx2.mail.elte.hu ([157.181.151.9]:51808 "EHLO mx2.mail.elte.hu"
	rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP
	id S1752207AbYADHmO (ORCPT <rfc822;linux-kernel@vger.kernel.org>);
	Fri, 4 Jan 2008 02:42:14 -0500
Date: Fri, 4 Jan 2008 08:41:49 +0100
From: Ingo Molnar <mingo@elte.hu>
To: Arjan van de Ven <arjan@linux.intel.com>
Cc: linux-kernel@vger.kernel.org, akpm@linux-foundation.org, olof@lixom.net,
       mpm@selenic.com
Subject: Re: [patch 1/2] move WARN_ON() out of line
Message-ID: <20080104074149.GC17447@elte.hu>
References: <477D52ED.7000403@linux.intel.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <477D52ED.7000403@linux.intel.com>
User-Agent: Mutt/1.5.17 (2007-11-01)
X-ELTE-VirusStatus: clean
X-ELTE-SpamScore: -1.5
X-ELTE-SpamLevel: 
X-ELTE-SpamCheck: no
X-ELTE-SpamVersion: ELTE 2.0 
X-ELTE-SpamCheck-Details: score=-1.5 required=5.9 tests=BAYES_00 autolearn=no SpamAssassin version=3.2.3
	-1.5 BAYES_00               BODY: Bayesian spam probability is 0 to 1%
	[score: 0.0000]
Sender: linux-kernel-owner@vger.kernel.org
List-ID: <linux-kernel.vger.kernel.org>
X-Mailing-List: linux-kernel@vger.kernel.org


* Arjan van de Ven <arjan@linux.intel.com> wrote:

> This patch build on top of Olof's patch that introduces __WARN, and 
> places the slowpath out of line. It also uses Ingo's suggestion to not 
> use __FUNCTION__ but to use kallsyms to do the lookup; this saves a 
> ton of extra space since gcc doesn't need to store the function string 
> twice now:
>
> 3936367  833603  624736 5394706  525112 vmlinux.before
> 3917508  833603  624736 5375847  520767 vmlinux-slowpath
>
> 15Kb savings...

hey, cool!

Acked-by: Ingo Molnar <mingo@elte.hu>

i'm wondering how we could put this into x86.git to get it tested some 
more. Olof's patch touches other architectures so it's not really 
appropriate. Maybe a portion of Olof's patch could be applied to make 
your patch apply cleanly?

	Ingo

From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <linux-kernel-owner+w=401wt.eu-S1753561AbYADPvn@vger.kernel.org>
Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand
	id S1753561AbYADPvn (ORCPT <rfc822;w@1wt.eu>);
	Fri, 4 Jan 2008 10:51:43 -0500
Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1752274AbYADPvf
	(ORCPT <rfc822;linux-kernel-outgoing>);
	Fri, 4 Jan 2008 10:51:35 -0500
Received: from lixom.net ([66.141.50.11]:36081 "EHLO mail.lixom.net"
	rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP
	id S1752113AbYADPvf (ORCPT <rfc822;linux-kernel@vger.kernel.org>);
	Fri, 4 Jan 2008 10:51:35 -0500
Date: Fri, 4 Jan 2008 10:00:15 -0600
From: Olof Johansson <olof@lixom.net>
To: Ingo Molnar <mingo@elte.hu>
Cc: Arjan van de Ven <arjan@linux.intel.com>, linux-kernel@vger.kernel.org,
       akpm@linux-foundation.org, mpm@selenic.com, paulus@samba.org
Subject: Re: [patch 1/2] move WARN_ON() out of line
Message-ID: <20080104160015.GA29770@lixom.net>
References: <477D52ED.7000403@linux.intel.com> <20080104074149.GC17447@elte.hu>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <20080104074149.GC17447@elte.hu>
User-Agent: Mutt/1.5.17 (2007-11-01)
Sender: linux-kernel-owner@vger.kernel.org
List-ID: <linux-kernel.vger.kernel.org>
X-Mailing-List: linux-kernel@vger.kernel.org

On Fri, Jan 04, 2008 at 08:41:49AM +0100, Ingo Molnar wrote:
> 
> * Arjan van de Ven <arjan@linux.intel.com> wrote:
> 
> > This patch build on top of Olof's patch that introduces __WARN, and 
> > places the slowpath out of line. It also uses Ingo's suggestion to not 
> > use __FUNCTION__ but to use kallsyms to do the lookup; this saves a 
> > ton of extra space since gcc doesn't need to store the function string 
> > twice now:
> >
> > 3936367  833603  624736 5394706  525112 vmlinux.before
> > 3917508  833603  624736 5375847  520767 vmlinux-slowpath
> >
> > 15Kb savings...
> 
> hey, cool!
> 
> Acked-by: Ingo Molnar <mingo@elte.hu>
> 
> i'm wondering how we could put this into x86.git to get it tested some 
> more. Olof's patch touches other architectures so it's not really 
> appropriate. Maybe a portion of Olof's patch could be applied to make 
> your patch apply cleanly?

My base patch only touches other architectures to remove the no longer
needed HAVE_ARCH_BUG. Given the new ifdef in bug.h, there's nothing
functional that breaks if they're left in (i.e. split up in two
patches).

The only problem with merging it up the x86 path is that the powerpc
patch that builds on it would need to be ordered after the x86 merge
(in mm etc), or it'll cause build breaks. Keeping it in -mm is nice in
that way since Andrew could sequence them right when sending to Linus.

Easiest of all might be to get an Acked-by from Paul on the powerpc patch,
and merge it all up through x86.git?

(Paul: This is powerpc-switch-to-generic-warn_on-bug_on.patch in -mm
I'm talking about).


-Olof


From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <linux-kernel-owner+w=401wt.eu-S1754601AbYADQS5@vger.kernel.org>
Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand
	id S1754601AbYADQS5 (ORCPT <rfc822;w@1wt.eu>);
	Fri, 4 Jan 2008 11:18:57 -0500
Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1752877AbYADQSt
	(ORCPT <rfc822;linux-kernel-outgoing>);
	Fri, 4 Jan 2008 11:18:49 -0500
Received: from lixom.net ([66.141.50.11]:45504 "EHLO mail.lixom.net"
	rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP
	id S1752593AbYADQSt (ORCPT <rfc822;linux-kernel@vger.kernel.org>);
	Fri, 4 Jan 2008 11:18:49 -0500
Date: Fri, 4 Jan 2008 10:27:29 -0600
From: Olof Johansson <olof@lixom.net>
To: Arjan van de Ven <arjan@linux.intel.com>
Cc: linux-kernel@vger.kernel.org, mingo@elte.hu, akpm@linux-foundation.org,
       mpm@selenic.com
Subject: Re: [patch 1/2] move WARN_ON() out of line
Message-ID: <20080104162729.GB29770@lixom.net>
References: <477D52ED.7000403@linux.intel.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <477D52ED.7000403@linux.intel.com>
User-Agent: Mutt/1.5.17 (2007-11-01)
Sender: linux-kernel-owner@vger.kernel.org
List-ID: <linux-kernel.vger.kernel.org>
X-Mailing-List: linux-kernel@vger.kernel.org

Hi,

On Thu, Jan 03, 2008 at 10:26:05PM +0100, Arjan van de Ven wrote:

> This patch build on top of Olof's patch that introduces __WARN,
> and places the slowpath out of line. It also uses Ingo's suggestion
> to not use __FUNCTION__ but to use kallsyms to do the lookup;
> this saves a ton of extra space since gcc doesn't need to store the function
> string twice now:
>
> 3936367  833603  624736 5394706  525112 vmlinux.before
> 3917508  833603  624736 5375847  520767 vmlinux-slowpath
>
> 15Kb savings...

This patch actually resulted in a slight size increase on PPC, most
likely because of the new warn_on_slowpath() that isn't used:

   text    data     bss     dec     hex filename
8059224 1820584  529064 10408872 9ed3a8 vmlinux.mainline
8058268 1820592  529064 10407924 9ecff4 vmlinux.mm
8058324 1820648  529064 10408036 9ed064 vmlinux.mm+arjanpatch

Also:

> Index: linux-2.6.24-rc6/include/asm-generic/bug.h
> ===================================================================
> --- linux-2.6.24-rc6.orig/include/asm-generic/bug.h
> +++ linux-2.6.24-rc6/include/asm-generic/bug.h
> @@ -32,11 +32,8 @@ struct bug_entry {
>  #endif
>
>  #ifndef __WARN
> -#define __WARN() do {							\
> -	printk("WARNING: at %s:%d %s()\n", __FILE__,			\
> -		__LINE__, __FUNCTION__);				\
> -	dump_stack();							\
> -} while (0)
> +extern void warn_on_slowpath(const char *file, const int line);
> +#define __WARN() warn_on_slowpath(__FILE__, __LINE__)
>  #endif
>

This caused problems on powerpc, since bug.h ends up being pulled into
some assembly files. The #defines in there have been fine, but the
external declaration threw it off. (They need them to get to some of the
include/asm-powerpc/bug.h contents, but it pulls in the generic one as
well).

Easiest is probably to encapsulate the whole file in #ifndef __ASSEMBLY__.


-Olof

From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <linux-kernel-owner+w=401wt.eu-S1754838AbYAEKAX@vger.kernel.org>
Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand
	id S1754838AbYAEKAX (ORCPT <rfc822;w@1wt.eu>);
	Sat, 5 Jan 2008 05:00:23 -0500
Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1752904AbYAEKAK
	(ORCPT <rfc822;linux-kernel-outgoing>);
	Sat, 5 Jan 2008 05:00:10 -0500
Received: from smtp5.pp.htv.fi ([213.243.153.39]:46629 "EHLO smtp5.pp.htv.fi"
	rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP
	id S1752503AbYAEKAJ (ORCPT <rfc822;linux-kernel@vger.kernel.org>);
	Sat, 5 Jan 2008 05:00:09 -0500
Date: Sat, 5 Jan 2008 11:59:40 +0200
From: Adrian Bunk <bunk@kernel.org>
To: Ingo Molnar <mingo@elte.hu>
Cc: Arjan van de Ven <arjan@linux.intel.com>, linux-kernel@vger.kernel.org,
       akpm@linux-foundation.org, olof@lixom.net, mpm@selenic.com
Subject: Re: [patch 1/2] move WARN_ON() out of line
Message-ID: <20080105095940.GB2304@does.not.exist>
References: <477D52ED.7000403@linux.intel.com> <20080104074149.GC17447@elte.hu>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Disposition: inline
In-Reply-To: <20080104074149.GC17447@elte.hu>
User-Agent: Mutt/1.5.17 (2007-11-01)
Sender: linux-kernel-owner@vger.kernel.org
List-ID: <linux-kernel.vger.kernel.org>
X-Mailing-List: linux-kernel@vger.kernel.org

On Fri, Jan 04, 2008 at 08:41:49AM +0100, Ingo Molnar wrote:
>...
> i'm wondering how we could put this into x86.git to get it tested some 
> more.
>...

Please don't make x86.git a testing tree for not x86 specific stuff.

The right place for getting stuff tested is -mm, and when looking at 
git-x86.patch in -mm this tree already touches too many files outside
of arch/x86/ and include/asm-x86/.

> 	Ingo

cu
Adrian

-- 

       "Is there not promise of rain?" Ling Tan asked suddenly out
        of the darkness. There had been need of rain for many days.
       "Only a promise," Lao Er said.
                                       Pearl S. Buck - Dragon Seed


From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <linux-kernel-owner+w=401wt.eu-S1755383AbYAENRA@vger.kernel.org>
Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand
	id S1755383AbYAENRA (ORCPT <rfc822;w@1wt.eu>);
	Sat, 5 Jan 2008 08:17:00 -0500
Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1754188AbYAENQx
	(ORCPT <rfc822;linux-kernel-outgoing>);
	Sat, 5 Jan 2008 08:16:53 -0500
Received: from fg-out-1718.google.com ([72.14.220.159]:2220 "EHLO
	fg-out-1718.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org
	with ESMTP id S1754129AbYAENQw (ORCPT
	<rfc822;linux-kernel@vger.kernel.org>);
	Sat, 5 Jan 2008 08:16:52 -0500
DomainKey-Signature: a=rsa-sha1; c=nofws;
        d=gmail.com; s=gamma;
        h=message-id:date:from:organization:user-agent:mime-version:to:cc:subject:references:in-reply-to:content-type:content-transfer-encoding;
        b=gryuAG0SagaQMibHycV/mP2wifc2UNaaNGKQREh6PntwYRBkjZ9Rb3rhzGSh9vXbiYujt7dV69y5EHe3RUn7wkiPekb1a9hTv3dch9ZijYLag1M0PY68NWY7qwNHnwfXTP59C0uX07ttxSGpjcpdDuYfORN/xza6GbjPNnSxrck=
Message-ID: <477F833F.2030607@gmail.com>
Date: Sat, 05 Jan 2008 16:16:47 +0300
From: Dmitri Vorobiev <dmitri.vorobiev@gmail.com>
Organization: DmVo Home
User-Agent: Thunderbird 1.5.0.14pre (X11/20071022)
MIME-Version: 1.0
To: Arjan van de Ven <arjan@linux.intel.com>
CC: linux-kernel@vger.kernel.org, mingo@elte.hu, akpm@linux-foundation.org,
       olof@lixom.net, mpm@selenic.com
Subject: Re: [patch 1/2] move WARN_ON() out of line
References: <477D52ED.7000403@linux.intel.com>
In-Reply-To: <477D52ED.7000403@linux.intel.com>
Content-Type: text/plain; charset=KOI8-R
Content-Transfer-Encoding: 8bit
Sender: linux-kernel-owner@vger.kernel.org
List-ID: <linux-kernel.vger.kernel.org>
X-Mailing-List: linux-kernel@vger.kernel.org

Arjan van de Ven пишет:
> Subject: move WARN_ON() out of line
> From: Arjan van de Ven <arjan@linux.intel.com>
> CC: Ingo Molnar <mingo@elte.hu>
> CC: Andrew Morton <akpm@linux-foundation.org>
> CC: Olof Johansson <olof@lixom.net>
> CC: Matt Meckall <mpm@selenic.com>
> 
> A quick grep shows that there are currently 1145 instances of WARN_ON
> in the kernel. Currently, WARN_ON is pretty much entirely inlined,
> which makes it hard to enhance it without growing the size of the kernel
> (and getting Andrew rightfully unhappy).
> 
> This patch build on top of Olof's patch that introduces __WARN,
> and places the slowpath out of line. It also uses Ingo's suggestion
> to not use __FUNCTION__ but to use kallsyms to do the lookup;
> this saves a ton of extra space since gcc doesn't need to store the
> function
> string twice now:
> 
> 3936367  833603  624736 5394706  525112 vmlinux.before
> 3917508  833603  624736 5375847  520767 vmlinux-slowpath
> 
> 15Kb savings...
> 

This looks twice as good for one of MIPS configs:

   text    data     bss     dec     hex filename
4908276  204104 2846304 7958684  79709c vmlinux.after
4941596  204104 2846304 7992004  79f2c4 vmlinux.before
$ file vmlinux
vmlinux: ELF 32-bit MSB executable, MIPS, version 1 (SYSV), statically linked, not stripped

More than 30Kb gone, thanks a lot!

Tested-by: Dmitri Vorobiev <dmitri.vorobiev@gmail.com>

> Signed-off-by: Arjan van de Ven <arjan@linux.intel.com>
> 
> 
> ---
>  include/asm-generic/bug.h |    7 ++-----
>  kernel/panic.c            |   14 ++++++++++++++
>  2 files changed, 16 insertions(+), 5 deletions(-)
> 
> Index: linux-2.6.24-rc6/include/asm-generic/bug.h
> ===================================================================
> --- linux-2.6.24-rc6.orig/include/asm-generic/bug.h
> +++ linux-2.6.24-rc6/include/asm-generic/bug.h
> @@ -32,11 +32,8 @@ struct bug_entry {
>  #endif
> 
>  #ifndef __WARN
> -#define __WARN() do {                            \
> -    printk("WARNING: at %s:%d %s()\n", __FILE__,            \
> -        __LINE__, __FUNCTION__);                \
> -    dump_stack();                            \
> -} while (0)
> +extern void warn_on_slowpath(const char *file, const int line);
> +#define __WARN() warn_on_slowpath(__FILE__, __LINE__)
>  #endif
> 
>  #ifndef WARN_ON
> Index: linux-2.6.24-rc6/kernel/panic.c
> ===================================================================
> --- linux-2.6.24-rc6.orig/kernel/panic.c
> +++ linux-2.6.24-rc6/kernel/panic.c
> @@ -20,6 +20,7 @@
>  #include <linux/kexec.h>
>  #include <linux/debug_locks.h>
>  #include <linux/random.h>
> +#include <linux/kallsyms.h>
> 
>  int panic_on_oops;
>  int tainted;
> @@ -292,6 +293,19 @@ void oops_exit(void)
>          (unsigned long long)oops_id);
>  }
> 
> +
> +void warn_on_slowpath(const char *file, int line)
> +{
> +    char function[KSYM_SYMBOL_LEN];
> +    unsigned long caller = (unsigned long) __builtin_return_address(0);
> +
> +    sprint_symbol(function, caller);
> +    printk(KERN_WARNING "WARNING: at %s:%d %s()\n", file,
> +        line, function);
> +    dump_stack();
> +}
> +EXPORT_SYMBOL(warn_on_slowpath);
> +
>  #ifdef CONFIG_CC_STACKPROTECTOR
>  /*
>   * Called when gcc's -fstack-protector feature is used, and
> 
> 
> ------------------------------------------------------------------------
> 
> Subject: move WARN_ON() out of line
> From: Arjan van de Ven <arjan@linux.intel.com>
> CC: Ingo Molnar <mingo@elte.hu>
> CC: Andrew Morton <akpm@linux-foundation.org>
> CC: Olof Johansson <olof@lixom.net>
> CC: Matt Meckall <mpm@selenic.com>
> 
> A quick grep shows that there are currently 1145 instances of WARN_ON
> in the kernel. Currently, WARN_ON is pretty much entirely inlined,
> which makes it hard to enhance it without growing the size of the kernel
> (and getting Andrew unhappy).
> 
> This patch build on top of Olof's patch that introduces __WARN,
> and places the slowpath out of line. It also uses Ingo's suggestion
> to not use __FUNCTION__ but to use kallsyms to do the lookup;
> this saves a ton of extra space since gcc doesn't need to store the function
> string twice now:
> 
> 3936367  833603  624736 5394706  525112 vmlinux.before
> 3917508  833603  624736 5375847  520767 vmlinux-slowpath
> 
> 15Kb savings...
> 
> Signed-off-by: Arjan van de Ven <arjan@linux.intel.com>
> 
> 
> ---
>  include/asm-generic/bug.h |    7 ++-----
>  kernel/panic.c            |   14 ++++++++++++++
>  2 files changed, 16 insertions(+), 5 deletions(-)
> 
> Index: linux-2.6.24-rc6/include/asm-generic/bug.h
> ===================================================================
> --- linux-2.6.24-rc6.orig/include/asm-generic/bug.h
> +++ linux-2.6.24-rc6/include/asm-generic/bug.h
> @@ -32,11 +32,8 @@ struct bug_entry {
>  #endif
>  
>  #ifndef __WARN
> -#define __WARN() do {							\
> -	printk("WARNING: at %s:%d %s()\n", __FILE__,			\
> -		__LINE__, __FUNCTION__);				\
> -	dump_stack();							\
> -} while (0)
> +extern void warn_on_slowpath(const char *file, const int line);
> +#define __WARN() warn_on_slowpath(__FILE__, __LINE__)
>  #endif
>  
>  #ifndef WARN_ON
> Index: linux-2.6.24-rc6/kernel/panic.c
> ===================================================================
> --- linux-2.6.24-rc6.orig/kernel/panic.c
> +++ linux-2.6.24-rc6/kernel/panic.c
> @@ -20,6 +20,7 @@
>  #include <linux/kexec.h>
>  #include <linux/debug_locks.h>
>  #include <linux/random.h>
> +#include <linux/kallsyms.h>
>  
>  int panic_on_oops;
>  int tainted;
> @@ -292,6 +293,19 @@ void oops_exit(void)
>  		(unsigned long long)oops_id);
>  }
>  
> +
> +void warn_on_slowpath(const char *file, int line)
> +{
> +	char function[KSYM_SYMBOL_LEN];
> +	unsigned long caller = (unsigned long) __builtin_return_address(0);
> +
> +	sprint_symbol(function, caller);
> +	printk(KERN_WARNING "WARNING: at %s:%d %s()\n", file,
> +		line, function);
> +	dump_stack();
> +}
> +EXPORT_SYMBOL(warn_on_slowpath);
> +
>  #ifdef CONFIG_CC_STACKPROTECTOR
>  /*
>   * Called when gcc's -fstack-protector feature is used, and


