From owner-freebsd-arch@FreeBSD.ORG Thu Aug 16 23:20:33 2007 Return-Path: Delivered-To: freebsd-arch@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id BD3C516A421 for ; Thu, 16 Aug 2007 23:20:33 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from speedfactory.net (mail6.speedfactory.net [66.23.216.219]) by mx1.freebsd.org (Postfix) with ESMTP id 82C3613C457 for ; Thu, 16 Aug 2007 23:20:33 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from server.baldwin.cx (unverified [66.23.211.162]) by speedfactory.net (SurgeMail 3.8k) with ESMTP id 203738904-1834499 for multiple; Thu, 16 Aug 2007 19:20:29 -0400 Received: from localhost.corp.yahoo.com (john@localhost [127.0.0.1]) (authenticated bits=0) by server.baldwin.cx (8.13.8/8.13.8) with ESMTP id l7GNKKKU049205; Thu, 16 Aug 2007 19:20:20 -0400 (EDT) (envelope-from jhb@freebsd.org) From: John Baldwin To: Jeff Roberson Date: Thu, 16 Aug 2007 19:04:06 -0400 User-Agent: KMail/1.9.6 References: <20070815233852.X568@10.0.0.1> <200708161635.20935.jhb@freebsd.org> <20070816151932.R568@10.0.0.1> In-Reply-To: <20070816151932.R568@10.0.0.1> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200708161904.06299.jhb@freebsd.org> X-Greylist: Sender succeeded SMTP AUTH authentication, not delayed by milter-greylist-2.0.2 (server.baldwin.cx [127.0.0.1]); Thu, 16 Aug 2007 19:20:20 -0400 (EDT) X-Virus-Scanned: ClamAV 0.88.3/3967/Thu Aug 16 11:32:14 2007 on server.baldwin.cx X-Virus-Status: Clean X-Spam-Status: No, score=-4.4 required=4.2 tests=ALL_TRUSTED,AWL,BAYES_00 autolearn=ham version=3.1.3 X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on server.baldwin.cx Cc: freebsd-arch@freebsd.org Subject: Re: file locking. X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 16 Aug 2007 23:20:33 -0000 On Thursday 16 August 2007 06:31:13 pm Jeff Roberson wrote: > On Thu, 16 Aug 2007, John Baldwin wrote: > > > On Thursday 16 August 2007 04:18:51 pm Jeff Roberson wrote: > >> On Thu, 16 Aug 2007, John Baldwin wrote: > >> > >>> On Thursday 16 August 2007 03:01:18 am Jeff Roberson wrote: > >>>> I have been looking at file locking for 8.0 and have come up with a way > > to > >>>> completely eliminate the file lock, reduce the size of struct file by > >>>> ~4 pointers (22%), remove the global list of files and associated lock, > >>>> and restrict the scope of unp_gc while removing several race conditions. > >>> > >> > >> Thanks for the review. > >> > >>> I like finit(). I would maybe change socketpair() to pass so1 and so2 to > >>> finit() rather than setting f_data twice. > >> > >> I'm not sure what you mean? > > > > In socketpair() the new code does this: > > > > fp1->f_data = so1; > > ... > > fp2->f_data = so2; > > ... > > finit(fp1, ..., fp1->f_data, ...); > > finit(fp2, ..., fp2->f_data, ...); > > > > It might be cleaner to do this: > > > > ... > > ... > > finit(fp1, ..., so1, ...); > > finit(fp2, ..., so2, ...); > > I did not want to have one file pointing at another without an initialized > f_data field. However, I guess the underlying sockets are already setup > so this may not be important. The code did go to some effort to setup > f_data early before as well so I didn't want to change that. Until f_ops is set, f_data is irrelevant as badfileops ignores f_data. > > So, in the old code there's a really big comment about how it makes sure to > > only do closef() (via unp_discard()) once but does a sorflush() for each > > f_msgcount. Was that comment no longer true? > > The comment actually says: > > * > * It is incorrect to simply unp_discard each entry for f_msgcount > * times > > What we do is grab an extra ref to each struct file that is dead and then > explicitly sorflush() them. This closes all of the references held by > that socket, which would free any unreferenced non-unp descriptors. > However, we want to prevent the algorithm from recursing in on itself so > we hold the extra file ref for unp sockets that would be closed. Then > when we loop releasing this one last ref at the end the actually fo_close > will be called. > > This portion of the algorithm is not significantly different from before. > I just introduced an extra flag so I could remove the race from dropping > the lock inbetween operations and get an accurate count of how big the > array needs to be. Ok. > >> Do we have an official stance on libkvm? Now that we have sysctl for > >> run-time it's only useful for crashdump debugging. Really in most cases > >> it could be replaced with a reasonable set of gcc scripts. > > > > s/gcc/gdb/. At work we do mostly post-mortem analysis, so having working > > libkvm is still very important for us. xref the way I just fixed netstat to > > work again on coredumps recently. Breaking fstat on coredumps would probably > > be very annoying. libkvm can always use the same algo as the sysctl if > > necessary though. > > Yes, I'll do that. Cool, thanks! -- John Baldwin