Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758791AbZGHUZ0 (ORCPT ); Wed, 8 Jul 2009 16:25:26 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1755214AbZGHUZQ (ORCPT ); Wed, 8 Jul 2009 16:25:16 -0400 Received: from mx1.redhat.com ([66.187.233.31]:38381 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754539AbZGHUZP (ORCPT ); Wed, 8 Jul 2009 16:25:15 -0400 Date: Wed, 8 Jul 2009 16:11:59 -0400 From: Valerie Aurora To: Andi Kleen 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 Message-ID: <20090708201159.GB16893@shell> References: <20090706924.495556466@firstfloor.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20090706924.495556466@firstfloor.org> User-Agent: Mutt/1.4.2.2i Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2189 Lines: 77 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 > > --- > 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 -VAL -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/