Skip to contentSkip to conversation

bh_lru_install() optimize

PATCH New Coywolf Qi Hunt 1 participant 1 message Aug 25, 2005 VFS

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 bh_lru_install() optimize

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

---

 buffer.c |   17 ++++++-----------
 1 files changed, 6 insertions(+), 11 deletions(-)
fs/buffer.c renamed from fs/buffer.c~orig +6 -11
@@ -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);
 }
 
 /*