: block_read_full_page: micro optimization
PATCH 1/1 : block_read_full_page: micro optimization
I wonder, may be with such change kernel become little faster?
---
fs/buffer.c +1 -1
@@ -2093,7 +2093,7 @@ int block_read_full_page(struct page *pa }if (!buffer_mapped (bh)) {void *kaddr =kmap_atomic (page,KM_USER0 ); -memset (kaddr + i * blocksize,0 , blocksize); +memset (kaddr + (i << inode->i_blkbits),0 , blocksize);flush_dcache_page (page);kunmap_atomic (kaddr,KM_USER0 );if (!err)
fs/buffer.c int block_read_full_page(struct page *pa · line 2096
Quoted 3 lines · Paul Drynoff
I wonder, may be with such change kernel become little faster?
fs/buffer.c +1
-1-memset (kaddr + i * blocksize,0 , blocksize); +memset (kaddr + (i << inode->i_blkbits),0 , blocksize);
It's likely slower with this change, as you now require the CPU to load inode->i_blkbits which, chances are, isn't hanging around handily in a register like blocksize obviously is. So, you've increased register pressure and added more fetches from memory instead of just doing a simple (and cheap) multiplication. Not good.
Check the generated code for both cases. Smaller is usually better. Benchmarking would be best, however, code changes that cause cache misses or register pressure can be hard to measure well.
Ray