[Solved] High CPU utilization for linux guests
[Solved] High CPU utilization for linux guests
If you are running a linux guest, check task manager. Is the CPU load for your VirtualBox.exe at 50-100% constantly, even when idle?
I am running CentOS linux guests on a windows host. When I have them sitting idle, they were taking up 50% cpu constantly.
In the linux kernel, there is a setting called CONFIG_HZ, you can check what yours is set to by running "grep CONFIG_HZ /boot/config-<version>".
If that file doesn't exist, try /usr/src/kernels/<version>/.config
If you see it set to 1000 that is probably your issue. A friend running Ubuntu said his CONFIG_HZ was set to 100.
To solve this issue, I recompiled the kernel with two different options.
1) CONFIG_HZ = 100
2) TICKLESS enabled
Both options were in the General section at the top when running "make menuconfig"
I am not sure which change fixed it, maybe someone could try one or the other and let me know. I have a feeling setting TICKLESS overrides any CONFIG_HZ options but I'm not sure. Either way, after doing this my CPU utilization on my dual core went from constantly 50% to 0% when the VM was idle.
If you want an easy tutorial on how to recompile your kernel, check out http://www.cromwell-intl.com/unix/linux-kernel.html
I am running CentOS linux guests on a windows host. When I have them sitting idle, they were taking up 50% cpu constantly.
In the linux kernel, there is a setting called CONFIG_HZ, you can check what yours is set to by running "grep CONFIG_HZ /boot/config-<version>".
If that file doesn't exist, try /usr/src/kernels/<version>/.config
If you see it set to 1000 that is probably your issue. A friend running Ubuntu said his CONFIG_HZ was set to 100.
To solve this issue, I recompiled the kernel with two different options.
1) CONFIG_HZ = 100
2) TICKLESS enabled
Both options were in the General section at the top when running "make menuconfig"
I am not sure which change fixed it, maybe someone could try one or the other and let me know. I have a feeling setting TICKLESS overrides any CONFIG_HZ options but I'm not sure. Either way, after doing this my CPU utilization on my dual core went from constantly 50% to 0% when the VM was idle.
If you want an easy tutorial on how to recompile your kernel, check out http://www.cromwell-intl.com/unix/linux-kernel.html
-
- Volunteer
- Posts: 3572
- Joined: 28. May 2008, 08:40
- Primary OS: Ubuntu other
- VBox Version: PUEL
- Guest OSses: Ubuntu 10.04 & 11.10, both Svr&Wstn, Debian, CentOS
- Contact:
Hi Hypnoz, thanks for this. We regularly get complaints of VBox that its burning up CPU whilst the guest shows idle. It's nice to have someone realise that this is usually a guest OS tuning issue.
Read the Forum Posting Guide
Google your Q site:VirtualBox.org or search for the answer before posting.
Google your Q site:VirtualBox.org or search for the answer before posting.
Rebuilding the kernel with the 100 Hz timer fixed the CPU usage problem for my CentOS 5.2 guest, so thanks for bringing this (obvious, in hindsight) fix to light. Note for CentOS/RHEL users: you may want to follow the instructions at http://wiki.centos.org/HowTos/Custom_Kernel in order to integrate all the RedHat-specific patches for your kernel and turn it all into a nice neat RPM ready to be installed. It's CentOS-specific, but RHEL is close enough that you should be able to get it to work.
Thanks again!
Thanks again!
-
- Volunteer
- Posts: 180
- Joined: 17. May 2007, 16:02
Thank you for this post / thread
I had a similar problem in KVM and this thread came up on a google search.
FYI Centos maintains a repo with a vm kernel here http://people.centos.org/tru/kernel-vm/. Add this to /etc/yum.repos.d/CentOS-Base.repo then
FYI Centos maintains a repo with a vm kernel here http://people.centos.org/tru/kernel-vm/. Add this to /etc/yum.repos.d/CentOS-Base.repo
Code: Select all
[kernel-vm]
name = kernel-vm for vmware clock drift workaround
baseurl = http://people.centos.org/tru/kernel-vm/$releasever/RPMS/$basearch/
enabled = 1
gpgkey = http://people.centos.org/tru/RPM-GPG-KEY-CentOS-testing
gpgcheck = 1
Code: Select all
yum install kernel-vm
If is a virtual machine, is it still broken ?
-
- Posts: 4
- Joined: 30. Jul 2009, 23:01
- Primary OS: Mac OS X Leopard
- VBox Version: OSE other
- Guest OSses: Centos 5.2
Re: SOLVED: High CPU utilization for linux guests
This is golden post by bodhi.zazen , I suggest Mod make this sticky.
Centos guest will keep chugging on 100% CPU, when you install it , any kernel PAE or any other setting will not work but this kernel-vm simply kicks the gears in place and everything is butter-smooth.
Anshuman gholap.
Centos guest will keep chugging on 100% CPU, when you install it , any kernel PAE or any other setting will not work but this kernel-vm simply kicks the gears in place and everything is butter-smooth.
Anshuman gholap.
-
- Volunteer
- Posts: 1003
- Joined: 5. Sep 2008, 14:40
- Primary OS: Debian other
- VBox Version: PUEL
- Guest OSses: Solaris, Linux, Windows, OS/2, MacOSX, FreeBSD
- Contact:
Re: SOLVED: High CPU utilization for linux guests
but as of centos 5.3 kernel-vm is no longer needed, and i've always found putting "divider=10" on the grub kernel parameters sorts the regular kernel out anyway with no compilation needed, my centos 5.3 guest is using 1-3% of one of my cores when idle.anshuman wrote:Centos guest will keep chugging on 100% CPU, when you install it , any kernel PAE or any other setting will not work but this kernel-vm simply kicks the gears in place and everything is butter-smooth.
this has been sorted for months now in other threads if you search.
edit: looks like you're using windows as a host, that might be the problem then.
-
- Posts: 4
- Joined: 30. Jul 2009, 23:01
- Primary OS: Mac OS X Leopard
- VBox Version: OSE other
- Guest OSses: Centos 5.2
Re: SOLVED: High CPU utilization for linux guests
Thanks for that suggestion Sej7278, I am sorry if i woke up old thread. didnt search much actually.sej7278 wrote: but as of centos 5.3 kernel-vm is no longer needed, and i've always found putting "divider=10" on the grub kernel parameters sorts the regular kernel out anyway with no compilation needed, my centos 5.3 guest is using 1-3% of one of my cores when idle.
* I am on Mac OSx86 host (man OS on laptop).
* Got kernel updated and did that divider thing, now...with kernel-vm running previously, I didnt even notice any cpu activity when centos-guest kept idle... here with divider=10 option is normal kernel, I see constant 5-8% constant load graph when its idle... so i am wondering whats the best setting to keep it as Idle as possible.
Re: [Solved] High CPU utilization for linux guests
I've set the divider=10 grub boot setting and the CPU still jumps up and down from 3% to 12%. Is this normal? Has anyone got it lower? Should I really care all that much?
-
- Posts: 8
- Joined: 15. Sep 2009, 19:00
- Primary OS: MS Windows Vista
- VBox Version: PUEL
- Guest OSses: XP, CentOS
Re: [Solved] High CPU utilization for linux guests
I'm running Windows Vista Ultimate and today I created my first guest OS - a 32-bit CentOS 5.3 i386 guest. Virtualbox is 3.0.6.
It used 50% of my CPU power, balanced across the two cores that I have. And my CPU speed went from 26% to 100%.
I checked and CONFIG_HZ = 250 for the kernel I have.
However, I must admit that the default server installation I did left me with two kernel choices in GRUB, and maybe the config was for the XEN kernel that I wasn't using.
The kernel-vm solution solved the problem, but it seems like this is one case where 5.3 did not solve the problem.
proto
It used 50% of my CPU power, balanced across the two cores that I have. And my CPU speed went from 26% to 100%.
I checked and CONFIG_HZ = 250 for the kernel I have.
However, I must admit that the default server installation I did left me with two kernel choices in GRUB, and maybe the config was for the XEN kernel that I wasn't using.
The kernel-vm solution solved the problem, but it seems like this is one case where 5.3 did not solve the problem.
proto
Re: [Solved] High CPU utilization for linux guests
Nice fix. Working for me on Snow Leopard with VBox 3.0.6 running CentOS 5.3 64 bit.
Idling at around 10%, and my fans aren't raging any more.
Idling at around 10%, and my fans aren't raging any more.
-
- Posts: 49
- Joined: 17. Dec 2008, 10:21
- Primary OS: MS Windows XP
- VBox Version: PUEL
- Guest OSses: Windows, Fedora
Re: [Solved] High CPU utilization for linux guests
unfortunately it does not seem to work for my Fedora 10 guest on a Windows XP host.
Is there a way to confirm that kernel Tick runs with 100Hz?
Is there a way to confirm that kernel Tick runs with 100Hz?
-
- Posts: 5
- Joined: 2. Mar 2010, 22:55
- Primary OS: Mac OS X other
- VBox Version: PUEL
- Guest OSses: CentOS
Re: [Solved] High CPU utilization for linux guests
I'm also having the same issues using VBox 3.1.4 and CentOS 5.4 x86_64 on a MacBook Pro 2.53 w/4 GB of ram running OS 10.6.2. Can one of you experts give me a step by step on how to set the divider to 10 for the grub kernel? This seems to be the best approach based on this threat for a newbie to Linux like me.
Thanx in advance,
Cyrus
Thanx in advance,
Cyrus
-
- Posts: 2
- Joined: 12. Sep 2010, 13:51
- Primary OS: Mac OS X other
- VBox Version: OSE other
- Guest OSses: CentOS
Re: [Solved] High CPU utilization for linux guests
Assuming that you've installed the kernel as described by bodhi.zahzen above your /etc/grub.conf should look like this (extract of the relevant bit of the file, note that the default= line is zero-indexed):
With this configuration I see Virtualbox VM ticking over at 10-20% CPU on my MacBook Pro, previously this was pegged at 100% -- a big improvement, if still not perfect.
To add kernel parameters put them on the end of the kernel line in grub.conf, like this:
I should point out that the -vm kernel seems to not like this parameter, the output below is from dmesg. I gather that this is not required (and therefore not supported?) in RHEL > 5.3.
Code: Select all
default=0
timeout=5
splashimage=(hd0,0)/grub/splash.xpm.gz
hiddenmenu
title CentOS (2.6.18-92.1.22.el5vm)
root (hd0,0)
kernel /vmlinuz-2.6.18-92.1.22.el5vm ro root=/dev/VolGroup00/LogVol00
To add kernel parameters put them on the end of the kernel line in grub.conf, like this:
Code: Select all
kernel /vmlinuz-2.6.18-92.1.22.el5vm ro root=/dev/VolGroup00/LogVol00 divider=10
Code: Select all
Kernel command line: ro root=/dev/VolGroup00/LogVol00 divider=10
tick_divider: 10 is out of range.