qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] Question on qemu threads
@ 2014-09-30 17:44 Al Patel
  2014-09-30 20:43 ` Brian Jackson
  2014-10-02 15:15 ` Stefan Hajnoczi
  0 siblings, 2 replies; 4+ messages in thread
From: Al Patel @ 2014-09-30 17:44 UTC (permalink / raw)
  To: qemu-devel, qemu-discuss

[-- Attachment #1: Type: text/plain, Size: 1234 bytes --]

Hi:

I am running qemu-kvm version 1.0

($kvm -version
QEMU emulator version 1.0 (qemu-kvm-1.0), Copyright (c) 2003-2008 Fabrice
Bellard)

When I start a VM with 4 vcpus, I see about 8 threads. (the thread count
varies ...)

1118  1118 ?        00:00:00 kvm-irqfd-clean
 *8767  8767 pts/4    00:03:16 kvm*
* 8767  8770 pts/4    1-15:10:10 kvm*
* 8767  8771 pts/4    1-14:40:42 kvm*
* 8767  8772 pts/4    2-04:39:57 kvm*
* 8767  8773 pts/4    08:35:51 kvm*
* 8767 28585 pts/4    00:00:00 kvm*
* 8767 28597 pts/4    00:00:00 kvm*
* 8767 28598 pts/4    00:00:00 kvm*
* 8767 28599 pts/4    00:00:00 kvm*
* 8767 28600 pts/4    00:00:00 kvm*
 8768  8768 ?        00:00:00 kvm-pit/8767


On older version of qemu (prior to the qemu/kvm binary merge), I typically
saw 5 threads (for  4 vcpu) - which I believe  was 1 x 4 for each vcpu and
1 for
the IO threads.

In the current system, what are the extra threads?

Secondly, I am currently not using libvirt and having to start qemu from
command line. I still want to pin the vcpu to a pcpu and want to use
taskset on a thread. Unless I know which thread is emulating the vcpu
how can I pin that thread?

Do you have any other thoughts on the pinning part?

Any guidance/pointers?

Thank You.

[-- Attachment #2: Type: text/html, Size: 3432 bytes --]

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

* Re: [Qemu-devel] Question on qemu threads
  2014-09-30 17:44 [Qemu-devel] Question on qemu threads Al Patel
@ 2014-09-30 20:43 ` Brian Jackson
  2014-10-02 15:15 ` Stefan Hajnoczi
  1 sibling, 0 replies; 4+ messages in thread
From: Brian Jackson @ 2014-09-30 20:43 UTC (permalink / raw)
  To: qemu-devel; +Cc: Al Patel, qemu-discuss

On Tuesday, September 30, 2014 01:44:48 PM Al Patel wrote:
> Hi:
> 
> I am running qemu-kvm version 1.0
> 
> ($kvm -version
> QEMU emulator version 1.0 (qemu-kvm-1.0), Copyright (c) 2003-2008 Fabrice
> Bellard)
> 
> When I start a VM with 4 vcpus, I see about 8 threads. (the thread count
> varies ...)
> 
> 1118  1118 ?        00:00:00 kvm-irqfd-clean
>  *8767  8767 pts/4    00:03:16 kvm*
> * 8767  8770 pts/4    1-15:10:10 kvm*
> * 8767  8771 pts/4    1-14:40:42 kvm*
> * 8767  8772 pts/4    2-04:39:57 kvm*
> * 8767  8773 pts/4    08:35:51 kvm*
> * 8767 28585 pts/4    00:00:00 kvm*
> * 8767 28597 pts/4    00:00:00 kvm*
> * 8767 28598 pts/4    00:00:00 kvm*
> * 8767 28599 pts/4    00:00:00 kvm*
> * 8767 28600 pts/4    00:00:00 kvm*
>  8768  8768 ?        00:00:00 kvm-pit/8767


Probably aio emulation via a threadpool. Make sure you use aio=native and it 
won't do that.


> 
> 
> On older version of qemu (prior to the qemu/kvm binary merge), I typically
> saw 5 threads (for  4 vcpu) - which I believe  was 1 x 4 for each vcpu and
> 1 for
> the IO threads.
> 
> In the current system, what are the extra threads?
> 
> Secondly, I am currently not using libvirt and having to start qemu from
> command line. I still want to pin the vcpu to a pcpu and want to use
> taskset on a thread. Unless I know which thread is emulating the vcpu
> how can I pin that thread?
> 
> Do you have any other thoughts on the pinning part?


In qmp, you can query the info about vcpus and host threads. ("info cpus" in 
qemu monitor iirc).


> 
> Any guidance/pointers?
> 
> Thank You.

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

* Re: [Qemu-devel] Question on qemu threads
  2014-09-30 17:44 [Qemu-devel] Question on qemu threads Al Patel
  2014-09-30 20:43 ` Brian Jackson
@ 2014-10-02 15:15 ` Stefan Hajnoczi
  2014-10-06 16:52   ` Al Patel
  1 sibling, 1 reply; 4+ messages in thread
From: Stefan Hajnoczi @ 2014-10-02 15:15 UTC (permalink / raw)
  To: Al Patel; +Cc: qemu-devel, qemu-discuss

[-- Attachment #1: Type: text/plain, Size: 901 bytes --]

On Tue, Sep 30, 2014 at 01:44:48PM -0400, Al Patel wrote:
> In the current system, what are the extra threads?

The set of thread is dynamic because worker threads are started and
terminated depending on guest activity.  You cannot make assumptions
about threads and QEMU provides monitor commands that expose the tids.

> Secondly, I am currently not using libvirt and having to start qemu from
> command line. I still want to pin the vcpu to a pcpu and want to use
> taskset on a thread. Unless I know which thread is emulating the vcpu
> how can I pin that thread?
> 
> Do you have any other thoughts on the pinning part?

Use libvirt if you can.  It will save you a ton of time.

If you really cannot use it, you can still look at its source code to
understand how it does what it does.  See qemuProcessDetectVcpuPIDs() in
libvirt and the QEMU query-cpus QMP command.

Stefan

[-- Attachment #2: Type: application/pgp-signature, Size: 473 bytes --]

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

* Re: [Qemu-devel] Question on qemu threads
  2014-10-02 15:15 ` Stefan Hajnoczi
@ 2014-10-06 16:52   ` Al Patel
  0 siblings, 0 replies; 4+ messages in thread
From: Al Patel @ 2014-10-06 16:52 UTC (permalink / raw)
  To: Stefan Hajnoczi; +Cc: qemu-devel, qemu-discuss

[-- Attachment #1: Type: text/plain, Size: 1031 bytes --]

Thank You, Brian and Stefan!

-a


On Thu, Oct 2, 2014 at 11:15 AM, Stefan Hajnoczi <stefanha@gmail.com> wrote:

> On Tue, Sep 30, 2014 at 01:44:48PM -0400, Al Patel wrote:
> > In the current system, what are the extra threads?
>
> The set of thread is dynamic because worker threads are started and
> terminated depending on guest activity.  You cannot make assumptions
> about threads and QEMU provides monitor commands that expose the tids.
>
> > Secondly, I am currently not using libvirt and having to start qemu from
> > command line. I still want to pin the vcpu to a pcpu and want to use
> > taskset on a thread. Unless I know which thread is emulating the vcpu
> > how can I pin that thread?
> >
> > Do you have any other thoughts on the pinning part?
>
> Use libvirt if you can.  It will save you a ton of time.
>
> If you really cannot use it, you can still look at its source code to
> understand how it does what it does.  See qemuProcessDetectVcpuPIDs() in
> libvirt and the QEMU query-cpus QMP command.
>
> Stefan
>

[-- Attachment #2: Type: text/html, Size: 1553 bytes --]

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

end of thread, other threads:[~2014-10-06 16:52 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-09-30 17:44 [Qemu-devel] Question on qemu threads Al Patel
2014-09-30 20:43 ` Brian Jackson
2014-10-02 15:15 ` Stefan Hajnoczi
2014-10-06 16:52   ` Al Patel

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