From owner-svn-src-head@FreeBSD.ORG Wed Mar 4 19:24:28 2015 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 883E18D9; Wed, 4 Mar 2015 19:24:28 +0000 (UTC) Received: from kib.kiev.ua (kib.kiev.ua [IPv6:2001:470:d5e7:1::1]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id E9EF33B2; Wed, 4 Mar 2015 19:24:27 +0000 (UTC) Received: from tom.home (kostik@localhost [127.0.0.1]) by kib.kiev.ua (8.14.9/8.14.9) with ESMTP id t24JOM6q005233 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Wed, 4 Mar 2015 21:24:22 +0200 (EET) (envelope-from kostikbel@gmail.com) DKIM-Filter: OpenDKIM Filter v2.9.2 kib.kiev.ua t24JOM6q005233 Received: (from kostik@localhost) by tom.home (8.14.9/8.14.9/Submit) id t24JOMSC005232; Wed, 4 Mar 2015 21:24:22 +0200 (EET) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: tom.home: kostik set sender to kostikbel@gmail.com using -f Date: Wed, 4 Mar 2015 21:24:22 +0200 From: Konstantin Belousov To: Ryan Stone Subject: Re: svn commit: r278183 - in head/sys: amd64/include conf dev/xen/timer i386/include i386/xen x86/include x86/x86 Message-ID: <20150304192421.GL2379@kib.kiev.ua> References: <201502040826.t148Qi8W096721@svn.freebsd.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.23 (2014-03-12) X-Spam-Status: No, score=-2.0 required=5.0 tests=ALL_TRUSTED,BAYES_00, DKIM_ADSP_CUSTOM_MED,FREEMAIL_FROM,NML_ADSP_CUSTOM_MED autolearn=no autolearn_force=no version=3.4.0 X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on tom.home Cc: "svn-src-head@freebsd.org" , Bryan Venteicher , "svn-src-all@freebsd.org" , "src-committers@freebsd.org" X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 04 Mar 2015 19:24:28 -0000 On Wed, Mar 04, 2015 at 01:24:52PM -0500, Ryan Stone wrote: > On Wed, Feb 4, 2015 at 3:26 AM, Bryan Venteicher wrote: > > +static void > > +pvclock_read_time_info(struct pvclock_vcpu_time_info *ti, > > + uint64_t *cycles, uint8_t *flags) > > +{ > > + uint32_t version; > > + > > + do { > > + version = ti->version; > > + rmb(); > > + *cycles = ti->system_time + pvclock_get_nsec_offset(ti); > > + *flags = ti->flags; > > + rmb(); > > + } while ((ti->version & 1) != 0 || ti->version != version); > > +} > > The Linux implementation of this does a "rdtsc_barrier();" in place of > the rmb(), and in some situations that appears to result in a full > mfence, not just an lfence (the code is macro soup so it's difficult > to understand what's happening). Are you sure that the rmb() is > enough? I believe that the concern is whether the rdtsc() itself is > allowed to be re-ordered around an lfence. > > This stack overflow answer seems to indicate the a full mfence is > necessary on AMD processors: > > http://stackoverflow.com/questions/12631856/difference-between-rdtscp-rdtsc-memory-and-cpuid-rdtsc Yes, Intel declares that lfence is enough, but for AMD the mfence should be used. See r238973/r238975 and sys/x86/x86/tsc.c.