qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] Doubts on SMP, VCPU and CONFIG_IOTHREAD
@ 2012-09-18  6:27 Alex Barcelo
  2012-09-18  8:19 ` Paolo Bonzini
  0 siblings, 1 reply; 3+ messages in thread
From: Alex Barcelo @ 2012-09-18  6:27 UTC (permalink / raw)
  To: qemu-devel

Sorry for being so confused, I am sure that there is some manual which
I haven't read, but I am not able to find it :-\

I saw some things[1] about multiple vcpu, smp and things like that. It
seemed to me that --enable-io-thread enables it. But, it only works
for KVM, doesn't it? I assume that there is NOT one thread per vcpu in
TCG mode. And this --enable-io-thread now is the default? This option
is always active? Now I was wondering if something "parallel" is done
in TCG (maybe through coroutines?). No truly parallel, I know, but...
"logically parallel" if you know what I mean. I have been unable to
find it on the code.

Also, the problem on multithreading the execution of qemu-system is
the translation, right? TCG is not thread safe and cannot be run in a
parallel mode. Right?

[1] http://blog.vmsplice.net/2011/03/qemu-internals-overall-architecture-and.html

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

* Re: [Qemu-devel] Doubts on SMP, VCPU and CONFIG_IOTHREAD
  2012-09-18  6:27 [Qemu-devel] Doubts on SMP, VCPU and CONFIG_IOTHREAD Alex Barcelo
@ 2012-09-18  8:19 ` Paolo Bonzini
  2012-09-19 15:16   ` Alex Barcelo
  0 siblings, 1 reply; 3+ messages in thread
From: Paolo Bonzini @ 2012-09-18  8:19 UTC (permalink / raw)
  To: Alex Barcelo; +Cc: qemu-devel

Il 18/09/2012 08:27, Alex Barcelo ha scritto:
> 
> I saw some things[1] about multiple vcpu, smp and things like that. It
> seemed to me that --enable-io-thread enables it.

iothread means that the QEMU main thread only services an event loop
(I/O, bottom halves, timers, etc.).  Running CPUs is offloaded to extra
threads.

The iothread most of the times runs without the big QEMU lock (because
most of the time it is waiting on a select system call).

> But, it only works
> for KVM, doesn't it? I assume that there is NOT one thread per vcpu in
> TCG mode.

Yes, KVM has a thread per VCPU.  This is possible because with KVM the
VCPU thread is _also_ running most of the time without the big QEMU lock
(it is in the KVM_RUN ioctl).

However, TCG needs to run with the big QEMU lock.  For this reason TCG
has a single thread that runs in lockstep with the io-thread.  Whenever
the iothread gets out of the select system call and needs the lock, it
asks the TCG thread to exit and the TCG thread obeys.  This is done
using a condition variable qemu_io_proceeded_cond, controlled by a
boolean variable iothread_requesting_mutex.

Whenever the iothread goes back to sleep, it signals the condition
variable and the TCG thread starts running again.

> And this --enable-io-thread now is the default? This option
> is always active? Now I was wondering if something "parallel" is done
> in TCG (maybe through coroutines?).

The lockstep behavior obtained with the condition variable is what you
are looking for.

Paolo

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

* Re: [Qemu-devel] Doubts on SMP, VCPU and CONFIG_IOTHREAD
  2012-09-18  8:19 ` Paolo Bonzini
@ 2012-09-19 15:16   ` Alex Barcelo
  0 siblings, 0 replies; 3+ messages in thread
From: Alex Barcelo @ 2012-09-19 15:16 UTC (permalink / raw)
  To: Paolo Bonzini; +Cc: qemu-devel

Thanks a lot! Ok, now it seems a bit clearer :)

On Tue, Sep 18, 2012 at 10:19 AM, Paolo Bonzini <pbonzini@redhat.com> wrote:
> Il 18/09/2012 08:27, Alex Barcelo ha scritto:
>>
>> I saw some things[1] about multiple vcpu, smp and things like that. It
>> seemed to me that --enable-io-thread enables it.
>
> iothread means that the QEMU main thread only services an event loop
> (I/O, bottom halves, timers, etc.).  Running CPUs is offloaded to extra
> threads.
>
> The iothread most of the times runs without the big QEMU lock (because
> most of the time it is waiting on a select system call).
>
>> But, it only works
>> for KVM, doesn't it? I assume that there is NOT one thread per vcpu in
>> TCG mode.
>
> Yes, KVM has a thread per VCPU.  This is possible because with KVM the
> VCPU thread is _also_ running most of the time without the big QEMU lock
> (it is in the KVM_RUN ioctl).
>
> However, TCG needs to run with the big QEMU lock.  For this reason TCG
> has a single thread that runs in lockstep with the io-thread.  Whenever
> the iothread gets out of the select system call and needs the lock, it
> asks the TCG thread to exit and the TCG thread obeys.  This is done
> using a condition variable qemu_io_proceeded_cond, controlled by a
> boolean variable iothread_requesting_mutex.
>
> Whenever the iothread goes back to sleep, it signals the condition
> variable and the TCG thread starts running again.
>
>> And this --enable-io-thread now is the default? This option
>> is always active? Now I was wondering if something "parallel" is done
>> in TCG (maybe through coroutines?).
>
> The lockstep behavior obtained with the condition variable is what you
> are looking for.
>
> Paolo

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

end of thread, other threads:[~2012-09-19 15:16 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-09-18  6:27 [Qemu-devel] Doubts on SMP, VCPU and CONFIG_IOTHREAD Alex Barcelo
2012-09-18  8:19 ` Paolo Bonzini
2012-09-19 15:16   ` Alex Barcelo

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