From mboxrd@z Thu Jan 1 00:00:00 1970 From: Paolo Bonzini Subject: Re: rdtsc() in kvm-unit-tests on x86 Date: Mon, 10 Aug 2015 11:02:16 +0200 Message-ID: <55C86898.3000003@redhat.com> References: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Cc: Christoffer Dall , Shih-Wei Li To: Jintack Lim , kvm@vger.kernel.org Return-path: Received: from mail-wi0-f171.google.com ([209.85.212.171]:37486 "EHLO mail-wi0-f171.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932141AbbHJJCV (ORCPT ); Mon, 10 Aug 2015 05:02:21 -0400 Received: by wibhh20 with SMTP id hh20so141116284wib.0 for ; Mon, 10 Aug 2015 02:02:19 -0700 (PDT) In-Reply-To: Sender: kvm-owner@vger.kernel.org List-ID: On 07/08/2015 21:19, Jintack Lim wrote: > Hi all, > > While I was looking at rdtsc() code in kvm-unit-tests (e.g. x86/vmexit.c), > I was getting curious that out-of-order execution on the processor > may make rdtsc() executed not in the place we expect. > > Referring to this document from intel, > http://www.intel.com/content/www/us/en/embedded/training/ia-32-ia-64-benchmark-code-execution-paper.html > they suggested to use rdtscp instruction and other techniques to > serialize reading tsc register. > > I wonder how the serialization is achieved when using rdtsc() in > kvm-unit-tests code. > Or, maybe the serialization is not necessary for some reason? kvm-unit-tests executes the instruction thousands of times, so any error due to lack of serialization is lost in the noise. Paolo