LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Eric Dumazet <dada1@cosmosbay.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: "linux-kernel" <linux-kernel@vger.kernel.org>
Subject: [PATCH] FS : Speedup rw_verify_area()
Date: Wed, 7 Feb 2007 19:15:36 +0100	[thread overview]
Message-ID: <200702071915.37016.dada1@cosmosbay.com> (raw)
In-Reply-To: <20070207094344.0efdde10.akpm@linux-foundation.org>

[-- Attachment #1: Type: text/plain, Size: 1138 bytes --]

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>

[-- Attachment #2: rw_verify_area.patch --]
[-- Type: text/plain, Size: 628 bytes --]

--- linux-2.6.20/fs/read_write.c	2007-02-07 18:21:59.000000000 +0100
+++ linux-2.6.20-ed/fs/read_write.c	2007-02-07 18:23:41.000000000 +0100
@@ -197,13 +197,13 @@ int rw_verify_area(int read_write, struc
 	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,

  reply	other threads:[~2007-02-07 18:15 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-02-06 11:23 [2.6.20][PATCH] fix mempolicy error check on a system with memory-less-node KAMEZAWA Hiroyuki
2007-02-06 17:26 ` Christoph Lameter
2007-02-07  1:14   ` KAMEZAWA Hiroyuki
2007-02-07  8:04     ` Christoph Lameter
2007-02-07  8:36       ` KAMEZAWA Hiroyuki
2007-02-08 11:49         ` Bob Picco
2007-02-07 10:20       ` Andi Kleen
2007-02-07 10:20 ` Andi Kleen
2007-02-07 10:07   ` KAMEZAWA Hiroyuki
2007-02-07 10:19     ` Andi Kleen
2007-02-07 10:37       ` KAMEZAWA Hiroyuki
2007-02-07 10:41         ` Andi Kleen
2007-02-07 10:49           ` KAMEZAWA Hiroyuki
2007-02-07 11:32             ` Andi Kleen
2007-02-07 12:27               ` KAMEZAWA Hiroyuki
2007-02-07 14:05     ` Christoph Lameter
2007-02-07 15:28       ` KAMEZAWA Hiroyuki
2007-02-07 14:03   ` Christoph Lameter
2007-02-07 16:23   ` Andrew Morton
2007-02-07 16:50     ` Andi Kleen
2007-02-07 17:43       ` Andrew Morton
2007-02-07 18:15         ` Eric Dumazet [this message]
2007-02-08  0:37         ` KAMEZAWA Hiroyuki
2007-02-08 19:09         ` Christoph Lameter
2007-02-08 19:26           ` Andrew Morton
2007-02-08 19:35             ` Christoph Lameter

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200702071915.37016.dada1@cosmosbay.com \
    --to=dada1@cosmosbay.com \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --subject='Re: [PATCH] FS : Speedup rw_verify_area()' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).