public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
* How many threads should a kvm vm be starting?
@ 2011-09-27  0:29 Thomas Fjellstrom
  2011-09-27  6:33 ` Avi Kivity
  0 siblings, 1 reply; 5+ messages in thread
From: Thomas Fjellstrom @ 2011-09-27  0:29 UTC (permalink / raw)
  To: kvm

I just noticed something interesting, a virtual machine on one of my servers 
seems to have 69 threads (including the main thread). Other guests on the 
machine only have a couple threads.

Is this normal? or has something gone horribly wrong?

-- 
Thomas Fjellstrom
thomas@fjellstrom.ca

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: How many threads should a kvm vm be starting?
  2011-09-27  0:29 How many threads should a kvm vm be starting? Thomas Fjellstrom
@ 2011-09-27  6:33 ` Avi Kivity
  2011-09-27 22:04   ` Thomas Fjellstrom
  0 siblings, 1 reply; 5+ messages in thread
From: Avi Kivity @ 2011-09-27  6:33 UTC (permalink / raw)
  To: thomas; +Cc: kvm

On 09/27/2011 03:29 AM, Thomas Fjellstrom wrote:
> I just noticed something interesting, a virtual machine on one of my servers
> seems to have 69 threads (including the main thread). Other guests on the
> machine only have a couple threads.
>
> Is this normal? or has something gone horribly wrong?
>

It's normal if the guest does a lot of I/O.  The thread count should go 
down when the guest idles.

-- 
I have a truly marvellous patch that fixes the bug which this
signature is too narrow to contain.


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: How many threads should a kvm vm be starting?
  2011-09-27  6:33 ` Avi Kivity
@ 2011-09-27 22:04   ` Thomas Fjellstrom
  2011-09-28  7:41     ` Daniel P. Berrange
  0 siblings, 1 reply; 5+ messages in thread
From: Thomas Fjellstrom @ 2011-09-27 22:04 UTC (permalink / raw)
  To: Avi Kivity; +Cc: kvm

On September 27, 2011, Avi Kivity wrote:
> On 09/27/2011 03:29 AM, Thomas Fjellstrom wrote:
> > I just noticed something interesting, a virtual machine on one of my
> > servers seems to have 69 threads (including the main thread). Other
> > guests on the machine only have a couple threads.
> > 
> > Is this normal? or has something gone horribly wrong?
> 
> It's normal if the guest does a lot of I/O.  The thread count should go
> down when the guest idles.

Ah, that would make sense. Though it kind of defeats assigning a vm a single 
cpu/core. A single VM can now DOS an entire multi-core-cpu server. It pretty 
much pegged my dual core (with HT) server for a couple hours.

-- 
Thomas Fjellstrom
thomas@fjellstrom.ca

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: How many threads should a kvm vm be starting?
  2011-09-27 22:04   ` Thomas Fjellstrom
@ 2011-09-28  7:41     ` Daniel P. Berrange
  2011-09-28  7:55       ` Thomas Fjellstrom
  0 siblings, 1 reply; 5+ messages in thread
From: Daniel P. Berrange @ 2011-09-28  7:41 UTC (permalink / raw)
  To: Thomas Fjellstrom; +Cc: Avi Kivity, kvm

On Tue, Sep 27, 2011 at 04:04:41PM -0600, Thomas Fjellstrom wrote:
> On September 27, 2011, Avi Kivity wrote:
> > On 09/27/2011 03:29 AM, Thomas Fjellstrom wrote:
> > > I just noticed something interesting, a virtual machine on one of my
> > > servers seems to have 69 threads (including the main thread). Other
> > > guests on the machine only have a couple threads.
> > > 
> > > Is this normal? or has something gone horribly wrong?
> > 
> > It's normal if the guest does a lot of I/O.  The thread count should go
> > down when the guest idles.
> 
> Ah, that would make sense. Though it kind of defeats assigning a vm a single 
> cpu/core. A single VM can now DOS an entire multi-core-cpu server. It pretty 
> much pegged my dual core (with HT) server for a couple hours.

You can mitigate these problems by putting each KVM process in its own
cgroup, and using the 'cpu_shares' tunable to ensure that each KVM
process gets the same relative ratio of CPU time, regardless of how
many threads it is running. With newer kernels there are other CPU
tunables for placing hard caps on CPU utilization of the process as
a whole too.

Regards,
Daniel
-- 
|: http://berrange.com      -o-    http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org              -o-             http://virt-manager.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org       -o-       http://live.gnome.org/gtk-vnc :|

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: How many threads should a kvm vm be starting?
  2011-09-28  7:41     ` Daniel P. Berrange
@ 2011-09-28  7:55       ` Thomas Fjellstrom
  0 siblings, 0 replies; 5+ messages in thread
From: Thomas Fjellstrom @ 2011-09-28  7:55 UTC (permalink / raw)
  To: Daniel P. Berrange; +Cc: Avi Kivity, kvm

On September 28, 2011, Daniel P. Berrange wrote:
> On Tue, Sep 27, 2011 at 04:04:41PM -0600, Thomas Fjellstrom wrote:
> > On September 27, 2011, Avi Kivity wrote:
> > > On 09/27/2011 03:29 AM, Thomas Fjellstrom wrote:
> > > > I just noticed something interesting, a virtual machine on one of my
> > > > servers seems to have 69 threads (including the main thread). Other
> > > > guests on the machine only have a couple threads.
> > > > 
> > > > Is this normal? or has something gone horribly wrong?
> > > 
> > > It's normal if the guest does a lot of I/O.  The thread count should go
> > > down when the guest idles.
> > 
> > Ah, that would make sense. Though it kind of defeats assigning a vm a
> > single cpu/core. A single VM can now DOS an entire multi-core-cpu
> > server. It pretty much pegged my dual core (with HT) server for a couple
> > hours.
> 
> You can mitigate these problems by putting each KVM process in its own
> cgroup, and using the 'cpu_shares' tunable to ensure that each KVM
> process gets the same relative ratio of CPU time, regardless of how
> many threads it is running. With newer kernels there are other CPU
> tunables for placing hard caps on CPU utilization of the process as
> a whole too.

I'll have to look into how to set that up with libvirt. A brief search leads 
me to believe its rather easy to set up, so I'll have to do that asap :)

> Regards,
> Daniel


-- 
Thomas Fjellstrom
thomas@fjellstrom.ca

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2011-09-28  7:55 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-09-27  0:29 How many threads should a kvm vm be starting? Thomas Fjellstrom
2011-09-27  6:33 ` Avi Kivity
2011-09-27 22:04   ` Thomas Fjellstrom
2011-09-28  7:41     ` Daniel P. Berrange
2011-09-28  7:55       ` Thomas Fjellstrom

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox