[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20131001015344.GV13318@ZenIV.linux.org.uk>
Date: Tue, 1 Oct 2013 02:53:44 +0100
From: Al Viro <viro@...IV.linux.org.uk>
To: Eric Dumazet <eric.dumazet@...il.com>
Cc: Linus Torvalds <torvalds@...ux-foundation.org>,
Ingo Molnar <mingo@...nel.org>,
Peter Zijlstra <peterz@...radead.org>,
Waiman Long <Waiman.Long@...com>,
Benjamin Herrenschmidt <benh@...nel.crashing.org>,
"Chandramouleeswaran, Aswin" <aswin@...com>,
Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
linux-fsdevel <linux-fsdevel@...r.kernel.org>
Subject: Re: spinlock contention of files->file_lock
On Mon, Sep 30, 2013 at 06:05:03PM -0700, Eric Dumazet wrote:
> Speaking of spinlock contention, the files->file_lock is a good example.
>
> Multi threaded programs hit this spinlock three times per fd :
>
> alloc_fd() / fd_install() / close()
>
> I think fd_install() could be done without this spinlock.
The problem is dup2(), not table resize... I'm not saying it can't be
done, but it won't be trivial and you seem to be looking for potential
trouble in the wrong place. dup2() semantics is the real bitch.
What we want is
* dup2() over unused descriptor => insert and be done with that
* dup2() over opened one => replace and do equivalent of close()
for what had been there before
The trouble is, what to do with dup2() over reserved, but still not
installed descriptor? We handle that as -EBUSY and we use ->file_lock
to get atomicity wrt transitions between those states.
And yes, dup2() is a lousy API in multithreaded situation. It's still
there... See comments in do_dup2() for some amusement.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists