Gitweb:     
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=163da958ba5282cbf85e8b3dc08e4f51f8b01c5e
Commit:     163da958ba5282cbf85e8b3dc08e4f51f8b01c5e
Parent:     2a10387ec463c4fcd3ccc461291ce4d8505827e2
Author:     Eric Dumazet <[EMAIL PROTECTED]>
AuthorDate: Mon Feb 12 00:52:24 2007 -0800
Committer:  Linus Torvalds <[EMAIL PROTECTED]>
CommitDate: Mon Feb 12 09:48:29 2007 -0800

    [PATCH] FS: speed up rw_verify_area()
    
    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: Eric Dumazet <[EMAIL PROTECTED]>
    Signed-off-by: Andrew Morton <[EMAIL PROTECTED]>
    Signed-off-by: Linus Torvalds <[EMAIL PROTECTED]>
---
 fs/read_write.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/fs/read_write.c b/fs/read_write.c
index bcb0ef2..1f8dc37 100644
--- a/fs/read_write.c
+++ b/fs/read_write.c
@@ -197,13 +197,13 @@ int rw_verify_area(int read_write, struct file *file, 
loff_t *ppos, size_t count
        struct inode *inode;
        loff_t pos;
 
+       inode = file->f_path.dentry->d_inode;
        if (unlikely((ssize_t) count < 0))
                goto Einval;
        pos = *ppos;
        if (unlikely((pos < 0) || (loff_t) (pos + count) < 0))
                goto Einval;
 
-       inode = file->f_path.dentry->d_inode;
        if (unlikely(inode->i_flock && MANDATORY_LOCK(inode))) {
                int retval = locks_mandatory_area(
                        read_write == READ ? FLOCK_VERIFY_READ : 
FLOCK_VERIFY_WRITE,
-
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to