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

[Xen-devel] Re: tsc_scale/cpu_khz imprecise and need fixing?

To: Dan Magenheimer <dan.magenheimer@xxxxxxxxxx>, "Xen-Devel (E-mail)" <xen-devel@xxxxxxxxxxxxxxxxxxx>
Subject: [Xen-devel] Re: tsc_scale/cpu_khz imprecise and need fixing?
From: Keir Fraser <keir.fraser@xxxxxxxxxxxxx>
Date: Thu, 29 Oct 2009 22:13:46 +0000
Cc: "Zhang, Xiantao" <xiantao.zhang@xxxxxxxxx>
Delivery-date: Thu, 29 Oct 2009 15:14:09 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
In-reply-to: <e4ebe3de-a7f2-4c37-8c87-ad96c6c19f85@default>
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: AcpY1nulT0z0pagdReWkr4j7mRPsVAADpmMM
Thread-topic: tsc_scale/cpu_khz imprecise and need fixing?
User-agent: Microsoft-Entourage/12.20.0.090605
On 29/10/2009 20:28, "Dan Magenheimer" <dan.magenheimer@xxxxxxxxxx> wrote:

> I *think* the reason is that tsc_scale, which
> I believe is set only once per processor at startup
> on machines with constant/invariant TSC, is set
> imprecisely using init_pit_and_calibrate_tsc().
> I suspect the imprecision is compounded through
> the reciprocal operation.  AND I wonder if an ill-timed
> power management event might render tsc_scale not
> just imprecise, but just plain wrong!

The 50ms calibration period may not be long enough, we could put the PIT in
square-wave mode instead and count 10 50ms periods...

However this may not improve matters since the PIT may tick at quite a
different rate than the stated frequency. A crystal can easily be 100ppm off
from what's stamped on the can. Really we should calibrate the TSC to the
platform timer that we choose to use. Perhaps we should update tsc_scale
even for invariant tsc, just to fold in extra precision after boot. E.g.,
tsc_scale = alpha*old_tsc_scale +
(1-alpha)*(new_sys_time-old_sys_time)/(new_tsc-old_tsc)
and increase alpha towards 1 over time, as we develop trust in the value of
tsc_scale. Where new/old tsc and system-time values would be across a
calibration rendezvous period.

 -- Keir



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