All of lore.kernel.org
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: "Frederic Konrad" <fred.konrad@greensocs.com>,
	"Alex Bennée" <alex.bennee@linaro.org>,
	mttcg@greensocs.com, mark.burton@greensocs.com
Cc: peter.maydell@linaro.org, qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [RFC PATCH] qemu_mutux: make the iothread recursive (MTTCG)
Date: Tue, 23 Jun 2015 16:23:22 +0200	[thread overview]
Message-ID: <55896BDA.10408@redhat.com> (raw)
In-Reply-To: <55896B6B.7020605@greensocs.com>



On 23/06/2015 16:21, Frederic Konrad wrote:
> 
>> While I was testing multi-threaded TCG I discovered once consequence of
>> using locking around memory_region_dispatch is that virt-io transactions
>> could dead lock trying to grab the main mutex. This is due to the
>> virt-io driver writing data back into the system memory:
> 
> Hi,
> 
> Thanks for that.
> Didn't qemu abort in this case with a pthread error? Maybe that did
> change since
> the last time I had this error.

Unfortunately it had to change:

commit 24fa90499f8b24bcba2960a3316d797f9b80b5e9
Author: Paolo Bonzini <pbonzini@redhat.com>
Date:   Thu Mar 5 16:47:14 2015 +0100

    qemu-thread: do not use PTHREAD_MUTEX_ERRORCHECK

    PTHREAD_MUTEX_ERRORCHECK is completely broken with respect to fork.
    The way to safely do fork is to bring all threads to a quiescent
    state by acquiring locks (either in callers---as we do for the
    iothread mutex---or using pthread_atfork's prepare callbacks)
    and then release them in the child.

    The problem is that releasing error-checking locks in the child
    fails under glibc with EPERM, because the mutex stores a different
    owner tid than the duplicated thread in the child process.  We
    could make it work for locks acquired via pthread_atfork, by
    recreating the mutex in the child instead of unlocking it
    (we know that there are no other threads that could have taken
    the mutex; but when the lock is acquired in fork's caller
    that would not be possible.

    The simplest solution is just to forgo error checking.

    Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>

I do revert that patch however for my own testing, since it does make
things much easier when there's a deadlock.

Paolo

      reply	other threads:[~2015-06-23 14:23 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-06-23 12:21 [Qemu-devel] [RFC PATCH] qemu_mutux: make the iothread recursive (MTTCG) Alex Bennée
2015-06-23 12:32 ` Paolo Bonzini
2015-06-23 12:55   ` Alex Bennée
2015-06-23 14:21 ` Frederic Konrad
2015-06-23 14:23   ` Paolo Bonzini [this message]

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=55896BDA.10408@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=alex.bennee@linaro.org \
    --cc=fred.konrad@greensocs.com \
    --cc=mark.burton@greensocs.com \
    --cc=mttcg@greensocs.com \
    --cc=peter.maydell@linaro.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.