From: Jeremy Fitzhardinge Subject: Re: Re: [PATCH 3/5] x86/pvclock: add vsyscall implementation Date: Fri, 09 Oct 2009 17:24:30 -0700 Message-ID: <4ACFD43E.6000506@goop.org> References: <1254790211-15416-1-git-send-email-jeremy.fitzhardinge@citrix.com> <1254790211-15416-4-git-send-email-jeremy.fitzhardinge@citrix.com> <4ACB0833.2050203@redhat.com> <4ACB9074.1000804@goop.org> <4ACC6C9C.7080707@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <4ACC6C9C.7080707@redhat.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: Avi Kivity Cc: Dan Magenheimer , Jeremy Fitzhardinge , kurt.hackel@oracle.com, the arch/x86 maintainers , Linux Kernel Mailing List , Glauber de Oliveira Costa , Xen-devel , Keir Fraser , Zach Brown , Chris Mason List-Id: xen-devel@lists.xenproject.org On 10/07/09 03:25, Avi Kivity wrote: > def try_pvclock_vtime(): > tsc, p0 = rdtscp() > v0 = pvclock[p0].version > tsc, p = rdtscp() > t = pvclock_time(pvclock[p], tsc) > if p != p0 or pvclock[p].version != v0: > raise Exception("Processor or timebased change under our feet") > return t This doesn't quite work. If we end up migrating some time after the first rdtscp, then the accesses to pvclock[] will be cross-cpu. Since we don't made any strong SMP memory ordering guarantees on updating the structure, the snapshot isn't guaranteed to be consistent even if we re-check the version at the end. So to use rdtscp we need to either redefine the update of pvclock_vcpu_time_info to be SMP-safe, or keep the additional migration check. J