lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20090115132252.GZ29283@parisc-linux.org>
Date:	Thu, 15 Jan 2009 06:22:52 -0700
From:	Matthew Wilcox <matthew@....cx>
To:	Hisashi Hifumi <hifumi.hisashi@....ntt.co.jp>
Cc:	akpm@...ux-foundation.org, linux-ext4@...r.kernel.org,
	linux-fsdevel@...r.kernel.org
Subject: Re: [RESEND] [PATCH] lseek: change i_mutex usage.

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."
--
To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ