[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Xen-devel] [PATCH] x86/hvm/pmtimer: improving scalability of virtual time update on Xen 4.0.0


  • To: Tim Deegan <Tim.Deegan@xxxxxxxxxx>, Song Xiang <classicxsong@xxxxxxxxx>
  • From: Keir Fraser <keir@xxxxxxx>
  • Date: Wed, 17 Nov 2010 15:43:18 +0000
  • Cc: "xen-devel@xxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxx>, Haibo Chen <oldseawave@xxxxxxxxx>, Jan Beulich <JBeulich@xxxxxxxxxx>
  • Delivery-date: Wed, 17 Nov 2010 07:44:04 -0800
  • Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=sender:user-agent:date:subject:from:to:cc:message-id:thread-topic :thread-index:in-reply-to:mime-version:content-type :content-transfer-encoding; b=KB6sMnFB8GmthQBULh/Uyn215ChsTq4BmayctIQGQXcs8pclnFKKgM9bGv5VMIr0No sKZgjQlW7JMjev8lfcilzOK0sbhiJ12I19s2JEAF2wXnkkQ6Ux8spL3OWXROLtTixEfh 81WW6t/xprS/vDFuQvQNB9j88TWmvPSVl/laM=
  • List-id: Xen developer discussion <xen-devel.lists.xensource.com>
  • Thread-index: AcuGbien/0MbV1RnH0Ktagw5DHIVVw==
  • Thread-topic: [Xen-devel] [PATCH] x86/hvm/pmtimer: improving scalability of virtual time update on Xen 4.0.0

On 17/11/2010 14:47, "Tim Deegan" <Tim.Deegan@xxxxxxxxxx> wrote:

>>      /* Update the timer */
>>      curr_gtime = hvm_get_guest_time(s->vcpu);
>> -    s->pm.tmr_val += ((curr_gtime - s->last_gtime) * s->scale) >> 32;
>> +    *(volatile uint32_t *)&s->pm.tmr_val = s->pm.tmr_val + (((curr_gtime -
>> s->last_gtime) * s->scale) >> 32);
>>      s->pm.tmr_val &= TMR_VAL_MASK;
>>      s->last_gtime = curr_gtime;
> 
> That doesn't make it an atomic update!  The variable is still written
> to twice. :)  You need to calculate the new tmr_val in a scratch
> variable, and then write it back once at the end of the function.
> (And no 'volatile' wll be necessary).

Can we be sure the compiler will emit only one write to the shared field
unless we use volatile? Seems to safer and more explicit to keep it, to me
(like atomic_set()). Otherwise compiler could elide the local variable and
continue to do the whole composite operation on the shared field?

Of course I agree about calculating the value to store in a local variabne
and then write the result in one operation.

 -- Keir



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


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.