qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: mdroth <mdroth@linux.vnet.ibm.com>
Cc: Liu Ping Fan <qemulist@gmail.com>,
	Anthony Liguori <anthony@codemonkey.ws>,
	qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH v2 2/2] QEMUBH: make AioContext's bh re-entrant
Date: Wed, 19 Jun 2013 11:27:25 +0200	[thread overview]
Message-ID: <51C1797D.9080800@redhat.com> (raw)
In-Reply-To: <20130618222652.GC7866@vm>

Il 19/06/2013 00:26, mdroth ha scritto:
> On Tue, Jun 18, 2013 at 09:20:26PM +0200, Paolo Bonzini wrote:
>> Il 18/06/2013 17:14, mdroth ha scritto:
>>> Could we possibly simplify this by introducing a recursive mutex that we
>>> could use to protect the whole list loop and hold even during the cb?
>>
>> If it is possible, we should avoid recursive locks.  It makes impossible
>> to establish a lock hierarchy.  For example:
>>
>>> I assume we can't hold the lock during the cb currently since we might
>>> try to reschedule, but if it's a recursive mutex would that simplify
>>> things?
>>
>> If you have two callbacks in two different AioContexts, both of which do
>> bdrv_drain_all(), you get an AB-BA deadlock
> 
> I think I see what you mean. That problem exists regardless of whether we
> introduce a recursive mutex though right?

Without a recursive mutex, you only hold one lock at a time in each thread.

> I guess the main issue is the
> fact that we'd be encouraging sloppy locking practices without
> addressing the root problem?

Yeah.  We're basically standing where the Linux kernel stood 10 years
ago (let's say 2.2 timeframe).  If Linux got this far without recursive
mutexes, we can at least try. :)

> I'm just worried what other subtle problems pop up if we instead rely
> heavily on memory barriers and inevitably forget one here or there, but
> maybe that's just me not having a good understanding of when to use them.

That's true.  I hope that the docs in patch 1 help, and (much) more
thorough docs are available in the Linux kernel.

> But doesn't rcu provide higher-level interfaces for these kinds of things?
> Is it possible to hide any of this behind our list interfaces?

My atomics header file provides higher-level interfaces, but in most
cases barriers are not that harder to use and the docs help converting
one style to the other.

So far I've not used RCU for lists, only for entire data structures.

Paolo

  reply	other threads:[~2013-06-19  9:29 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-06-16 11:21 [Qemu-devel] [PATCH v2 0/2] make AioContext's bh re-entrant Liu Ping Fan
2013-06-16 11:21 ` [Qemu-devel] [PATCH v2 1/2] add a header file for atomic operations Liu Ping Fan
2013-06-17 18:57   ` Richard Henderson
2013-06-18  8:36     ` Paolo Bonzini
2013-06-18 11:03       ` Paolo Bonzini
2013-06-18 14:38       ` Richard Henderson
2013-06-18 15:04         ` Paolo Bonzini
2013-06-18 13:24     ` [Qemu-devel] Java volatile vs. C11 seq_cst (was Re: [PATCH v2 1/2] add a header file for atomic operations) Paolo Bonzini
2013-06-18 14:50       ` Paul E. McKenney
2013-06-18 15:29         ` Peter Sewell
2013-06-18 15:37         ` Torvald Riegel
2013-06-19  1:53           ` Paul E. McKenney
2013-06-19  7:11             ` Torvald Riegel
2013-06-20 15:18               ` Paul E. McKenney
2013-06-18 16:08         ` Paolo Bonzini
2013-06-18 16:38           ` Torvald Riegel
2013-06-19  1:57             ` Paul E. McKenney
2013-06-19  9:31             ` Paolo Bonzini
2013-06-19 13:15               ` Torvald Riegel
2013-06-19 15:14                 ` Paolo Bonzini
2013-06-19 20:25                   ` Torvald Riegel
2013-06-20  7:53                     ` Paolo Bonzini
2013-06-22 10:55                       ` Torvald Riegel
2013-06-18 15:26       ` Torvald Riegel
2013-06-18 17:38       ` Andrew Haley
2013-06-19  9:30         ` Paolo Bonzini
2013-06-19 15:36           ` Andrew Haley
2013-06-16 11:21 ` [Qemu-devel] [PATCH v2 2/2] QEMUBH: make AioContext's bh re-entrant Liu Ping Fan
2013-06-17 15:28   ` Stefan Hajnoczi
2013-06-17 16:41     ` Paolo Bonzini
2013-06-18  2:19     ` liu ping fan
2013-06-18  9:31       ` Stefan Hajnoczi
2013-06-18 15:14   ` mdroth
2013-06-18 16:19     ` mdroth
2013-06-18 19:20     ` Paolo Bonzini
2013-06-18 22:26       ` mdroth
2013-06-19  9:27         ` Paolo Bonzini [this message]
2013-06-20  9:11           ` Stefan Hajnoczi
2013-06-17  7:11 ` [Qemu-devel] [PATCH v2 0/2] " Paolo Bonzini
2013-06-18  2:40   ` liu ping fan
2013-06-18  8:36     ` Paolo Bonzini

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=51C1797D.9080800@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=anthony@codemonkey.ws \
    --cc=mdroth@linux.vnet.ibm.com \
    --cc=qemu-devel@nongnu.org \
    --cc=qemulist@gmail.com \
    /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).