From owner-svn-src-all@FreeBSD.ORG Wed Mar 4 18:24:53 2015 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id DF75BAC5; Wed, 4 Mar 2015 18:24:53 +0000 (UTC) Received: from mail-ig0-x234.google.com (mail-ig0-x234.google.com [IPv6:2607:f8b0:4001:c05::234]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id A41FDCA3; Wed, 4 Mar 2015 18:24:53 +0000 (UTC) Received: by igdh15 with SMTP id h15so38850338igd.4; Wed, 04 Mar 2015 10:24:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=rGNZzVsUWQPVZK7QyqlwuHdIBZjJ1FUtja8nXhu52aM=; b=bwpvyfMlaOPzWZl/ikWcAiBm03r/+0jUGQOzxAP9XSDg8s0ivV1Y931Qbls+oyD8o1 V5v4FMpK5r399hIEBA6SmvWgctQIft+LaEOs+IqeL4BvtCvV8V8IpdUxLMHuyeXHe5Av 7H23idxkQwIVxN4NRcsBXAjRIOOnlAIKmQ030HcxgOIoNkD8IKDaacGheSkzQ86qS+SB 40m2injyIuyl/VIymtVgqeIInrTekZftjY6VTD9iZamedqsfWod5aV9SaM39QLw9VjNK 8JNgT9xNIp0mkvUzxDGka6WA2SegRJEqXuDYF0729nsHsp9fa6uc/TYRPUWOLQJPr/oP t1Bg== MIME-Version: 1.0 X-Received: by 10.107.8.213 with SMTP id h82mr13150263ioi.89.1425493492907; Wed, 04 Mar 2015 10:24:52 -0800 (PST) Received: by 10.107.156.75 with HTTP; Wed, 4 Mar 2015 10:24:52 -0800 (PST) In-Reply-To: <201502040826.t148Qi8W096721@svn.freebsd.org> References: <201502040826.t148Qi8W096721@svn.freebsd.org> Date: Wed, 4 Mar 2015 13:24:52 -0500 Message-ID: Subject: Re: svn commit: r278183 - in head/sys: amd64/include conf dev/xen/timer i386/include i386/xen x86/include x86/x86 From: Ryan Stone To: Bryan Venteicher Content-Type: text/plain; charset=UTF-8 Cc: "svn-src-head@freebsd.org" , "svn-src-all@freebsd.org" , "src-committers@freebsd.org" X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.18-1 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, 04 Mar 2015 18:24:54 -0000 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