From owner-freebsd-current@FreeBSD.ORG Tue Dec 20 18:30:20 2005 Return-Path: X-Original-To: freebsd-current@freebsd.org Delivered-To: freebsd-current@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id B6EF516A41F; Tue, 20 Dec 2005 18:30:20 +0000 (GMT) (envelope-from jhb@freebsd.org) Received: from speedfactory.net (mail6.speedfactory.net [66.23.216.219]) by mx1.FreeBSD.org (Postfix) with ESMTP id A222B43D70; Tue, 20 Dec 2005 18:30:18 +0000 (GMT) (envelope-from jhb@freebsd.org) Received: from server.baldwin.cx (unverified [66.23.211.162]) by speedfactory.net (SurgeMail 3.5b3) with ESMTP id 4227830 for multiple; Tue, 20 Dec 2005 13:28:27 -0500 Received: from localhost (john@localhost [127.0.0.1]) by server.baldwin.cx (8.13.4/8.13.4) with ESMTP id jBKIUDnB007809; Tue, 20 Dec 2005 13:30:16 -0500 (EST) (envelope-from jhb@freebsd.org) From: John Baldwin To: freebsd-current@freebsd.org Date: Tue, 20 Dec 2005 11:39:33 -0500 User-Agent: KMail/1.8.2 References: <20051220032538.A33093@xorpc.icir.org> <43A8166C.9060401@FreeBSD.org> <20051220081611.A36159@xorpc.icir.org> In-Reply-To: <20051220081611.A36159@xorpc.icir.org> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200512201139.35723.jhb@freebsd.org> X-Virus-Scanned: ClamAV version 0.87.1, clamav-milter version 0.87 on server.baldwin.cx X-Virus-Status: Clean X-Spam-Status: No, score=-1.4 required=4.2 tests=ALL_TRUSTED autolearn=failed version=3.1.0 X-Spam-Checker-Version: SpamAssassin 3.1.0 (2005-09-13) on server.baldwin.cx X-Server: High Performance Mail Server - http://surgemail.com r=1653887525 Cc: Luigi Rizzo , Suleiman Souhlal Subject: Re: td->td_critnest manipulations do not use atomic_add_int ? X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 20 Dec 2005 18:30:20 -0000 On Tuesday 20 December 2005 11:16 am, Luigi Rizzo wrote: > On Tue, Dec 20, 2005 at 06:34:20AM -0800, Suleiman Souhlal wrote: > > Hello Luigi, > > > > Luigi Rizzo wrote: > > > as in the subject... i see that td->td_critnest (used to determine > > > whether a thread can be preempted or not) is manipulated using > > > plain ++ or -- instruction instead of the atomic_add_int(). > > > > This should be fine as it only gets modified by the current thread. If > > an interrupt comes while we are decreasing td_critnest back to 0, then > > we just don't get preempted immediately, but at the end of our quantum, > > or when someone else tries to preempt us, whichever comes first, which > > should be totally harmless. > > i think that there are still some potential race conditions if > the variable is read from another processor to make a decision > based on its value. It's not, that's the key. It's only read by the current thread. Because of sched_lock being held when a thread context switches (and thus anytime it migrates) and the membars it contains, no other locking is needed for data that only curthread accesses. -- John Baldwin <>< http://www.FreeBSD.org/~jhb/ "Power Users Use the Power to Serve" = http://www.FreeBSD.org