From: Avi Kivity <avi@redhat.com>
To: liu ping fan <qemulist@gmail.com>
Cc: Jan Kiszka <jan.kiszka@siemens.com>,
Marcelo Tosatti <mtosatti@redhat.com>,
qemu-devel@nongnu.org, Anthony Liguori <anthony@codemonkey.ws>,
Paolo Bonzini <pbonzini@redhat.com>
Subject: Re: [Qemu-devel] [big lock] Discussion about the convention of device's DMA each other after breaking down biglock
Date: Wed, 19 Sep 2012 11:06:55 +0300 [thread overview]
Message-ID: <50597D1F.3070607@redhat.com> (raw)
In-Reply-To: <CAJnKYQmv=k9QhcTfVzXcdqnFxZiCsZTehC8pGWeVCfBq7FX0zg@mail.gmail.com>
On 09/19/2012 06:02 AM, liu ping fan wrote:
> Currently, cpu_physical_memory_rw() can be used directly or indirectly
> by mmio-dispatcher to access other devices' memory region. This can
> cause some problem when adopting device's private lock.
>
> Back ground refer to:
> http://lists.gnu.org/archive/html/qemu-devel/2012-09/msg01481.html
> For lazy, just refer to:
> http://lists.gnu.org/archive/html/qemu-devel/2012-09/msg01878.html
>
>
> --1st. the recursive lock of biglock.
> If we leave c_p_m_rw() as it is, ie, no lock inside. Then we can have
> the following (section of the whole call chain, and with
> private_lockA):
> lockA-mmio-dispatcher --> hold biglock -- >c_p_m_rw() --- >
> Before c_p_m_rw(), we drop private_lockA to anti the possibly of
> deadlock. But we can not anti the nested of this chain or calling to
> another lockB-mmio-dispatcher. So we can not avoid the possibility of
> nested lock of biglock. And another important factor is that we break
> the lock sequence: private_lock-->biglock.
> All of these require us to push biglock's holding into c_p_m_rw(), the
> wrapper can not give help.
I agree that this is unavoidable.
>
> --2nd. c_p_m_rw(), sync or async?
>
> IF we convert all of the device to be protected by refcount, then we can have
> //no big lock
> c_p_m_rw()
> {
> devB->ref++;
> {
> --------------------------------------->pushed onto another thread.
> lock_privatelock
> mr->ops->write();
> unlock_privatelock
> }
> wait_for_completion();
> devB->ref--;
> }
> This model can help c_p_m_rw() present as a SYNC API. But currently,
> we mix biglock and private lock together, and wait_for_completion()
> maybe block the release of big lock, which finally causes deadlock. So
> we can not simply rely on this model.
> Instead, we need to classify the calling scene into three cases:
> case1. lockA--dispatcher ---> lockB-dispatcher //can use
> async+completion model
> case2. lockA--dispatcher ---> biglock-dispatcher // sync, but can
> cause the nested lock of biglock
> case3. biglock-dispacher ---> lockB-dispatcher // async to avoid
> the lock sequence problem, (as to completion, it need to be placed
> outside the top level biglock, and it is hard to do so. Suggest to
> change to case 1. Or at present, just leave it async)
>
> This new model will require the biglock can be nested.
I think changing to an async model is too complicated. It's difficult
enough already. Isn't dropping private locks + recursive big locks
sufficient?
--
error compiling committee.c: too many arguments to function
next prev parent reply other threads:[~2012-09-19 8:07 UTC|newest]
Thread overview: 45+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-09-19 3:02 [Qemu-devel] [big lock] Discussion about the convention of device's DMA each other after breaking down biglock liu ping fan
2012-09-19 8:06 ` Avi Kivity [this message]
2012-09-19 9:00 ` liu ping fan
2012-09-19 9:07 ` Avi Kivity
2012-09-19 9:11 ` liu ping fan
2012-09-19 9:14 ` Paolo Bonzini
2012-09-19 9:19 ` liu ping fan
2012-09-19 9:23 ` Avi Kivity
2012-09-19 9:27 ` Jan Kiszka
2012-09-19 9:28 ` Jan Kiszka
2012-09-20 7:51 ` liu ping fan
2012-09-20 7:54 ` Paolo Bonzini
2012-09-20 8:09 ` liu ping fan
2012-09-20 8:27 ` Paolo Bonzini
2012-09-20 9:07 ` Avi Kivity
2012-09-21 7:27 ` liu ping fan
2012-09-21 8:21 ` Paolo Bonzini
2012-09-19 9:21 ` Avi Kivity
2012-09-19 9:51 ` Paolo Bonzini
2012-09-19 10:06 ` Avi Kivity
2012-09-19 10:19 ` Paolo Bonzini
2012-09-19 10:27 ` Avi Kivity
2012-09-19 9:34 ` Jan Kiszka
2012-09-19 9:50 ` Avi Kivity
2012-09-19 10:18 ` Jan Kiszka
2012-09-24 6:33 ` liu ping fan
2012-09-24 7:44 ` Avi Kivity
2012-09-24 8:32 ` liu ping fan
2012-09-24 9:42 ` Avi Kivity
2012-09-27 3:13 ` liu ping fan
2012-09-27 9:16 ` Avi Kivity
2012-09-27 9:29 ` Paolo Bonzini
2012-09-27 9:34 ` Avi Kivity
2012-09-27 9:36 ` Paolo Bonzini
2012-09-27 10:08 ` Avi Kivity
2012-09-27 10:22 ` Paolo Bonzini
2012-09-27 10:48 ` Avi Kivity
2012-09-29 9:20 ` liu ping fan
2012-09-30 8:13 ` Avi Kivity
2012-09-30 8:48 ` liu ping fan
2012-09-30 11:18 ` Avi Kivity
2012-09-30 11:04 ` Blue Swirl
2012-09-30 11:17 ` Avi Kivity
2012-09-30 11:48 ` Blue Swirl
2012-09-20 8:11 ` liu ping fan
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=50597D1F.3070607@redhat.com \
--to=avi@redhat.com \
--cc=anthony@codemonkey.ws \
--cc=jan.kiszka@siemens.com \
--cc=mtosatti@redhat.com \
--cc=pbonzini@redhat.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).