aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorEric Dumazet <dada1@cosmosbay.com>2007-02-12 03:52:24 -0500
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-02-12 12:48:29 -0500
commit163da958ba5282cbf85e8b3dc08e4f51f8b01c5e (patch)
treeccfdaf7ac1b0f5e06cd4cc34522fa491ede89fe7 /fs
parent2a10387ec463c4fcd3ccc461291ce4d8505827e2 (diff)
[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 <dada1@cosmosbay.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'fs')
-rw-r--r--fs/read_write.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/fs/read_write.c b/fs/read_write.c
index bcb0ef2aae3d..1f8dc373ede7 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
197 struct inode *inode; 197 struct inode *inode;
198 loff_t pos; 198 loff_t pos;
199 199
200 inode = file->f_path.dentry->d_inode;
200 if (unlikely((ssize_t) count < 0)) 201 if (unlikely((ssize_t) count < 0))
201 goto Einval; 202 goto Einval;
202 pos = *ppos; 203 pos = *ppos;
203 if (unlikely((pos < 0) || (loff_t) (pos + count) < 0)) 204 if (unlikely((pos < 0) || (loff_t) (pos + count) < 0))
204 goto Einval; 205 goto Einval;
205 206
206 inode = file->f_path.dentry->d_inode;
207 if (unlikely(inode->i_flock && MANDATORY_LOCK(inode))) { 207 if (unlikely(inode->i_flock && MANDATORY_LOCK(inode))) {
208 int retval = locks_mandatory_area( 208 int retval = locks_mandatory_area(
209 read_write == READ ? FLOCK_VERIFY_READ : FLOCK_VERIFY_WRITE, 209 read_write == READ ? FLOCK_VERIFY_READ : FLOCK_VERIFY_WRITE,