qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* Limiting per vCPU Usage
@ 2020-09-20 20:24 Peter Lieven
  2020-09-21  8:29 ` Daniel P. Berrangé
  0 siblings, 1 reply; 4+ messages in thread
From: Peter Lieven @ 2020-09-20 20:24 UTC (permalink / raw)
  To: qemu-devel

Hi Qemu folks,


is there a BCP to limit just the maximum usage of a virtual (KVM) cpu?

I know that there are many approaches, but as far as I know they all limit the complete qemu process which is far more

than just the virtual CPUs.

Is it possible to limit just the vCPU threads and leave threads that handle the monitor, vnc, qmp, iothreads, storage backend etc.

unthrottled?


Thanks,

Peter




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

* Re: Limiting per vCPU Usage
  2020-09-20 20:24 Limiting per vCPU Usage Peter Lieven
@ 2020-09-21  8:29 ` Daniel P. Berrangé
  2020-09-21 13:47   ` Peter Lieven
  0 siblings, 1 reply; 4+ messages in thread
From: Daniel P. Berrangé @ 2020-09-21  8:29 UTC (permalink / raw)
  To: Peter Lieven; +Cc: qemu-devel

On Sun, Sep 20, 2020 at 10:24:41PM +0200, Peter Lieven wrote:
> Hi Qemu folks,
> 
> 
> is there a BCP to limit just the maximum usage of a virtual (KVM) cpu?
> 
> I know that there are many approaches, but as far as I know they all limit the complete qemu process which is far more
> 
> than just the virtual CPUs.
> 
> Is it possible to limit just the vCPU threads and leave threads that
> handle the monitor, vnc, qmp, iothreads, storage backend etc.

Libvirt uses cgroups to achieve what you describe. A cgroup for the
QEMU process as a whole, then create child cgroups, one for each
vCPUs, and a further one for non-vCPU threads. CPU limits are then
applied on the child cgroups.

Regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|



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

* Re: Limiting per vCPU Usage
  2020-09-21  8:29 ` Daniel P. Berrangé
@ 2020-09-21 13:47   ` Peter Lieven
  2020-09-21 14:09     ` Daniel P. Berrangé
  0 siblings, 1 reply; 4+ messages in thread
From: Peter Lieven @ 2020-09-21 13:47 UTC (permalink / raw)
  To: Daniel P. Berrangé; +Cc: qemu-devel

Am 21.09.20 um 10:29 schrieb Daniel P. Berrangé:
> On Sun, Sep 20, 2020 at 10:24:41PM +0200, Peter Lieven wrote:
>> Hi Qemu folks,
>>
>>
>> is there a BCP to limit just the maximum usage of a virtual (KVM) cpu?
>>
>> I know that there are many approaches, but as far as I know they all limit the complete qemu process which is far more
>>
>> than just the virtual CPUs.
>>
>> Is it possible to limit just the vCPU threads and leave threads that
>> handle the monitor, vnc, qmp, iothreads, storage backend etc.
> Libvirt uses cgroups to achieve what you describe. A cgroup for the
> QEMU process as a whole, then create child cgroups, one for each
> vCPUs, and a further one for non-vCPU threads. CPU limits are then
> applied on the child cgroups.


Hi Daniel,


I came up with the same solution. Is there a nice way to get the thread ids of the vCPUs?

Iterating over all thread IDs and check the names works, but the thread names are not considered

a stable API (text from original commit message).


Thanks,

Peter





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

* Re: Limiting per vCPU Usage
  2020-09-21 13:47   ` Peter Lieven
@ 2020-09-21 14:09     ` Daniel P. Berrangé
  0 siblings, 0 replies; 4+ messages in thread
From: Daniel P. Berrangé @ 2020-09-21 14:09 UTC (permalink / raw)
  To: Peter Lieven; +Cc: qemu-devel

On Mon, Sep 21, 2020 at 03:47:56PM +0200, Peter Lieven wrote:
> Am 21.09.20 um 10:29 schrieb Daniel P. Berrangé:
> > On Sun, Sep 20, 2020 at 10:24:41PM +0200, Peter Lieven wrote:
> > > Hi Qemu folks,
> > > 
> > > 
> > > is there a BCP to limit just the maximum usage of a virtual (KVM) cpu?
> > > 
> > > I know that there are many approaches, but as far as I know they all limit the complete qemu process which is far more
> > > 
> > > than just the virtual CPUs.
> > > 
> > > Is it possible to limit just the vCPU threads and leave threads that
> > > handle the monitor, vnc, qmp, iothreads, storage backend etc.
> > Libvirt uses cgroups to achieve what you describe. A cgroup for the
> > QEMU process as a whole, then create child cgroups, one for each
> > vCPUs, and a further one for non-vCPU threads. CPU limits are then
> > applied on the child cgroups.
> 
> 
> Hi Daniel,
> 
> 
> I came up with the same solution. Is there a nice way to get the thread ids of the vCPUs?
> 
> Iterating over all thread IDs and check the names works, but the thread names are not considered
> 
> a stable API (text from original commit message).

The QMP  query-cpus  command tells you thread IDs. There is similar for
I/O threads too.  This is what libvirt uses to determine the mappings.

Regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|



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

end of thread, other threads:[~2020-09-21 14:12 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-20 20:24 Limiting per vCPU Usage Peter Lieven
2020-09-21  8:29 ` Daniel P. Berrangé
2020-09-21 13:47   ` Peter Lieven
2020-09-21 14:09     ` Daniel P. Berrangé

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).