All of lore.kernel.org
 help / color / mirror / Atom feed
From: Marcelo Tosatti <mtosatti@redhat.com>
To: Anthony Liguori <anthony@codemonkey.ws>
Cc: Avi Kivity <avi@redhat.com>, Jan Kiszka <jan.kiszka@web.de>,
	qemu-devel <qemu-devel@nongnu.org>, kvm <kvm@vger.kernel.org>
Subject: Re: Role of qemu_fair_mutex
Date: Tue, 4 Jan 2011 19:39:20 -0200	[thread overview]
Message-ID: <20110104213920.GA7379@amt.cnet> (raw)
In-Reply-To: <4D232BF6.6050102@codemonkey.ws>

On Tue, Jan 04, 2011 at 08:17:26AM -0600, Anthony Liguori wrote:
> On 01/03/2011 04:01 AM, Avi Kivity wrote:
> >On 01/03/2011 11:46 AM, Jan Kiszka wrote:
> >>Hi,
> >>
> >>at least in kvm mode, the qemu_fair_mutex seems to have lost its
> >>function of balancing qemu_global_mutex access between the io-thread and
> >>vcpus. It's now only taken by the latter, isn't it?
> >>
> >>This and the fact that qemu-kvm does not use this kind of lock made me
> >>wonder what its role is and if it is still relevant in practice. I'd
> >>like to unify the execution models of qemu-kvm and qemu, and this lock
> >>is the most obvious difference (there are surely more subtle ones as
> >>well...).
> >>
> >
> >IIRC it was used for tcg, which has a problem that kvm doesn't
> >have: a tcg vcpu needs to hold qemu_mutex when it runs, which
> >means there will always be contention on qemu_mutex.  In the
> >absence of fairness, the tcg thread could dominate qemu_mutex and
> >starve the iothread.
> 
> No, it's actually the opposite IIRC.
> 
> TCG relies on the following behavior.   A guest VCPU runs until 1)
> it encounters a HLT instruction 2) an event occurs that forces the
> TCG execution to break.
> 
> (2) really means that the TCG thread receives a signal.  Usually,
> this is the periodic timer signal.
> 
> When the TCG thread, it needs to let the IO thread run for at least
> one iteration.  Coordinating the execution of the IO thread such
> that it's guaranteed to run at least once and then having it drop
> the qemu mutex long enough for the TCG thread to acquire it is the
> purpose of the qemu_fair_mutex.

Its the vcpu threads that starve the IO thread.


WARNING: multiple messages have this Message-ID (diff)
From: Marcelo Tosatti <mtosatti@redhat.com>
To: Anthony Liguori <anthony@codemonkey.ws>
Cc: Jan Kiszka <jan.kiszka@web.de>, Avi Kivity <avi@redhat.com>,
	kvm <kvm@vger.kernel.org>, qemu-devel <qemu-devel@nongnu.org>
Subject: [Qemu-devel] Re: Role of qemu_fair_mutex
Date: Tue, 4 Jan 2011 19:39:20 -0200	[thread overview]
Message-ID: <20110104213920.GA7379@amt.cnet> (raw)
In-Reply-To: <4D232BF6.6050102@codemonkey.ws>

On Tue, Jan 04, 2011 at 08:17:26AM -0600, Anthony Liguori wrote:
> On 01/03/2011 04:01 AM, Avi Kivity wrote:
> >On 01/03/2011 11:46 AM, Jan Kiszka wrote:
> >>Hi,
> >>
> >>at least in kvm mode, the qemu_fair_mutex seems to have lost its
> >>function of balancing qemu_global_mutex access between the io-thread and
> >>vcpus. It's now only taken by the latter, isn't it?
> >>
> >>This and the fact that qemu-kvm does not use this kind of lock made me
> >>wonder what its role is and if it is still relevant in practice. I'd
> >>like to unify the execution models of qemu-kvm and qemu, and this lock
> >>is the most obvious difference (there are surely more subtle ones as
> >>well...).
> >>
> >
> >IIRC it was used for tcg, which has a problem that kvm doesn't
> >have: a tcg vcpu needs to hold qemu_mutex when it runs, which
> >means there will always be contention on qemu_mutex.  In the
> >absence of fairness, the tcg thread could dominate qemu_mutex and
> >starve the iothread.
> 
> No, it's actually the opposite IIRC.
> 
> TCG relies on the following behavior.   A guest VCPU runs until 1)
> it encounters a HLT instruction 2) an event occurs that forces the
> TCG execution to break.
> 
> (2) really means that the TCG thread receives a signal.  Usually,
> this is the periodic timer signal.
> 
> When the TCG thread, it needs to let the IO thread run for at least
> one iteration.  Coordinating the execution of the IO thread such
> that it's guaranteed to run at least once and then having it drop
> the qemu mutex long enough for the TCG thread to acquire it is the
> purpose of the qemu_fair_mutex.

Its the vcpu threads that starve the IO thread.

  parent reply	other threads:[~2011-01-04 22:29 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-01-03  9:46 Role of qemu_fair_mutex Jan Kiszka
2011-01-03  9:46 ` [Qemu-devel] " Jan Kiszka
2011-01-03 10:01 ` Avi Kivity
2011-01-03 10:01   ` [Qemu-devel] " Avi Kivity
2011-01-03 10:03   ` Jan Kiszka
2011-01-03 10:03     ` [Qemu-devel] " Jan Kiszka
2011-01-03 10:08     ` Avi Kivity
2011-01-03 10:08       ` [Qemu-devel] " Avi Kivity
2011-01-04 14:17   ` Anthony Liguori
2011-01-04 14:17     ` [Qemu-devel] " Anthony Liguori
2011-01-04 14:27     ` Avi Kivity
2011-01-04 14:27       ` [Qemu-devel] " Avi Kivity
2011-01-04 14:55       ` Anthony Liguori
2011-01-04 14:55         ` [Qemu-devel] " Anthony Liguori
2011-01-04 15:12         ` Avi Kivity
2011-01-04 15:12           ` [Qemu-devel] " Avi Kivity
2011-01-04 15:43           ` Anthony Liguori
2011-01-04 15:43             ` [Qemu-devel] " Anthony Liguori
2011-01-05  8:55             ` Avi Kivity
2011-01-05  8:55               ` [Qemu-devel] " Avi Kivity
2011-01-04 21:39     ` Marcelo Tosatti [this message]
2011-01-04 21:39       ` Marcelo Tosatti
2011-01-05 16:44       ` Anthony Liguori
2011-01-05 16:44         ` [Qemu-devel] " Anthony Liguori
2011-01-05 17:08         ` Avi Kivity
2011-01-05 17:08           ` [Qemu-devel] " Avi Kivity

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=20110104213920.GA7379@amt.cnet \
    --to=mtosatti@redhat.com \
    --cc=anthony@codemonkey.ws \
    --cc=avi@redhat.com \
    --cc=jan.kiszka@web.de \
    --cc=kvm@vger.kernel.org \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.