public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: Avi Kivity <avi@redhat.com>
To: Jan Kiszka <jan.kiszka@web.de>
Cc: qemu-devel <qemu-devel@nongnu.org>, kvm <kvm@vger.kernel.org>,
	Marcelo Tosatti <mtosatti@redhat.com>
Subject: Re: Role of qemu_fair_mutex
Date: Mon, 03 Jan 2011 12:08:27 +0200	[thread overview]
Message-ID: <4D21A01B.7000900@redhat.com> (raw)
In-Reply-To: <4D219F06.7040305@web.de>

On 01/03/2011 12:03 PM, Jan Kiszka wrote:
> Am 03.01.2011 11:01, 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.
> >
> >  This doesn't happen with kvm since kvm vcpus drop qemu_mutex when running.
> >
>
> I see. Then I guess we should do this:
>
> diff --git a/cpus.c b/cpus.c
> index 9bf5224..0de8552 100644
> --- a/cpus.c
> +++ b/cpus.c
> @@ -734,9 +734,7 @@ static sigset_t block_io_signals(void)
>   void qemu_mutex_lock_iothread(void)
>   {
>       if (kvm_enabled()) {
> -        qemu_mutex_lock(&qemu_fair_mutex);
>           qemu_mutex_lock(&qemu_global_mutex);
> -        qemu_mutex_unlock(&qemu_fair_mutex);
>       } else {
>           qemu_mutex_lock(&qemu_fair_mutex);
>           if (qemu_mutex_trylock(&qemu_global_mutex)) {

I think so, though Anthony or Marcelo should confirm my interpretation 
first.

-- 
error compiling committee.c: too many arguments to function


  reply	other threads:[~2011-01-03 10:08 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-01-03  9:46 Role of qemu_fair_mutex Jan Kiszka
2011-01-03 10:01 ` Avi Kivity
2011-01-03 10:03   ` Jan Kiszka
2011-01-03 10:08     ` Avi Kivity [this message]
2011-01-04 14:17   ` Anthony Liguori
2011-01-04 14:27     ` Avi Kivity
2011-01-04 14:55       ` Anthony Liguori
2011-01-04 15:12         ` Avi Kivity
2011-01-04 15:43           ` Anthony Liguori
2011-01-05  8:55             ` Avi Kivity
2011-01-04 21:39     ` Marcelo Tosatti
2011-01-05 16:44       ` Anthony Liguori
2011-01-05 17:08         ` 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=4D21A01B.7000900@redhat.com \
    --to=avi@redhat.com \
    --cc=jan.kiszka@web.de \
    --cc=kvm@vger.kernel.org \
    --cc=mtosatti@redhat.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