* KVM and cpu limiting
@ 2010-07-02 6:23 Boris Dolgov
[not found] ` <AANLkTinbGi6LOu01xySOiqfml-VFG5TYt7ovXVn7hVlR@mail.gmail.com>
2010-07-02 8:02 ` RW
0 siblings, 2 replies; 5+ messages in thread
From: Boris Dolgov @ 2010-07-02 6:23 UTC (permalink / raw)
To: kvm
Hello!
Is it possible to limit cpu usage be VM when using qemu+kvm?
I need one server to run a lot of VMs (much more than cpu cores I
have). Each VM must have it's guaranted cpu time or time slice it must
use.
Is it possible to make such limits? Is it possible to modify
/proc/cpuinfo of VMs?
--
Boris Dolgov.
^ permalink raw reply [flat|nested] 5+ messages in thread[parent not found: <AANLkTinbGi6LOu01xySOiqfml-VFG5TYt7ovXVn7hVlR@mail.gmail.com>]
* Re: Fwd: KVM and cpu limiting [not found] ` <AANLkTinbGi6LOu01xySOiqfml-VFG5TYt7ovXVn7hVlR@mail.gmail.com> @ 2010-07-02 7:57 ` Srivatsa Vaddagiri 2010-07-02 16:38 ` Boris Dolgov 0 siblings, 1 reply; 5+ messages in thread From: Srivatsa Vaddagiri @ 2010-07-02 7:57 UTC (permalink / raw) To: Boris Dolgov; +Cc: kvm, bharata, Balbir Singh > Is it possible to limit cpu usage be VM when using qemu+kvm? Have you checked cpu controller? # mkdir /cpu_control # mount -t cgroup -o cpu none /cpu_control # cd /cpu_control # mkdir vm1 # mkdir vm2 Then change vm{1,2}/cpu.shares to control how much proportion of CPU capacity each VM gets. Basically, each vm is (soft-)limtied to: its allocated shares / total shares allocated for all VMs. > I need one server to run a lot of VMs (much more than cpu cores I > have). Each VM must have it's guaranted cpu time or time slice it must > use. This interface is more focused on limiting resource consumption rather than guaranteeing certain minimum. By carefully controlling how many VMs are run on the server and how many shares are allocated to each, this can be a good alternative to provide some "minimum" resources to a VM. Its slightly inflexible for guaranteeing "minimum" resource to a VM, but that's the best we have now. > Is it possible to make such limits? Is it possible to modify > /proc/cpuinfo of VMs? Why do you want to modify /proc/cpuinfo of VMs? - vatsa ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Fwd: KVM and cpu limiting 2010-07-02 7:57 ` Fwd: " Srivatsa Vaddagiri @ 2010-07-02 16:38 ` Boris Dolgov 2010-07-06 4:39 ` Srivatsa Vaddagiri 0 siblings, 1 reply; 5+ messages in thread From: Boris Dolgov @ 2010-07-02 16:38 UTC (permalink / raw) To: vatsa; +Cc: kvm, bharata, Balbir Singh On Fri, Jul 2, 2010 at 11:57 AM, Srivatsa Vaddagiri <vatsa@in.ibm.com> wrote: >> Is it possible to limit cpu usage be VM when using qemu+kvm? > > Have you checked cpu controller? It is very interesting. Looks like it is something, that I need. So, limiting qemu process will limit cpu usage for the container? I think, i will be able to configure it to provide guaranted cpu to containers in that way. But what happens with the VM when qemu process is paused by the scheduler? Will this time be counted as idle time for VM's cpu, or it will be added to the state, which was used when qemu process was paused? > Why do you want to modify /proc/cpuinfo of VMs? Just for information about the limits for the VMs' owners. -- Boris Dolgov. ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Fwd: KVM and cpu limiting 2010-07-02 16:38 ` Boris Dolgov @ 2010-07-06 4:39 ` Srivatsa Vaddagiri 0 siblings, 0 replies; 5+ messages in thread From: Srivatsa Vaddagiri @ 2010-07-06 4:39 UTC (permalink / raw) To: Boris Dolgov; +Cc: kvm, bharata, Balbir Singh On Fri, Jul 02, 2010 at 08:38:37PM +0400, Boris Dolgov wrote: > On Fri, Jul 2, 2010 at 11:57 AM, Srivatsa Vaddagiri <vatsa@in.ibm.com> wrote: > >> Is it possible to limit cpu usage be VM when using qemu+kvm? > > > > Have you checked cpu controller? > It is very interesting. Looks like it is something, that I need. > So, limiting qemu process will limit cpu usage for the container? > I think, i will be able to configure it to provide guaranted cpu to > containers in that way. Note that shares control how much cpu bandwidth a VM gets _relative_ to other active VMs and hence is not a absolute measure of how much CPU capacity is provided to a particular VM. If the number of VMs deployed on a server and their relative priority remains static in general, then shares can be used as both "guarantee" and "limit" mechanism. > But what happens with the VM when qemu process is paused by the > scheduler? Will this time be counted as idle time for VM's cpu, No - it should be accounted as "runqueue wait time". > or it will be added to the state, which was used when qemu process was > paused? The runqueue wait time should reflect as "steal" time for the VMs. top command should show the steal time for a VM (look for 'st'), although I am not 100% sure whether steal time is reported in case of KVM guests. > > Why do you want to modify /proc/cpuinfo of VMs? > Just for information about the limits for the VMs' owners. Sounds like a cool idea - although not sure whether cpuinfo is the right place. You can try sending a patch and find out what the community thinks of it! - vatsa ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: KVM and cpu limiting 2010-07-02 6:23 KVM and cpu limiting Boris Dolgov [not found] ` <AANLkTinbGi6LOu01xySOiqfml-VFG5TYt7ovXVn7hVlR@mail.gmail.com> @ 2010-07-02 8:02 ` RW 1 sibling, 0 replies; 5+ messages in thread From: RW @ 2010-07-02 8:02 UTC (permalink / raw) To: kvm > Is it possible to limit cpu usage be VM when using qemu+kvm? > First thing you can do is to only provide one or two virtual CPUs to a VM. This is normally a not to bad way to limit CPU usage. But maybe cgroups can help you more: http://www.mjmwired.net/kernel/Documentation/cgroups.txt > I need one server to run a lot of VMs (much more than cpu cores I > have). Each VM must have it's guaranted cpu time or time slice it must > use. > > Is it possible to make such limits? Is it possible to modify > /proc/cpuinfo of VMs? > > You can start Qemu/KVM with different "-cpu" parameter: bern:~ # qemu-kvm -cpu ? x86 qemu64 x86 phenom x86 core2duo x86 kvm64 x86 qemu32 x86 coreduo x86 486 x86 pentium x86 pentium2 x86 pentium3 x86 athlon x86 n270 Or just provied "-cpu host". Then you get the same output inside the guest as the host. - Robert ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2010-07-06 4:40 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-07-02 6:23 KVM and cpu limiting Boris Dolgov
[not found] ` <AANLkTinbGi6LOu01xySOiqfml-VFG5TYt7ovXVn7hVlR@mail.gmail.com>
2010-07-02 7:57 ` Fwd: " Srivatsa Vaddagiri
2010-07-02 16:38 ` Boris Dolgov
2010-07-06 4:39 ` Srivatsa Vaddagiri
2010-07-02 8:02 ` RW
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).