From mboxrd@z Thu Jan 1 00:00:00 1970 From: Thomas Fjellstrom Subject: Re: How many threads should a kvm vm be starting? Date: Wed, 28 Sep 2011 01:55:29 -0600 Message-ID: <201109280155.29776.thomas@fjellstrom.ca> References: <201109261829.38937.thomas@fjellstrom.ca> <201109271604.41502.thomas@fjellstrom.ca> <20110928074119.GB21102@redhat.com> Reply-To: thomas@fjellstrom.ca Mime-Version: 1.0 Content-Type: Text/Plain; charset="utf-8" Content-Transfer-Encoding: 7bit Cc: Avi Kivity , kvm@vger.kernel.org To: "Daniel P. Berrange" Return-path: Received: from mail.tomasu.net ([64.85.170.232]:39207 "EHLO mail.tomasu.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751377Ab1I1Hzi (ORCPT ); Wed, 28 Sep 2011 03:55:38 -0400 In-Reply-To: <20110928074119.GB21102@redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: 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