qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Anthony Liguori <aliguori@us.ibm.com>
To: Paul Brook <paul@codesourcery.com>
Cc: Marcelo Tosatti <mtosatti@redhat.com>, qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [patch 1/2] qemu: sem/thread helpers
Date: Wed, 11 Mar 2009 11:56:21 -0500	[thread overview]
Message-ID: <49B7ED35.5050704@us.ibm.com> (raw)
In-Reply-To: <200903111648.02530.paul@codesourcery.com>

Paul Brook wrote:
>> +QemuSem qemu_sem;
>>     
>
> It's entirely unclear what is actually protected by the semaphore.
>
> What exactly does the IO thread do? AFAICS device MMIO is still run from 
> within the CPU thread. Device code is not threadsafe (and probably never will 
> be), so you can't run any of the device callbacks in the IO thread either. 
> Doesn't seem like there's a lot left for it to do...
>   

The goal is to drop qemu_mutex while the VCPU is running to allow the 
device model to run while the VCPU executes.  This is not currently safe 
with TCG but it is safe when using KVM.

There are a couple reasons to drop qemu_mutex while running the VCPU.  
When using KVM's in-kernel APIC, hlt emulation occurs within the 
kernel.  This means that the KVM_RUN ioctl blocks indefinitely.  We 
currently don't use in-kernel APIC emulation in upstream QEMU's KVM 
support as this set of patches is a pre-requisite for that.

This also enables true SMP support in KVM.   You can allow multiple 
VCPUs to run concurrently once you're dropping qemu_mutex during VCPU 
execution.

The VCPU threads have to acquire qemu_mutex once they drop back to QEMU 
(to handle MMIO, for instance), but this only happens during IO.

 From an infrastructure perspective, this is a feature for KVM but also 
a step in a better direction for TCG too.  If TCG can be made to allow 
qemu_mutex to be dropped (perhaps for x86->x86 translation, as a start), 
then the same infrastructure can be used for true SMP support with TCG.

Once we have this, we can start making some of the device model code 
thread safe too...

Regards,

Anthony Liguori

Regards,

Anthony Liguori

> Paul
>   

  reply	other threads:[~2009-03-11 16:56 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-03-11 16:16 [Qemu-devel] [patch 0/2] RFC: separate thread for IO Marcelo Tosatti
2009-03-11 16:16 ` [Qemu-devel] [patch 1/2] qemu: sem/thread helpers Marcelo Tosatti
2009-03-11 16:33   ` [Qemu-devel] " Anthony Liguori
2009-03-11 16:48   ` [Qemu-devel] " Paul Brook
2009-03-11 16:56     ` Anthony Liguori [this message]
2009-03-11 16:58     ` Marcelo Tosatti
2009-03-18 18:47     ` Marcelo Tosatti
2009-03-15 14:15   ` Avi Kivity
2009-03-17 17:42     ` Marcelo Tosatti
2009-03-17 23:07       ` Paul Brook
2009-03-17 23:43         ` Marcelo Tosatti
2009-03-11 16:16 ` [Qemu-devel] [patch 2/2] qemu: separate thread for io Marcelo Tosatti

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=49B7ED35.5050704@us.ibm.com \
    --to=aliguori@us.ibm.com \
    --cc=mtosatti@redhat.com \
    --cc=paul@codesourcery.com \
    --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).