CPU usage of a VM that runs Ubuntu

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
z0rr0
Member
Member
Posts: 64
Joined: Sun Apr 03, 2005 11:00 pm
Location: Grenoble, France
Contact:

CPU usage of a VM that runs Ubuntu

Post by z0rr0 »

Hello everyone, I am interested to measure the CPU usage of different OSs running as QEMU guests. To do so, I run the VM and then check the CPU usage of the process named "qemu" by using TOP. I did it for Ubuntu with an Apache server and I saw that the CPU usage is always more or less 10%. This value changes if I produces traffic to the Apache server. My question is how does linux ubuntu achieve to keep the CPU usage at 10% all the time? May this be related with the use of CPU scaling? As I said before, it is at 10% even when it is idle. To increment the cpu usage, I have to incress the number of http request at 100 in a windows of 60s.

Regards, Matias.
pragmatic
Posts: 15
Joined: Tue Jul 04, 2017 12:45 am

Re: CPU usage of a VM that runs Ubuntu

Post by pragmatic »

You question is somewhat ambiguous with respect to exactly what you are trying to ask. To me it would seem that 10% CPU is the nominal usage for that OS running in QEMU. In other words, it is taking 10% of our CPU resources just to keep the Ubuntu instance running, perhaps even at idle as you say. Then you cause traffic to route to the VM thereby demanding more CPU resources and the 10% base will increase as necessary.
Korona
Member
Member
Posts: 1000
Joined: Thu May 17, 2007 1:27 pm
Contact:

Re: CPU usage of a VM that runs Ubuntu

Post by Korona »

Your benchmark cannot properly distinguish CPU usage caused by the guest (i.e. the guest kernel and daemons running inside the guest) and QEMU (e.g. time keeping IRQs, VMENTER/VMEXIT costs, QEMU own event loop and so on).
managarm: Microkernel-based OS capable of running a Wayland desktop (Discord: https://discord.gg/7WB6Ur3). My OS-dev projects: [mlibc: Portable C library for managarm, qword, Linux, Sigma, ...] [LAI: AML interpreter] [xbstrap: Build system for OS distributions].
z0rr0
Member
Member
Posts: 64
Joined: Sun Apr 03, 2005 11:00 pm
Location: Grenoble, France
Contact:

Re: CPU usage of a VM that runs Ubuntu

Post by z0rr0 »

Hello,
pragmatic wrote:You question is somewhat ambiguous with respect to exactly what you are trying to ask. To me it would seem that 10% CPU is the nominal usage for that OS running in QEMU. In other words, it is taking 10% of our CPU resources just to keep the Ubuntu instance running, perhaps even at idle as you say. Then you cause traffic to route to the VM thereby demanding more CPU resources and the 10% base will increase as necessary.
You are right, let me rephrase. I am interested to know how the Ubuntu guest is able to keep the CPU at 10%.
Korona wrote:Your benchmark cannot properly distinguish CPU usage caused by the guest (i.e. the guest kernel and daemons running inside the guest) and QEMU (e.g. time keeping IRQs, VMENTER/VMEXIT costs, QEMU own event loop and so on).


In my benchmark, I am interested to consider both: the guest and QEMU.

Thanks for your answers, Matias.
z0rr0
Member
Member
Posts: 64
Joined: Sun Apr 03, 2005 11:00 pm
Location: Grenoble, France
Contact:

Re: CPU usage of a VM that runs Ubuntu

Post by z0rr0 »

I think what I really wanted to ask was about P-state. I knew nothing about this but it seems that Intel manual is quite complete :)
Post Reply