From: Valerie Aurora <vaurora@redhat.com>
To: Andi Kleen <andi@firstfloor.org>
Cc: viro@zeniv.linux.org.uk, linux-kernel@vger.kernel.org,
linux-fsdevel@vger.kernel.org
Subject: Re: [PATCH] [1/2] Optimization for touch_atime
Date: Wed, 8 Jul 2009 16:11:59 -0400 [thread overview]
Message-ID: <20090708201159.GB16893@shell> (raw)
In-Reply-To: <20090706924.495556466@firstfloor.org>
On Mon, Jul 06, 2009 at 09:24:46PM +0200, Andi Kleen wrote:
>
> Some benchmark testing shows touch_atime to be high up in profile
> logs for IO intensive workloads. Most likely that's due to the lock
> in mnt_want_write(). Unfortunately touch_atime first takes the lock,
> and then does all the other tests that could avoid atime updates (like
> noatime or relatime).
>
> Do it the other way round -- first try to avoid the update and only
> then if that didn't succeed take the lock. That works because none of
> the atime avoidance tests rely on locking.
>
> This also eliminates a goto.
>
> Signed-off-by: Andi Kleen <ak@linux.intel.com>
>
> ---
> fs/inode.c | 20 ++++++++++----------
> 1 file changed, 10 insertions(+), 10 deletions(-)
>
> Index: linux-2.6.30-ak/fs/inode.c
> ===================================================================
> --- linux-2.6.30-ak.orig/fs/inode.c
> +++ linux-2.6.30-ak/fs/inode.c
> @@ -1361,31 +1361,31 @@ void touch_atime(struct vfsmount *mnt, s
> struct inode *inode = dentry->d_inode;
> struct timespec now;
>
> - if (mnt_want_write(mnt))
> - return;
> if (inode->i_flags & S_NOATIME)
> - goto out;
> + return;
> if (IS_NOATIME(inode))
> - goto out;
> + return;
> if ((inode->i_sb->s_flags & MS_NODIRATIME) && S_ISDIR(inode->i_mode))
> - goto out;
> + return;
>
> if (mnt->mnt_flags & MNT_NOATIME)
> - goto out;
> + return;
> if ((mnt->mnt_flags & MNT_NODIRATIME) && S_ISDIR(inode->i_mode))
> - goto out;
> + return;
>
> now = current_fs_time(inode->i_sb);
>
> if (!relatime_need_update(mnt, inode, now))
> - goto out;
> + return;
>
> if (timespec_equal(&inode->i_atime, &now))
> - goto out;
> + return;
> +
> + if (mnt_want_write(mnt))
> + return;
>
> inode->i_atime = now;
> mark_inode_dirty_sync(inode);
> -out:
> mnt_drop_write(mnt);
> }
> EXPORT_SYMBOL(touch_atime);
Nice!
Reviewed-by: Valerie Aurora <vaurora@redhat.com>
-VAL
prev parent reply other threads:[~2009-07-08 20:25 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-07-06 19:24 [PATCH] [1/2] Optimization for touch_atime Andi Kleen
2009-07-06 19:24 ` [PATCH] [2/2] Optimize touch_time too Andi Kleen
2009-07-07 10:50 ` Christoph Hellwig
2009-07-07 10:49 ` [PATCH] [1/2] Optimization for touch_atime Christoph Hellwig
2009-07-08 20:11 ` Valerie Aurora [this message]
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=20090708201159.GB16893@shell \
--to=vaurora@redhat.com \
--cc=andi@firstfloor.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=viro@zeniv.linux.org.uk \
/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
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).