From owner-p4-projects@FreeBSD.ORG Tue Aug 15 16:02:36 2006 Return-Path: X-Original-To: p4-projects@freebsd.org Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 68EE716A4E5; Tue, 15 Aug 2006 16:02:36 +0000 (UTC) X-Original-To: perforce@freebsd.org Delivered-To: perforce@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 27B8316A4DA; Tue, 15 Aug 2006 16:02:36 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from server.baldwin.cx (66-23-211-162.clients.speedfactory.net [66.23.211.162]) by mx1.FreeBSD.org (Postfix) with ESMTP id 663EC43D68; Tue, 15 Aug 2006 16:02:35 +0000 (GMT) (envelope-from jhb@freebsd.org) Received: from localhost.corp.yahoo.com (john@localhost [127.0.0.1]) (authenticated bits=0) by server.baldwin.cx (8.13.6/8.13.6) with ESMTP id k7FG2Sbt028481; Tue, 15 Aug 2006 12:02:28 -0400 (EDT) (envelope-from jhb@freebsd.org) From: John Baldwin To: Divacky Roman Date: Tue, 15 Aug 2006 12:01:26 -0400 User-Agent: KMail/1.9.1 References: <200608151407.k7FE7Lj5095567@repoman.freebsd.org> <200608151127.54902.jhb@freebsd.org> <20060815154956.GB60482@stud.fit.vutbr.cz> In-Reply-To: <20060815154956.GB60482@stud.fit.vutbr.cz> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200608151201.27169.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]); Tue, 15 Aug 2006 12:02:28 -0400 (EDT) X-Virus-Scanned: ClamAV 0.88.3/1664/Tue Aug 15 10:28:31 2006 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: Roman Divacky , Perforce Change Reviews Subject: Re: PERFORCE change 104029 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 15 Aug 2006 16:02:36 -0000 On Tuesday 15 August 2006 11:49, Divacky Roman wrote: > On Tue, Aug 15, 2006 at 11:27:54AM -0400, John Baldwin wrote: > > On Tuesday 15 August 2006 10:07, Roman Divacky wrote: > > > http://perforce.freebsd.org/chv.cgi?CH=104029 > > > > > > Change 104029 by rdivacky@rdivacky_witten on 2006/08/15 14:06:41 > > > > > > Protect against racing concurent creation in futex_get() > > > > > > Pointed out by: jhb > > > > > > Affected files ... > > > > > > .. //depot/projects/soc2006/rdivacky_linuxolator/compat/linux/linux_futex.c#24 > > edit > > > > > > Differences ... > > > > > > > > ==== //depot/projects/soc2006/rdivacky_linuxolator/compat/linux/linux_futex.c#24 > > (text+ko) ==== > > > > > > @@ -342,13 +342,13 @@ > > > if (locked == FUTEX_UNLOCKED) > > > FUTEX_UNLOCK; > > > > > > + if (locked == FUTEX_UNLOCKED) > > > + FUTEX_LOCK; > > > > Looks like you should collapse the lock/unlock. However, it's probably best > > to use mutexes instead of sx locks, and to instead do something like this: > > the lock here IS a mutex... > > > lock(); > > if (item in list) { > > item->ref++; > > unlock(); > > return (item); > > } > > unlock(); > > > > new_item = new_item(); > > > > lock(); > > if (item in list) { > > item->ref++; > > unlock(); > > free(new_item); > > return (item); > > } > > insert new_item > > new_item->ref++; > > unlock(); > > return (new_item) > > isnt this exactly what I am doing in later revision? No, you aren't doing the second 'if (item in list)' test to see if some other thread already added a futex for that uaddr and if so free the one you just created and return the one in the list instead. -- John Baldwin