WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

Re: [Xen-devel] RE: rdtsc: correctness vs performance on Xen (and KVM?)

To: Jan Beulich <JBeulich@xxxxxxxxxx>
Subject: Re: [Xen-devel] RE: rdtsc: correctness vs performance on Xen (and KVM?)
From: Jeremy Fitzhardinge <jeremy@xxxxxxxx>
Date: Fri, 04 Sep 2009 08:44:38 -0700
Cc: Dan Magenheimer <dan.magenheimer@xxxxxxxxxx>, "Xen-Devel \(E-mail\)" <xen-devel@xxxxxxxxxxxxxxxxxxx>, Keir Fraser <keir.fraser@xxxxxxxxxxxxx>, Alan Cox <alan@xxxxxxxxxxxxxxxxxxx>
Delivery-date: Fri, 04 Sep 2009 08:45:01 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
In-reply-to: <4AA0DBB702000078000136B1@xxxxxxxxxxxxxxxxxx>
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
References: <C6C4A72F.13BDD%keir.fraser@xxxxxxxxxxxxx> <4A9EEC3D.4070402@xxxxxxxx> <4A9F9917020000780001320C@xxxxxxxxxxxxxxxxxx> <4A9FFD04.4020908@xxxxxxxx> <4AA0DBB702000078000136B1@xxxxxxxxxxxxxxxxxx>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.1) Gecko/20090814 Fedora/3.0-2.6.b3.fc11 Lightning/1.0pre Thunderbird/3.0b3
On 09/04/09 00:19, Jan Beulich wrote:
> struct pvclock_vcpu_time_info has a 'pad0' field afaics.
>   

Ah, yes, I was looking at wall_clock.  We could claim the padding for
"local version", but it would require a 64-bit unpreemptible read, which
is awkward on 32-bit.

>> We only need to worry about Xen preempting a kernel update rather than
>> the other way around.  I think it ends up being very simple:
>>
>> void ctxtsw_update_pvclock(struct pvclock_vcpu_time_info *pvclock)
>> {
>>      BUG_ON(preemptible());  /* Switching VCPUs would be a disaster */
>>
>>      /*
>>       * We just need to update version; if Xen did it behind our back, then
>>       * that's OK with us.  We should never see an update-in-progress 
>> because Xen
>>       * will always completely update the pvclock structure before 
>> rescheduling the
>>       * VCPU, so version should always be even.  We don't care if Xen 
>> updates the
>>       * timing parameters here because we're not in the middle of a clock 
>> read.
>>       * Usermode might be in the middle of a read, but all it needs to see 
>> is version
>>       * changing to a new even number, even if this add gets preempted by 
>> Xen in
>>       * the middle.  There are no cross-PCPU writes going on, so we don't 
>> need to
>>       * worry about bus-level atomicity.
>>       */
>>      pvclock->version += 2;
>> }
>>     
> No, that won't work as-is, because you can't guarantee the compiler to
> translate this to and add-with-memory-operand. While avoiding a bus
> lock here indeed seems possible (as long as it is clear that user mode will
> never be interested in reading other than the instance of the CPU it's
> currently running on), you won't get away without inline assembly.
>   

I don't think that matters, even if the compiler generates a preemptable
sequence: the end result will always be a changed version number.  Even
if we end up rolling back the version to a smaller number (because Xen
did multiple pvclock updates while it preempted us) nothing will get
confused because nothing observed those intermediate versions.  Xen
itself doesn't care about the version number (its effectively
write-only).  KVM is the same.

    J

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel

<Prev in Thread] Current Thread [Next in Thread>