public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [patch] bh_lru_install() optimize
@ 2005-08-25  8:38 Coywolf Qi Hunt
  0 siblings, 0 replies; only message in thread
From: Coywolf Qi Hunt @ 2005-08-25  8:38 UTC (permalink / raw)
  To: akpm; +Cc: linux-kernel

Hello,

This optimizes bh_lru_install(). It's a hot spot I think.  The bh_lru is well
manipulated now so we can use put_bh() as a substitute for the first __brelse()
here, and a bogus BUG_ON() can be removed safely.  We evict at the right place
too.  Boot tested.

	Coywolf


Signed-off-by: Coywolf Qi Hunt <qiyong@fc-cn.com>
---

 buffer.c |   17 ++++++-----------
 1 files changed, 6 insertions(+), 11 deletions(-)

--- 2.6.13-rc6-mm2/fs/buffer.c~orig	2005-08-23 13:42:04.000000000 +0800
+++ 2.6.13-rc6-mm2/fs/buffer.c	2005-08-25 16:04:21.000000000 +0800
@@ -1356,7 +1356,6 @@ static inline void check_irqs_on(void)
  */
 static void bh_lru_install(struct buffer_head *bh)
 {
-	struct buffer_head *evictee = NULL;
 	struct bh_lru *lru;
 
 	check_irqs_on();
@@ -1372,15 +1371,14 @@ static void bh_lru_install(struct buffer
 		for (in = 0; in < BH_LRU_SIZE; in++) {
 			struct buffer_head *bh2 = lru->bhs[in];
 
-			if (bh2 == bh) {
-				__brelse(bh2);
-			} else {
+			if (bh2 == bh)
+				put_bh(bh2);
+			else {
 				if (out >= BH_LRU_SIZE) {
-					BUG_ON(evictee != NULL);
-					evictee = bh2;
-				} else {
+					if (bh2)
+						__brelse(bh2);	/* evict bh2 */
+				} else
 					bhs[out++] = bh2;
-				}
 			}
 		}
 		while (out < BH_LRU_SIZE)
@@ -1388,9 +1386,6 @@ static void bh_lru_install(struct buffer
 		memcpy(lru->bhs, bhs, sizeof(bhs));
 	}
 	bh_lru_unlock();
-
-	if (evictee)
-		__brelse(evictee);
 }
 
 /*

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2005-08-25  8:38 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-08-25  8:38 [patch] bh_lru_install() optimize Coywolf Qi Hunt

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