From: "Jan Beulich" Subject: Re: A patch to xen/arch/x86/hvm/pmtimer.c for both Xen 4.0.0 and Xen 4.0.1 to improve HVM scalability Date: Mon, 15 Nov 2010 08:28:49 +0000 Message-ID: <4CE0FD5102000078000222D9@vpn.id2.novell.com> References: <1208B612-80C6-4009-ACEB-1D4E99D0FA7E@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Return-path: In-Reply-To: <1208B612-80C6-4009-ACEB-1D4E99D0FA7E@gmail.com> Content-Disposition: inline List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: Song Xiang Cc: xen-devel@lists.xensource.com, Haibo Chen List-Id: xen-devel@lists.xenproject.org >>> On 13.11.10 at 11:56, Song Xiang wrote: > --- arch/x86/hvm/pmtimer.c (revision 4651) > +++ arch/x86/hvm/pmtimer.c (working copy) > @@ -206,10 +206,17 @@ >=20 > if ( dir =3D=3D IOREQ_READ ) > { > - spin_lock(&s->lock); > - pmt_update_time(s); > - *val =3D s->pm.tmr_val; > - spin_unlock(&s->lock); > + /* > + * if acquired the PMTState lock then update the time > + * else other vcpu is updating it ,it should be up to date. > + */ > + if (spin_trylock(&s->lock)) { > + pmt_update_time(s); > + *val =3D s->pm.tmr_val; > + spin_unlock(&s->lock); > + } > + else > + *val =3D (s->pm.tmr_val & TMR_VAL_MASK); > return X86EMUL_OKAY; > } I don't think this is correct: While it seems reasonable to skip the global update, returning potentially stale time to the guest isn't. You'd need to mimic what pmt_update_time() does, just without updating global state. That, however, isn't going to be that trivial as you need to also read global state for doing the calculations. Jan