Bug 508009

Summary: Guest TSC clocksource is unusable in AMD processors.
Product: Red Hat Enterprise Linux 5 Reporter: jason wang <jasowang>
Component: kvmAssignee: Eduardo Habkost <ehabkost>
Status: CLOSED CANTFIX QA Contact: Lawrence Lim <llim>
Severity: medium Docs Contact:
Priority: low    
Version: 5.4CC: akong, rlerch, szhou, tburke, tools-bugs, virt-maint, ykaul
Target Milestone: rc   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Guests cannot relay on the tsc clock since it is not stable. Windows guest can use the pmtimer clock by changing boot.ini configuration: http://support.microsoft.com/kb/833721
Story Points: ---
Clone Of: Environment:
Last Closed: 2009-07-21 08:56:30 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 513501    
Attachments:
Description Flags
Device message of guests. none

Description jason wang 2009-06-25 06:21:19 UTC
Description of problem:

TSC clocksource is unusable in AMD processors. When booting Fedora-10 using kernel parameters "clock=tsc clocksource=tsc", "Clocksource tsc unstable (delta = 13189211949 ns)" could be found in the dmesg of guest.

Executes the following simple scripts:
while true; do date; done
could get the following output:
Thu Jun 25 00:24:06 EDT 2009
Thu Jun 25 00:23:52 EDT 2009
Thu Jun 25 00:24:06 EDT 2009
Thu Jun 25 00:23:52 EDT 2009
Thu Jun 25 00:23:52 EDT 2009
Thu Jun 25 00:24:06 EDT 2009
Thu Jun 25 00:24:06 EDT 2009
Thu Jun 25 00:24:06 EDT 2009

Version-Release number of selected component (if applicable):
Guest Operation System: 2.6.27.5-117.fc10.i686 
KVM Version : kvm-83-77.el5
Host Operation System: Linux amd-5600-4-1 2.6.18-152.el5 #1 SMP Wed Jun 3 18:57:00 EDT 2009 x86_64 x86_64 x86_64 GNU/Linux
Host processors: AMD Athlon(tm) 64 X2 Dual Core Processor 5600+

How reproducible:
100%

Steps to Reproduce:
1. Boot the fedora kernel with the parameters clock=tsc clocksource=tsc on AMD host
2. execute the simple scripts: while true; do date; done
3. dmesg
  
Actual results:
1 Clocksource tsc unstable (delta = 13189211949 ns) is found in the dmesg
2 Strange output:
...
Thu Jun 25 00:24:06 EDT 2009
Thu Jun 25 00:23:52 EDT 2009
Thu Jun 25 00:24:06 EDT 2009
Thu Jun 25 00:23:52 EDT 2009
Thu Jun 25 00:23:52 EDT 2009
Thu Jun 25 00:24:06 EDT 2009
Thu Jun 25 00:24:06 EDT 2009
Thu Jun 25 00:24:06 EDT 2009
...
3 System is usual unresponsive for short seconds

Expected results:
1 TSC clocksource should be usable
2 The date value returned should keep monotonic
3 System should keep normal latency

Additional info:
1 qemu-kvm cmdline:
/usr/bin/qemu-kvm -no-hpet -usbdevice tablet -rtc-td-hack -drive file=Fedora-10-32.0.qcow2,media=disk,if=ide,cache=off,index=0 -m 1024 -vnc :0 -smp 2 -net nic,vlan=0,model=e1000,macaddr=00:11:22:33:55:44 -net tap,vlan=0,script=/etc/qemu-ifup-switch

2 I've tested Intel processors, no problems found. TSC clocksourc
e is usable.

3 kvm_stat
kvm statistics

 efer_reload                  0       0
 exits                 10689128    5001
 fpu_reload               30149       4
 halt_exits              441721    2067
 halt_wakeup              19804      97
 host_state_reload      1281513    2613
 hypercalls             3912248       0
 insn_emulation         2882280    2814
 insn_emulation_fail          0       0
 invlpg                 1462979       0
 io_exits                578034      54
 irq_exits               450768       5
 irq_injections         1037355    2125
 irq_window                   0       0
 kvm_request_irq              0       0
 largepages                   0       0
 mmio_exits              258898     490
 mmu_cache_miss          251048       0
 mmu_flooded             203815       0
 mmu_pde_zapped          115824       0
 mmu_pte_updated        3499102       0
 mmu_pte_write          4209397       0

Comment 1 jason wang 2009-06-25 06:22:32 UTC
Created attachment 349332 [details]
Device message of guests.

Comment 3 jason wang 2009-07-09 03:01:44 UTC
Also notice kvm could not pass the monitonic_time test:
Host info:
recipe1.case_id  	226
recipe1.snapshot 	no
recipe1.nicmodel 	e1000
recipe1.ksm 	1
recipe1.network 	bridge
recipe1.guestname 	Linux
recipe1.platform 	all
recipe1.category 	acceptance_loop
recipe1.hosttype 	big
recipe1.driveformat 	ide
recipe1.imageformat 	qcow2
Host IP Address: 	10.66.83.191
Host CPU Model: 	Intel(R) Xeon(R) CPU E5310 @ 1.60GHz
Host CPU Vendor: 	GenuineIntel
CPU numbers: 	8
Disk type: 	sda
Host KVM Version: 	kvm-83-83.el5
Memory: 	32GB
Host OS: 	Red Hat Enterprise Linux Server release 5.4 Beta (Tikanga)
Output of uname: 	Linux intel-5310-32-1 2.6.18-156.el5 #1 SMP Mon Jun 29 18:16:54 EDT 2009 x86_64 x86_64 x86_64 GNU/Linux
host_vdsm_version 	package vdsm is not installed 

20090708-192048 RHEL-Server-5.3.64.autotest.monotonic_time: Running test 'monotonic_time'...
20090708-192049 RHEL-Server-5.3.64.autotest.monotonic_time: ---------------- Test output ----------------
20090708-192050 RHEL-Server-5.3.64.autotest.monotonic_time: ../../bin/autotest ./control
20090708-192059 RHEL-Server-5.3.64.autotest.monotonic_time: Dropping caches
20090708-192059 RHEL-Server-5.3.64.autotest.monotonic_time: Initializing the state engine.
20090708-192059 RHEL-Server-5.3.64.autotest.monotonic_time: Persistent state variable __steps now set to []
20090708-192059 RHEL-Server-5.3.64.autotest.monotonic_time: 2009-07-08 07:21:19,882 running: rm -rf /root/autotest/results/default
20090708-192102 RHEL-Server-5.3.64.autotest.monotonic_time: Symlinking init scripts
20090708-192102 RHEL-Server-5.3.64.autotest.monotonic_time: 2009-07-08 07:21:22,188 running: grep :initdefault: /etc/inittab
20090708-192102 RHEL-Server-5.3.64.autotest.monotonic_time: 2009-07-08 07:21:22,805 running: ln -sf /root/autotest/tools/autotest /etc/init.d/autotest
20090708-192102 RHEL-Server-5.3.64.autotest.monotonic_time: 2009-07-08 07:21:23,158 running: ln -sf /root/autotest/tools/autotest /etc/rc5.d/S99autotest
20090708-192108 RHEL-Server-5.3.64.autotest.monotonic_time: START	----	----	timestamp=1247052089	localtime=Jul 08 07:21:29	
20090708-192108 RHEL-Server-5.3.64.autotest.monotonic_time: Persistent state variable __group_level now set to 1
20090708-192108 RHEL-Server-5.3.64.autotest.monotonic_time: 	START	monotonic_time.gtod	monotonic_time.gtod	timestamp=1247052089	localtime=Jul 08 07:21:29	
20090708-192108 RHEL-Server-5.3.64.autotest.monotonic_time: Persistent state variable __group_level now set to 2
20090708-192108 RHEL-Server-5.3.64.autotest.monotonic_time: 2009-07-08 07:21:29,180 Configuring logger for tests level
20090708-192108 RHEL-Server-5.3.64.autotest.monotonic_time: 2009-07-08 07:21:29,208 running: which gcc
20090708-192108 RHEL-Server-5.3.64.autotest.monotonic_time: /usr/bin/gcc
20090708-192108 RHEL-Server-5.3.64.autotest.monotonic_time: 2009-07-08 07:21:29,564 running: make
20090708-192109 RHEL-Server-5.3.64.autotest.monotonic_time: cc -O -std=gnu99 -Wall   -c -o time_test.o time_test.c
20090708-192118 RHEL-Server-5.3.64.autotest.monotonic_time: cc -O -std=gnu99 -Wall   -c -o cpuset.o cpuset.c
20090708-192118 RHEL-Server-5.3.64.autotest.monotonic_time: cc -O -std=gnu99 -Wall   -c -o threads.o threads.c
20090708-192118 RHEL-Server-5.3.64.autotest.monotonic_time: cc -O -std=gnu99 -Wall   -c -o logging.o logging.c
20090708-192118 RHEL-Server-5.3.64.autotest.monotonic_time: cc -static -o time_test time_test.o cpuset.o threads.o logging.o -lpthread -lrt
20090708-192122 RHEL-Server-5.3.64.autotest.monotonic_time: 2009-07-08 07:21:44,449 Test started. Number of iterations: 1
20090708-192122 RHEL-Server-5.3.64.autotest.monotonic_time: 2009-07-08 07:21:44,451 Executing iteration 1 of 1
20090708-192122 RHEL-Server-5.3.64.autotest.monotonic_time: 2009-07-08 07:21:44,451 running: /root/autotest/tests/monotonic_time/src/time_test --duration 300 gtod
20090708-192448 RHEL-Server-5.3.64.autotest.monotonic_time: results.exit_status 1
20090708-192448 RHEL-Server-5.3.64.autotest.monotonic_time: 2009-07-08 07:26:44,777 running: grep MemTotal /proc/meminfo
20090708-192448 RHEL-Server-5.3.64.autotest.monotonic_time: 2009-07-08 07:26:44,878 Configuring logger for client level
20090708-192448 RHEL-Server-5.3.64.autotest.monotonic_time: 		FAIL	monotonic_time.gtod	monotonic_time.gtod	timestamp=1247052404	localtime=Jul 08 07:26:44	FAIL: gtod-worst-warp=-2
20090708-192448 RHEL-Server-5.3.64.autotest.monotonic_time: Persistent state variable __group_level now set to 1
20090708-192448 RHEL-Server-5.3.64.autotest.monotonic_time: 	END FAIL	monotonic_time.gtod	monotonic_time.gtod	timestamp=1247052404	localtime=Jul 08 07:26:44	
20090708-192448 RHEL-Server-5.3.64.autotest.monotonic_time: Dropping caches
20090708-192448 RHEL-Server-5.3.64.autotest.monotonic_time: 2009-07-08 07:26:44,884 running: sync
20090708-192448 RHEL-Server-5.3.64.autotest.monotonic_time: 2009-07-08 07:26:44,948 running: sync
20090708-192448 RHEL-Server-5.3.64.autotest.monotonic_time: 2009-07-08 07:26:44,977 running: echo 3 > /proc/sys/vm/drop_caches
20090708-192448 RHEL-Server-5.3.64.autotest.monotonic_time: 	START	monotonic_time.clock	monotonic_time.clock	timestamp=1247052405	localtime=Jul 08 07:26:45	
20090708-192448 RHEL-Server-5.3.64.autotest.monotonic_time: Persistent state variable __group_level now set to 2
20090708-192448 RHEL-Server-5.3.64.autotest.monotonic_time: 2009-07-08 07:26:45,038 Configuring logger for tests level
20090708-192448 RHEL-Server-5.3.64.autotest.monotonic_time: 2009-07-08 07:26:45,065 running: which gcc
20090708-192448 RHEL-Server-5.3.64.autotest.monotonic_time: /usr/bin/gcc
20090708-192448 RHEL-Server-5.3.64.autotest.monotonic_time: 2009-07-08 07:26:45,218 Test started. Number of iterations: 1
20090708-192448 RHEL-Server-5.3.64.autotest.monotonic_time: 2009-07-08 07:26:45,219 Executing iteration 1 of 1
20090708-192448 RHEL-Server-5.3.64.autotest.monotonic_time: 2009-07-08 07:26:45,219 running: /root/autotest/tests/monotonic_time/src/time_test --duration 300 clock
20090708-192815 RHEL-Server-5.3.64.autotest.monotonic_time: results.exit_status 1
20090708-192815 RHEL-Server-5.3.64.autotest.monotonic_time: 2009-07-08 07:31:45,561 running: grep MemTotal /proc/meminfo
20090708-192815 RHEL-Server-5.3.64.autotest.monotonic_time: 2009-07-08 07:31:45,604 Configuring logger for client level
20090708-192815 RHEL-Server-5.3.64.autotest.monotonic_time: 		FAIL	monotonic_time.clock	monotonic_time.clock	timestamp=1247052705	localtime=Jul 08 07:31:45	FAIL: clock-worst-warp=-4000
20090708-192815 RHEL-Server-5.3.64.autotest.monotonic_time: Persistent state variable __group_level now set to 1
20090708-192815 RHEL-Server-5.3.64.autotest.monotonic_time: 	END FAIL	monotonic_time.clock	monotonic_time.clock	timestamp=1247052705	localtime=Jul 08 07:31:45	
20090708-192815 RHEL-Server-5.3.64.autotest.monotonic_time: Dropping caches
20090708-192815 RHEL-Server-5.3.64.autotest.monotonic_time: 2009-07-08 07:31:45,610 running: sync
20090708-192815 RHEL-Server-5.3.64.autotest.monotonic_time: 2009-07-08 07:31:45,649 running: sync
20090708-192815 RHEL-Server-5.3.64.autotest.monotonic_time: 2009-07-08 07:31:45,678 running: echo 3 > /proc/sys/vm/drop_caches
20090708-192815 RHEL-Server-5.3.64.autotest.monotonic_time: 	START	monotonic_time.tsc	monotonic_time.tsc	timestamp=1247052705	localtime=Jul 08 07:31:45	
20090708-192815 RHEL-Server-5.3.64.autotest.monotonic_time: Persistent state variable __group_level now set to 2
20090708-192815 RHEL-Server-5.3.64.autotest.monotonic_time: 2009-07-08 07:31:45,735 Configuring logger for tests level
20090708-192815 RHEL-Server-5.3.64.autotest.monotonic_time: 2009-07-08 07:31:45,769 running: which gcc
20090708-192815 RHEL-Server-5.3.64.autotest.monotonic_time: /usr/bin/gcc
20090708-192815 RHEL-Server-5.3.64.autotest.monotonic_time: 2009-07-08 07:31:45,803 Test started. Number of iterations: 1
20090708-192815 RHEL-Server-5.3.64.autotest.monotonic_time: 2009-07-08 07:31:45,805 Executing iteration 1 of 1
20090708-192815 RHEL-Server-5.3.64.autotest.monotonic_time: 2009-07-08 07:31:45,806 running: /root/autotest/tests/monotonic_time/src/time_test --duration 300 tsc
20090708-193142 RHEL-Server-5.3.64.autotest.monotonic_time: results.exit_status 1
20090708-193142 RHEL-Server-5.3.64.autotest.monotonic_time: 2009-07-08 07:36:45,927 running: grep MemTotal /proc/meminfo
20090708-193142 RHEL-Server-5.3.64.autotest.monotonic_time: 2009-07-08 07:36:45,967 Configuring logger for client level
20090708-193142 RHEL-Server-5.3.64.autotest.monotonic_time: 		FAIL	monotonic_time.tsc	monotonic_time.tsc	timestamp=1247053005	localtime=Jul 08 07:36:45	FAIL: tsc-worst-warp=-16176
20090708-193142 RHEL-Server-5.3.64.autotest.monotonic_time: Persistent state variable __group_level now set to 1
20090708-193142 RHEL-Server-5.3.64.autotest.monotonic_time: 	END FAIL	monotonic_time.tsc	monotonic_time.tsc	timestamp=1247053005	localtime=Jul 08 07:36:45	
20090708-193142 RHEL-Server-5.3.64.autotest.monotonic_time: Dropping caches

Comment 4 jason wang 2009-07-09 03:02:45 UTC
The above test is running on a guest with 32GB mem and 8 vcpu.

Comment 5 Lawrence Lim 2009-07-13 08:30:40 UTC
Please confirm if this is a regression. If it is, then we should aim for 5.4 fix.

Comment 6 jason wang 2009-07-14 04:50:02 UTC
(In reply to comment #5)
> Please confirm if this is a regression. If it is, then we should aim for 5.4
> fix.  

Not a regression. Could be reproduced in 87el5,83el5,81el5,77el5,71el5

Comment 7 Lawrence Lim 2009-07-20 12:17:35 UTC
Comment from Dor:

For AMD hosts you should change the guest to use PMTIMER.
It is done through boot.ini config file in the guest:
http://support.microsoft.com/kb/833721

Comment 8 Yaniv Kaul 2009-07-20 12:25:40 UTC
(In reply to comment #7)
> Comment from Dor:
> 
> For AMD hosts you should change the guest to use PMTIMER.
> It is done through boot.ini config file in the guest:
> http://support.microsoft.com/kb/833721  

There is an AMD CPU driver update available from Windows Update that does exactly that.

Comment 10 Dor Laor 2009-07-21 08:56:30 UTC
Release note added. If any revisions are required, please set the 
"requires_release_notes" flag to "?" and edit the "Release Notes" field accordingly.
All revisions will be proofread by the Engineering Content Services team.

New Contents:
Guests cannot relay on the tsc clock since it is not stable. Windows guest can use the pmtimer clock by changing boot.ini configuration: http://support.microsoft.com/kb/833721