Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Changing timer interrupt rate / vm-ware guest dual boot
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware
View previous topic :: View next topic  
Author Message
kimmie
Guru
Guru


Joined: 08 Sep 2004
Posts: 531
Location: Australia

PostPosted: Fri Apr 15, 2005 2:49 am    Post subject: Changing timer interrupt rate / vm-ware guest dual boot Reply with quote

I'm settting up a 2005.0 / gentoo-sources system under vm-ware workstation 5.0 at the moment. I'm using vm-ware to build/test/snapshot the system and then moving it to a real machine when I'm happy with the changes. I'll continue to do this as the destination machine is a file server which has to be up most of the time. The destination machine is a dual-cpu, so I use an SMP kernel, but when running under vm-ware, only one cpu is present.

Problem is, under vm-ware, the guest machine loses time. According to VMWare docs, this happens because the virtual machine can't keep up with the 1000Hz timer interrupt rate:

Quote:
Linux guest operating systems keep time by counting timer interrupts. Unpatched 2.4 and earlier kernels program the virtual system timer to request clock interrupts at 100Hz (100 interrupts per second). 2.6 kernels, on the other hand, request interrupts at 1000Hz — ten times as often. Some 2.4 kernels modified by distribution vendors to contain 2.6 features also request 1000Hz interrupts, or in some cases, interrupts at other rates, such as 512Hz.

Furthermore, an SMP-capable Linux kernel requests additional timer interrupts from the virtual local APIC timer. An SMP-capable kernel running on a one-CPU system generates twice as many total timer interrupts as the corresponding UP kernel, while such a kernel running on a two-CPU system requests three times as many. In general, an SMP-capable kernel running on <n> CPUs requests <n+1> times as many interrupts per second as a UP kernel. For example, an unmodified 2.6 Linux kernel running on a two-CPU virtual machine requests a total of 3000 clock interrupts per second.

When a guest asks for more than 1000 clock interrupts per second, it can be difficult for the virtual machine to keep up, especially if other applications are running on the host at the same time. This can cause the clock in the guest operating system to fall so far behind real time that it is unable to catch up. The overhead of delivering so many virtual clock interrupts can also hurt guest performance and increase host CPU consumption.


According to this, my guest is asking the VM for 2000Hz. The workaround (which I've tested, it works) is to patch the kernel to use a lower interrupt rate:
Quote:
recompile your kernel with a lower timer interrupt rate. 100Hz is adequate for most applications in a Linux guest. See the documentation for your Linux distribution for detailed instructions on how to build and run a custom kernel. Before recompiling the guest kernel, locate the following line in /usr/src/linux-2.6/include/asm-i386/param.h:
#define HZ 1000

Change the value of HZ to 100:
#define HZ 100

Ok, so I can fix the problem when running as a guest. What I'm worried about is how this will impact the real installation, the file server....

:?: Is it safe to change the timer interrupt rate under a 2.6 kernel?
:?: What effects might this have (other than the desired one)?
:?: Can I use rates other than 100 or 1000Hz?

Oops! It only just now occured to me :? that I could just use an unpatched kernel on the file server, and a patched kernel on the guest. But still, now that I've typed in the post, I'm still curious....
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum