public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] conditionalize some boring buffer_head checks
@ 2004-04-14  7:43 Jeff Garzik
  2004-04-14  7:58 ` Andrew Morton
  2004-04-14  8:29 ` Jens Axboe
  0 siblings, 2 replies; 24+ messages in thread
From: Jeff Garzik @ 2004-04-14  7:43 UTC (permalink / raw)
  To: Andrew Morton; +Cc: Linux Kernel

[-- Attachment #1: Type: text/plain, Size: 463 bytes --]


These checks are executed billions of times per day, with no stack dump 
bug reports sent to lkml.  Arguably, they will only trigger on buggy 
filesystems (programmer error), and thus IMO shouldn't even be executed 
in a non-debug kernel.

Even though BUG_ON() includes unlikely(), I think this patch -- or 
something like it -- is preferable.  The buffer_error() checks aren't 
even marked unlikely().

This is a micro-optimization on a key kernel fast path.



[-- Attachment #2: patch --]
[-- Type: text/plain, Size: 849 bytes --]

===== fs/buffer.c 1.237 vs edited =====
--- 1.237/fs/buffer.c	Wed Apr 14 03:18:09 2004
+++ edited/fs/buffer.c	Wed Apr 14 03:39:15 2004
@@ -2688,6 +2688,7 @@
 {
 	struct bio *bio;
 
+#ifdef BH_DEBUG
 	BUG_ON(!buffer_locked(bh));
 	BUG_ON(!buffer_mapped(bh));
 	BUG_ON(!bh->b_end_io);
@@ -2698,6 +2699,7 @@
 		buffer_error();
 	if (rw == READ && buffer_dirty(bh))
 		buffer_error();
+#endif
 
 	/* Only clear out a write error when rewriting */
 	if (test_set_buffer_req(bh) && rw == WRITE)
===== include/linux/buffer_head.h 1.47 vs edited =====
--- 1.47/include/linux/buffer_head.h	Wed Apr 14 03:18:09 2004
+++ edited/include/linux/buffer_head.h	Wed Apr 14 03:39:31 2004
@@ -13,6 +13,8 @@
 #include <linux/wait.h>
 #include <asm/atomic.h>
 
+#undef BH_DEBUG
+
 enum bh_state_bits {
 	BH_Uptodate,	/* Contains valid data */
 	BH_Dirty,	/* Is dirty */

^ permalink raw reply	[flat|nested] 24+ messages in thread

end of thread, other threads:[~2004-04-15 21:46 UTC | newest]

Thread overview: 24+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-04-14  7:43 [PATCH] conditionalize some boring buffer_head checks Jeff Garzik
2004-04-14  7:58 ` Andrew Morton
2004-04-14  8:02   ` Andrew Morton
2004-04-14  8:10     ` Jeff Garzik
2004-04-14  8:16       ` Andrew Morton
2004-04-14  8:45         ` Jeff Garzik
2004-04-14  9:10         ` Jeff Garzik
2004-04-14 21:25           ` Matt Mackall
2004-04-14 21:27             ` Randy.Dunlap
2004-04-14 21:37               ` Matt Mackall
2004-04-14 21:33             ` Jeff Garzik
2004-04-14 21:49               ` Matt Mackall
2004-04-15  6:12               ` Zwane Mwaikambo
2004-04-15 20:52             ` PATCH] Kconfig.debug family Randy.Dunlap
2004-04-15 21:36               ` Sam Ravnborg
2004-04-15 21:36               ` Marc-Christian Petersen
2004-04-15 21:41                 ` Randy.Dunlap
2004-04-14  8:27       ` [PATCH] conditionalize some boring buffer_head checks Tim Hockin
2004-04-14  8:48         ` Jeff Garzik
2004-04-14 13:31           ` Chris Friesen
2004-04-14 15:05             ` Randy.Dunlap
2004-04-14  8:29 ` Jens Axboe
2004-04-14  8:42   ` Jeff Garzik
2004-04-14  8:47     ` Jens Axboe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox