qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: Alex Barcelo <abarcelo@ac.upc.edu>
Cc: qemu-devel <qemu-devel@nongnu.org>
Subject: Re: [Qemu-devel] Doubts on SMP, VCPU and CONFIG_IOTHREAD
Date: Tue, 18 Sep 2012 10:19:18 +0200	[thread overview]
Message-ID: <50582E86.3060206@redhat.com> (raw)
In-Reply-To: <CAFKAgTfV6kVvkKGW6ThF0JUbV=KGGCJs+8zfUjNkOLw_QbS+cQ@mail.gmail.com>

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

  reply	other threads:[~2012-09-18  8:19 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-09-18  6:27 [Qemu-devel] Doubts on SMP, VCPU and CONFIG_IOTHREAD Alex Barcelo
2012-09-18  8:19 ` Paolo Bonzini [this message]
2012-09-19 15:16   ` Alex Barcelo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=50582E86.3060206@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=abarcelo@ac.upc.edu \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).