From owner-svn-src-all@FreeBSD.ORG Wed Nov 18 15:12:18 2009 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 014BA106566C; Wed, 18 Nov 2009 15:12:18 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from cyrus.watson.org (cyrus.watson.org [65.122.17.42]) by mx1.freebsd.org (Postfix) with ESMTP id C7CF08FC1B; Wed, 18 Nov 2009 15:12:17 +0000 (UTC) Received: from bigwig.baldwin.cx (66.111.2.69.static.nyinternet.net [66.111.2.69]) by cyrus.watson.org (Postfix) with ESMTPSA id 67FA046B53; Wed, 18 Nov 2009 10:12:17 -0500 (EST) Received: from jhbbsd.hudson-trading.com (unknown [209.249.190.8]) by bigwig.baldwin.cx (Postfix) with ESMTPA id 6F7A98A020; Wed, 18 Nov 2009 10:12:16 -0500 (EST) From: John Baldwin To: Jilles Tjoelker Date: Wed, 18 Nov 2009 08:41:54 -0500 User-Agent: KMail/1.9.7 References: <4B01E548.7040708@gmail.com> <20091117182501.GA70742@stack.nl> In-Reply-To: <20091117182501.GA70742@stack.nl> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200911180841.55183.jhb@freebsd.org> X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.0.1 (bigwig.baldwin.cx); Wed, 18 Nov 2009 10:12:16 -0500 (EST) X-Virus-Scanned: clamav-milter 0.95.1 at bigwig.baldwin.cx X-Virus-Status: Clean X-Spam-Status: No, score=-2.5 required=4.2 tests=AWL,BAYES_00,RDNS_NONE autolearn=no version=3.2.5 X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on bigwig.baldwin.cx Cc: svn-src-head@freebsd.org, Dmitry Pryanishnikov , svn-src-all@freebsd.org, src-committers@freebsd.org, Edwin Groothuis Subject: Re: svn commit: r194783 - head/lib/libc/stdtime X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 18 Nov 2009 15:12:18 -0000 On Tuesday 17 November 2009 1:25:01 pm Jilles Tjoelker wrote: > On Tue, Nov 17, 2009 at 01:50:32AM +0200, Dmitry Pryanishnikov wrote: > > > Author: edwin > > > Date: Tue Jun 23 22:28:44 2009 > > > New Revision: 194783 > > > URL: http://svn.freebsd.org/changeset/base/194783 > > > > Log: > > > Remove duplicate if-statement on gmt_is_set in gmtsub(). > > > > MFC after: 1 week > > > > Modified: > > > head/lib/libc/stdtime/localtime.c > > > This change looks like a (small?) pessimization to me: before it, > > _MUTEX_LOCK/_MUTEX_UNLOCK pair would be skipped for the case gmt_is_set > > == TRUE (all invocations except the first one), now it won't. I'm not > > sure whether this is critical here though... > > It is certainly less efficient, but the old code was (most likely) > wrong. It used an idiom known as "double checked locking", which is > incorrect in most memory models. The problem is that the store to > gmt_is_set may become visible without stores to other memory (gmtptr and > what it points to) becoming visible. That is easily fixed with a memory barrier. Just use atomic_store_rel() to set gmt_is_set at the end of the setup phase. -- John Baldwin