xfs-masters
[Top] [All Lists]

Re: [xfs-masters] RFC: Fix f_flags races without the BKL

To: Andi Kleen <andi@xxxxxxxxxxxxxx>
Subject: Re: [xfs-masters] RFC: Fix f_flags races without the BKL
From: Christoph Hellwig <hch@xxxxxx>
Date: Tue, 30 Dec 2008 15:48:37 +0100
Cc: Christoph Hellwig <hch@xxxxxx>, Jonathan Corbet <corbet@xxxxxxx>, Al@xxxxxxxxxxx, Oleg Nesterov <oleg@xxxxxxxxxx>, LKML <linux-kernel@xxxxxxxxxxxxxxx>, bfields@xxxxxxxxxxxx, xfs-masters@xxxxxxxxxxx, Viro <viro@xxxxxxxxxxxxxxxxxx>, Alan Cox <alan@xxxxxxxxxxxxxxxxxxx>
In-reply-to: <20081230133737.GM496@xxxxxxxxxxxxxxxxxx>
References: <20081229041352.6bbdf57c@tpl> <20081229124151.GA29634@xxxxxxxxxx> <20081229152732.GH496@xxxxxxxxxxxxxxxxxx> <20081230055956.1747bd86@tpl> <20081230130439.GA28874@xxxxxx> <20081230133737.GM496@xxxxxxxxxxxxxxxxxx>
User-agent: Mutt/1.3.28i
On Tue, Dec 30, 2008 at 02:37:37PM +0100, Andi Kleen wrote:
> That's not clear. Mutexes can be much slower than a spinlock
> like BKL in some situations, mostly because they schedule more and
> have generally more overhead.
> 
> As long as you don't have another BKL user contending the BKL
> is likely faster than the mutex.

Note that I did not say faster, but better.  The subtle races the
BKL semantics introduce are nasty.

That beeing said I took another look at the patch and it seems like
most places are indeed just very quick flags setting / clearing
with the only sleeping possible inside ->fasync.  So having a
file_flags_lock spinlock, and another sleeping mutex protecting
->fasync might be another options.

Jon, do you remember what we actually need to protect in -fasync?
any reason not to take the locking inside the method?  Together with
->lock and the old ->ioctl it's pretty special in fops as none of
the others have any locking at all.

> 
> -Andi
> 
> -- 
> ak@xxxxxxxxxxxxxxx
> 
> _______________________________________________
> xfs-masters mailing list
> xfs-masters@xxxxxxxxxxx
> http://oss.sgi.com/mailman/listinfo/xfs-masters
---end quoted text---

<Prev in Thread] Current Thread [Next in Thread>