The problem appears to be due to cpu frequency scaling. The article Host Power Management Causes Problems with Guest Timekeeping on Linux Hosts has details on solving the problem.
You have to edit a config file to specify your max cpu frequency. You can find it out in a couple of ways:
$ cat /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_max_freq
1833000
or
$ cpufreq-info
cpufrequtils 002: cpufreq-info (C) Dominik Brodowski 2004-2006
Report errors and bugs to linux@brodo.de, please.
analyzing CPU 0:
driver: centrino
CPUs which need to switch frequency at the same time: 0
hardware limits: 1000 MHz - 1.83 GHz
available frequency steps: 1.83 GHz, 1.33 GHz, 1000 MHz
available cpufreq governors: userspace, powersave, ondemand, conservative, performance
current policy: frequency should be within 1000 MHz and 1.83 GHz.
The governor "ondemand" may decide which speed to use
within this range.
current CPU frequency is 1000 MHz.
analyzing CPU 1:
driver: centrino
CPUs which need to switch frequency at the same time: 1
hardware limits: 1000 MHz - 1.83 GHz
available frequency steps: 1.83 GHz, 1.33 GHz, 1000 MHz
available cpufreq governors: userspace, powersave, ondemand, conservative, performance
current policy: frequency should be within 1000 MHz and 1.83 GHz.
The governor "ondemand" may decide which speed to use
within this range.
current CPU frequency is 1000 MHz.
or (verified on Mac)
$ sysctl -a | grep cpufreq
hw.cpufrequency = 2400000000
hw.cpufrequency_max: 2400000000
hw.cpufrequency_min: 2400000000
hw.cpufrequency: 2400000000
Since my max CPU is 1.83 GHz, I added these lines to /etc/vmware/config:
host.cpukHz = 1830000
host.noTSC = TRUE
ptsc.noTSC = TRUE
I restarted VMware. So far, it seems to be keeping time. I think it simply stops the clock getting ahead of itself, then the VMWare Tools time synchronization ensures if it runs slow, it periodically catches up to the correct time.
29 comments:
Thanks for posting this tip. I experienced this problem with a 2GHz Core 2 Duo, and was able to fix it quickly using your instructions.
Works for me too in vmware player on Gentoo. This was causing some rather serious issues for my WinXP guest OS. Thanks for this!
The other way to work around it is to set the performance governor before you start VMware. But this might munch a lot of CPU and if you're trying to save battery power...
This is something that VMware could easily fix; the CPU speeds are easy enough to grab out of /proc. But they haven't bothered to do it. I can't fathom why.
Thanks for your tip.
It was very helpful!
I whant say that is better a "cat /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_max_freq" to view the max cpu clock instead use cpufreq-info.
Bye.
I am impressed. Why did it take so much searching for such a simple solution to a problem that should not exist in the first place?
I can report that it works on a dell latitude d610 with opensuse and windows-2000 guest (not the cpu-freq, but the cat /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_max_freq)
Thank you very much!
That proc location does not exist in all 2.6 kernels ... for example in 2.6.9-67.EL in RHEL and CentOS, it is not there.
You can get the info from /proc/cpuinfo though.
This is probably why they are not pulling it manually.
thanks a lot.... it just works fine !!!!
Thank you so much for posting this!! I should have googled it months and months ago when I first noticed the problem.
Spend a whole afternoon trying to nail this down. Your post was what solved it for me so I could go home!! Many thanks.
Quite impressive. I recently switched from an Intel Celeron 2.8 GHz to an AMD Athlon 64 4000+, running VMWare WS 6.0.2 on Ubuntu 7.10 and was completely stumped, since everything worked on the Celeron. This fix took about 10 seconds and the timer is right on track again. Bravo.
Thanks for this. Searched a lot to fix this issue incl. vmware support without success until now.
Beware with dual cores, xeons and just about anything that's not single processor.
In these the best solution is to fix the processors's speeds to the maximum allowed by hardware in ALL processors reported by linux. Remember that a Xeon is really 2 processors. So, for a 3.4Ghz Xeon you'll do this BEFORE starting vmware server:
/usr/bin/cpufreq-set -c 0 -d 3400000 -u 3400000 -g performance
/usr/bin/cpufreq-set -c 1 -d 3400000 -u 3400000 -g performance
this tell's linux that the xeon's minimum speed=max speed=3.4Ghz. 'c' is the processor # reported by cpufreq-info -d and -u, min and max speeds in KHz, and -g the policy for cpuspeed (for servers 'performance' is advisable)
This won't do any powersaving through the processor load, at all, but in a vmware server machine that shouln't be a issue.
Alex
i still can't believe that a blog post thats older than a year solved my problem. I didn't find a solution after days of looking through vmwares own docs.
thanks alot for sharing
Aaahhhh...! VMware host on openSuse 10.3 x86_64 is usable at last! Thank you SO much!
I found this blog entry and thought it'd be the answer to my prayers. Unfortunately it isn't, as when I add the lines to /etc/vmware/config and stop/start vmware, it insists its not been configured, and when I run vmware-config as required it removes the lines. sigh.
On my VMs, on a multi-core system, adding these settings helped - a lot. But not completely. So I tried lying to it and told it the CPU was 2.5GHz (2500000) instead of 2.394.
Now I see it losing a second or two per minute, which is corrected more than once per minute. That's if I am seeing this correctly...
I read through some vmware documentation and it recommended turning off APM in the host - set the right kernel options in grub or lilo, and this has fixed it.
As ever, the host keeps perfect (ntp) time, and is very close to the hardware clock (use "hwclock" command). With vmware tools in the WindowsXP guest, its clock matches the host perfectly!
I also installed a tiny (damnsmalllinux) vm to see if it was a problem with windows as guest, and it used to gain time pretty rapidly, it's now much more stable when free-running, sufficiently that ntp would keep it in check.
As I understand it, the vmware tools clock sync is designed mainly to speed up the guest's clock when it missed clock interrupts due to the host being busy, which makes sense to me.
p.s http://www.damnsmalllinux.org is a very nice tiny linux, will fit onto a business card CD, or small USB stick, or ideal as a trivial virtual machine for testing.
thanks.. this caused my VOIP clock to run so fast, I didn't notice it at first.
On my core2duo with gentoo kernel 2.6.25-r7 I have the problem that the guest clock is nearly stoped when the host cpu is idle. If there is load on the host the clock is running at normal speed. Has someone any idea?
vmware tools should allow a guest with a slow-running clock to catch up, but as far as I can tell it won't slow it down.
if using vmware tools doesn't work, then you'll have to disable idling in the host and probably APM too.
Just wanted to say thanks for posting this.
VMware had been running faultlessly for over a year. It randomly exhibited this peculiar behavour -- much to the disgust of the Windows Server 2003 guest OS (unstartable services and "broken" Active Directory).
I do not have CPU frequency scaling enabled in the BIOS or the kernel, but the 3 appropriate lines in /etc/vmware/config sorted it first time.
Madness.
Thanks again.
I finally got my guest clock to slow down. I tried changing the power settings in the bios. I tried turning off windows clock sync. I tried a number of different solutions offered and I could not get the clock from running ahead. Until...I simply allocated 1 cpu to the guest vm and the clock works perfectly. Here is my configuration.
Dell latitude 620.
2 GB of Ram
Ubuntu Workstation 8.04 Host
VMWare workstaion 6.04
Windows XP Guest
Works like a charm!
Definitely the best fix ever on this topic
Thanks so much for this. I was running a cron job to set the time every hour and spent ages installing the VMWare Tools on my Centos 5.1 guest, only to discover VMWare Tools can only set the clock forward. VMWare Kbase article 1591 says to use cat /proc/cpuinfo to find the CPU Mhz by looking for the "cpu MHz" setting. However, on my dual core 2.13 Ghz IBM server that gave me 1600000 KHz whereas cat /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_max_freq gave me 2133000 KHz. The 2.13 GHz setting seems to have worked.
when i run this command on my box
cat /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_max_freq
cat: /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_max_freq: No such file or directory
file not found.
Well, I'm no longer on a Linux box. However, this works on a mac:
$ sysctl -a | grep cpufreq
hw.cpufrequency = 2400000000
hw.cpufrequency_max: 2400000000
hw.cpufrequency_min: 2400000000
hw.cpufrequency: 2400000000
so you might give it a try
I just wanted to let everyone know that this tip also works on VMWare server 1.0.8. I was having the problem of my WinXP guest (Ubuntu 8.10 host) running like it was given a dose of speed. I applied the code to my /etc/vmware/config file and all was right with the world. Thanks again for the great post!
Thanks for the info. Also worked for me with host running Debian Lenny and vm machine with Cent OS.
Post a Comment