Skip to contentSkip to conversation

fs: change lookup_bh_lru() to use memmove()

RFC New yalin wang 1 participant 1 message Sep 29, 2015 VFS

lore
Share & tools
lore

yalin wang

author
#0 lore raw

RFC 1/1 fs: change lookup_bh_lru() to use memmove()

This patch make a little change to lookup_bh_lru() function to use memmove() to set new buffer_head,
better performance for some platforms.

---
 fs/buffer.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)
fs/buffer.c +3 -5
index d6769f1..af14d69 100644
@@ -1331,11 +1331,9 @@ lookup_bh_lru(struct block_device *bdev, sector_t block, unsigned size)
 		if (bh && bh->b_blocknr == block && bh->b_bdev == bdev &&
 		    bh->b_size == size) {
 			if (i) {
-				while (i) {
-					__this_cpu_write(bh_lrus.bhs[i],
-						__this_cpu_read(bh_lrus.bhs[i - 1]));
-					i--;
-				}
+				memmove(&this_cpu_ptr(&bh_lrus)->bhs[1],
+					&this_cpu_ptr(&bh_lrus)->bhs[0],
+					sizeof(bh)*i);
 				__this_cpu_write(bh_lrus.bhs[0], bh);
 			}
 			get_bh(bh);
Signature · 1 line
1.9.1