From mboxrd@z Thu Jan 1 00:00:00 1970 From: Haozhong Zhang Subject: [PATCH 01/13] x86/time.c: Use system time to calculate elapsed_nsec in tsc_get_info() Date: Mon, 28 Sep 2015 15:13:46 +0800 Message-ID: <1443424438-13404-2-git-send-email-haozhong.zhang@intel.com> References: <1443424438-13404-1-git-send-email-haozhong.zhang@intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1443424438-13404-1-git-send-email-haozhong.zhang@intel.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: xen-devel@lists.xen.org Cc: Haozhong Zhang , Kevin Tian , Wei Liu , Ian Campbell , Stefano Stabellini , Jun Nakajima , Andrew Cooper , Ian Jackson , Aravind Gopalakrishnan , Jan Beulich , Keir Fraser , Boris Ostrovsky , Suravee Suthikulpanit List-Id: xen-devel@lists.xenproject.org When the TSC mode of a domain is TSC_MODE_DEFAULT and no TSC emulation is used, the existing tsc_get_info() calculates elapsed_nsec by scaling the host TSC with a ratio between guest TSC rate and nanoseconds. However, the result will be incorrect if the guest TSC rate differs from the host TSC rate. This patch fixes this problem by using the system time as elapsed_nsec. Signed-off-by: Haozhong Zhang --- xen/arch/x86/time.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/xen/arch/x86/time.c b/xen/arch/x86/time.c index bbb7e6c..a345efb 100644 --- a/xen/arch/x86/time.c +++ b/xen/arch/x86/time.c @@ -1868,8 +1868,7 @@ void tsc_get_info(struct domain *d, uint32_t *tsc_mode, *gtsc_khz = d->arch.tsc_khz; break; } - tsc = rdtsc(); - *elapsed_nsec = scale_delta(tsc, &d->arch.vtsc_to_ns); + *elapsed_nsec = get_s_time(); *gtsc_khz = cpu_khz; break; case TSC_MODE_PVRDTSCP: -- 2.4.8