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] [PATCH] x86/hvm/pmtimer: improving scalability of virtua

To: Tim Deegan <Tim.Deegan@xxxxxxxxxx>, Song Xiang <classicxsong@xxxxxxxxx>
Subject: Re: [Xen-devel] [PATCH] x86/hvm/pmtimer: improving scalability of virtual time update on Xen 4.0.0
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
Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:sender:user-agent:date :subject:from:to:cc:message-id:thread-topic:thread-index:in-reply-to :mime-version:content-type:content-transfer-encoding; bh=Y+NtfmubsKNX9VZ8Ik1A7qLGKJpKaf5qGx+c6n2DAWg=; b=H0u9SzVXlwPVIJZ9/meVPHz6jf5/FkUzac2ePQQko4/RbO3safcn+/d8PJ/9no3D8h xe2Mn2c+0qKhYEb7xMhGX0qmpx6rWR/yvJiH2yBfGSf01wFRUw6lJczXUcgexeDB1UWH r7zRQm/JaUiO14+DrKupPZKKJI21xNoqjI+l8=
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=
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
In-reply-to: <20101117144745.GG21112@xxxxxxxxxxxxxxxxxxxxxxx>
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>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
Thread-index: AcuGbien/0MbV1RnH0Ktagw5DHIVVw==
Thread-topic: [Xen-devel] [PATCH] x86/hvm/pmtimer: improving scalability of virtual time update on Xen 4.0.0
User-agent: Microsoft-Entourage/12.27.0.100910
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