• Eric Dumazet's avatar
    [PATCH] FS: speed up rw_verify_area() · 163da958
    Eric Dumazet authored
    oprofile hunting showed a stall in rw_verify_area(), because of triple
    indirection and potential cache misses.
    (file->f_path.dentry->d_inode->i_flock)
    
    By moving initialization of 'struct inode' pointer before the pos/count
    sanity tests, we allow the compiler and processor to perform two loads by
    anticipation, reducing stall, without prefetch() hints.  Even x86 arch has
    enough registers to not use temporary variables and not increase text size.
    
    I validated this patch running a bench and studied oprofile changes, and
    absolute perf of the test program.
    
    Results of my epoll_pipe_bench (source available on request) on a Pentium-M
    1.6 GHz machine
    
    Before :
    # ./epoll_pipe_bench -l 30 -t 20
    Avg: 436089 evts/sec read_count=8843037 write_count=8843040 21.218390 samples
    per call
    (best value out of 10 runs)
    
    After :
    # ./epoll_pipe_bench -l 30 -t 20
    Avg: 470980 evts/sec read_count=9549871 write_count=9549894 21.216694 samples
    per call
    (best value out of 10 runs)
    
    oprofile CPU_CLK_UNHALTED events gave a reduction from 5.3401 % to 2.5851 %
    for the rw_verify_area() function.
    Signed-off-by: default avatarEric Dumazet <dada1@cosmosbay.com>
    Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
    Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
    163da958
read_write.c 17.6 KB