From owner-freebsd-arch@FreeBSD.ORG Fri Jun 1 09:57:27 2007 Return-Path: X-Original-To: freebsd-arch@FreeBSD.org Delivered-To: freebsd-arch@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id CE85716A400 for ; Fri, 1 Jun 2007 09:57:27 +0000 (UTC) (envelope-from jroberson@chesapeake.net) Received: from webaccess-cl.virtdom.com (webaccess-cl.virtdom.com [216.240.101.25]) by mx1.freebsd.org (Postfix) with ESMTP id 936D013C483 for ; Fri, 1 Jun 2007 09:57:27 +0000 (UTC) (envelope-from jroberson@chesapeake.net) Received: from [192.168.1.101] (c-71-231-138-78.hsd1.or.comcast.net [71.231.138.78]) (authenticated bits=0) by webaccess-cl.virtdom.com (8.13.6/8.13.6) with ESMTP id l519vO7r039190 (version=TLSv1/SSLv3 cipher=DHE-DSS-AES256-SHA bits=256 verify=NO); Fri, 1 Jun 2007 05:57:26 -0400 (EDT) (envelope-from jroberson@chesapeake.net) Date: Fri, 1 Jun 2007 02:57:19 -0700 (PDT) From: Jeff Roberson X-X-Sender: jroberson@10.0.0.1 To: Bruce Evans In-Reply-To: <20070601192834.S4657@besplex.bde.org> Message-ID: <20070601025432.N799@10.0.0.1> References: <20070529105856.L661@10.0.0.1> <200705291456.38515.jhb@freebsd.org> <20070529121653.P661@10.0.0.1> <20070530065423.H93410@delplex.bde.org> <20070529141342.D661@10.0.0.1> <20070530125553.G12128@besplex.bde.org> <20070529201255.X661@10.0.0.1> <20070529220936.W661@10.0.0.1> <20070530201618.T13220@besplex.bde.org> <20070530115752.F661@10.0.0.1> <20070531091419.S826@besplex.bde.org> <20070531010631.N661@10.0.0.1> <20070531181228.W799@10.0.0.1> <20070601192834.S4657@besplex.bde.org> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed Cc: freebsd-arch@FreeBSD.org Subject: Re: Updated rusage patch 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: Fri, 01 Jun 2007 09:57:27 -0000 On Fri, 1 Jun 2007, Bruce Evans wrote: > On Thu, 31 May 2007, Jeff Roberson wrote: > >> Now that I've said all of that and committed the patch, I just realized >> that there is still one race that is unacceptable. When the thread exits >> in thread_exit() and adds the stats of both threads together we could lose >> changes in the still-running thread. > > I think I see. > > The same problem seems to affect all calls to ruxagg() and rucollect() > for threads that aren't curthread. You cannot control the stats for > other threads using a spinlock since statclock() doesn't use a spinlock > for the tick counts and shouldn't (modulo this bug) use one for the > rss's. Resetting the tick counts in ruxagg() is particulary dangerous. > Resetting the runtime in ruxagg() isn't a problem because the runtime > isn't touched by statclock(). ruxcollect() only does insufficently > locked accesses for reading the rss's, except in thread_exit(). It > should be easy to avoid the resettings by accumulating into a local > rux as is already done for ru's (put an rux in each thread and add > these up when required). This reduces to the same problem as for the > rss's. Well, it isn't terribly inconvenient to hold the sched_lock/thread_lock in statclock() where the stats are updated. This makes the solution simply to grab thread/sched lock in ruxagg(). Jeff > > Bruce >