Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755488AbbDTNGr (ORCPT ); Mon, 20 Apr 2015 09:06:47 -0400 Received: from mx1.redhat.com ([209.132.183.28]:42753 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753108AbbDTNGn (ORCPT ); Mon, 20 Apr 2015 09:06:43 -0400 Date: Mon, 20 Apr 2015 15:06:34 +0200 From: Mateusz Guzik To: Al Viro Cc: Eric Dumazet , Andrew Morton , "Paul E. McKenney" , Yann Droneaud , Konstantin Khlebnikov , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [RFC PATCH] fs: use a sequence counter instead of file_lock in fd_install Message-ID: <20150420130633.GA2513@mguzik> References: <20150416121628.GA20615@mguzik> <1429307216.7346.255.camel@edumazet-glaptop2.roam.corp.google.com> <20150417221646.GA15589@mguzik> <20150417230252.GE889@ZenIV.linux.org.uk> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20150417230252.GE889@ZenIV.linux.org.uk> User-Agent: Mutt/1.5.23.1-rc1 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2087 Lines: 48 On Sat, Apr 18, 2015 at 12:02:52AM +0100, Al Viro wrote: > On Sat, Apr 18, 2015 at 12:16:48AM +0200, Mateusz Guzik wrote: > > > I would say this makes the use of seq counter impossible. Even if we > > decided to fall back to a lock on retry, we cannot know what to do if > > the slot is reserved - it very well could be that something called > > close, and something else reserved the slot, so putting the file inside > > could be really bad. In fact we would be putting a file for which we > > don't have a reference anymore. > > > > However, not all hope is lost and I still think we can speed things up. > > > > A locking primitive which only locks stuff for current cpu and has > > another mode where it locks stuff for all cpus would do the trick just > > fine. I'm not a linux guy, quick search suggests 'lglock' would do what > > I want. > > > > table reallocation is an extremely rare operation, so this should be > > fine. It would take the lock 'globally' for given table. > > It would also mean percpu_alloc() for each descriptor table... Well as it was noted I have not checked how it's implemented at the time of writing the message. I agree embedding something like this into files struct is a non-starter. I would say this could work with a small set of locks, selected by hashing struct files pointer. Table resizing is supposed to be extremely rare - most processes should not need it at all (if they do, the default size is too small and should be adjusted). Not only that, the lock is only needed if the process in question is multithreaded. So I would say this would not contend in real-world workloads, but still looks crappy. Unfortunately the whole thing loses original appeal of a simple hack with no potential perfomrance drawbacks. Maybe I'll hack it up later and run some tests anyway. -- Mateusz Guzik -- 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/