From: Matthew Wilcox <matthew@wil.cx>
To: Hisashi Hifumi <hifumi.hisashi@oss.ntt.co.jp>
Cc: akpm@linux-foundation.org, linux-ext4@vger.kernel.org,
linux-fsdevel@vger.kernel.org
Subject: Re: [RESEND] [PATCH] lseek: change i_mutex usage.
Date: Thu, 15 Jan 2009 06:22:52 -0700 [thread overview]
Message-ID: <20090115132252.GZ29283@parisc-linux.org> (raw)
In-Reply-To: <6.0.0.20.2.20090115163853.07056ed0@172.19.0.2>
On Thu, Jan 15, 2009 at 04:42:19PM +0900, Hisashi Hifumi wrote:
> I changed i_mutex usage on generic_file_llseek.
> This function is inside i_mutex, but I think there is room for optimization in some cases.
> When SEEK_END is specified from caller, in this case we should handle
> inode->i_size so i_mutex is needed. But in other cases such as SEEK_CUR or
> SEEK_SET, i_mutex is not needed because just changing file->f_pos value without
> touching i_size.
Of course if you have multiple threads, they will share a struct file,
and you're updating f_pos and f_version without locking. Maybe that's
OK, but it's soemthing you didn't discuss.
I think it's the only reason to have the mutex here. Otherwise we could
simply use i_size_read() in generic_file_llseek_unlocked() and there
would be no need for a mutex at all.
> - mutex_lock(&file->f_dentry->d_inode->i_mutex);
> - rval = generic_file_llseek_unlocked(file, offset, origin);
> - mutex_unlock(&file->f_dentry->d_inode->i_mutex);
> + if (origin == SEEK_END) {
> + mutex_lock(&file->f_dentry->d_inode->i_mutex);
> + rval = generic_file_llseek_unlocked(file, offset, origin);
> + mutex_unlock(&file->f_dentry->d_inode->i_mutex);
> + } else
> + rval = generic_file_llseek_unlocked(file, offset, origin);
I'm pretty sure the spinning mutex work will have a significant effect
on the performance here.
--
Matthew Wilcox Intel Open Source Technology Centre
"Bill, look, we understand that you're interested in selling us this
operating system, but compare it to ours. We can't possibly take such
a retrograde step."
next prev parent reply other threads:[~2009-01-15 13:23 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-01-15 7:42 [RESEND] [PATCH] lseek: change i_mutex usage Hisashi Hifumi
2009-01-15 13:22 ` Matthew Wilcox [this message]
2009-01-15 14:21 ` Theodore Tso
2009-01-15 15:36 ` jim owens
2009-01-16 0:40 ` Andrew Morton
2009-01-16 0:53 ` Hisashi Hifumi
2009-01-16 1:49 ` Andrew Morton
2009-01-16 2:08 ` Hisashi Hifumi
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=20090115132252.GZ29283@parisc-linux.org \
--to=matthew@wil.cx \
--cc=akpm@linux-foundation.org \
--cc=hifumi.hisashi@oss.ntt.co.jp \
--cc=linux-ext4@vger.kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
/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).