From: Peter Xu <peterx@redhat.com>
To: Paolo Bonzini <pbonzini@redhat.com>
Cc: "Chuang Xu" <xuchuangxclwt@bytedance.com>,
qemu-devel <qemu-devel@nongnu.org>,
"David Gilbert" <dgilbert@redhat.com>,
"Quintela, Juan" <quintela@redhat.com>,
"David Hildenbrand" <david@redhat.com>,
"Philippe Mathieu-Daudé" <philmd@linaro.org>,
zhouyibo@bytedance.com
Subject: Re: [RFC v4 2/3] memory: add depth assert in address_space_to_flatview
Date: Tue, 3 Jan 2023 12:43:27 -0500 [thread overview]
Message-ID: <Y7RpPwGd0WvrENlz@x1n> (raw)
In-Reply-To: <CABgObfa=i=9CZRFyX_EXBOSW===iDhcZoDO8Ju64F-tHUAXdRA@mail.gmail.com>
Hi, Paolo,
On Wed, Dec 28, 2022 at 09:27:50AM +0100, Paolo Bonzini wrote:
> Il ven 23 dic 2022, 16:54 Peter Xu <peterx@redhat.com> ha scritto:
>
> > > This is not valid because the transaction could happen in *another*
> > thread.
> > > In that case memory_region_transaction_depth() will be > 0, but RCU is
> > > needed.
> >
> > Do you mean the code is wrong, or the comment? Note that the code has
> > checked rcu_read_locked() where introduced in patch 1, but maybe something
> > else was missed?
> >
>
> The assertion is wrong. It will succeed even if RCU is unlocked in this
> thread but a transaction is in progress in another thread.
IIUC this is the case where the context:
(1) doesn't have RCU read lock held, and,
(2) doesn't have BQL held.
Is it safe at all to reference any flatview in such a context? The thing
is I think the flatview pointer can be freed anytime if both locks are not
taken.
> Perhaps you can check (memory_region_transaction_depth() > 0 &&
> !qemu_mutex_iothread_locked()) || rcu_read_locked() instead?
What if one thread calls address_space_to_flatview() with BQL held but not
RCU read lock held? I assume it's a legal operation, but it seems to be
able to trigger the assert already?
Thanks,
--
Peter Xu
next prev parent reply other threads:[~2023-01-03 17:44 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-12-23 14:23 [RFC v4 0/3] migration: reduce time of loading non-iterable vmstate Chuang Xu
2022-12-23 14:23 ` [RFC v4 1/3] rcu: introduce rcu_read_locked() Chuang Xu
2023-01-04 14:20 ` Alex Bennée
2023-01-05 8:17 ` Chuang Xu
2022-12-23 14:23 ` [RFC v4 2/3] memory: add depth assert in address_space_to_flatview Chuang Xu
2022-12-23 15:37 ` Peter Xu
2022-12-23 15:47 ` Paolo Bonzini
2022-12-23 15:54 ` Peter Xu
2022-12-28 8:27 ` Paolo Bonzini
2023-01-03 17:43 ` Peter Xu [this message]
2023-01-10 8:09 ` Chuang Xu
2023-01-10 14:45 ` Peter Xu
2023-01-12 7:59 ` Chuang Xu
2023-01-12 15:13 ` Peter Xu
2023-01-13 19:29 ` Chuang Xu
2022-12-28 10:50 ` Philippe Mathieu-Daudé
2023-01-04 7:39 ` [External] " Chuang Xu
2022-12-23 14:23 ` [RFC v4 3/3] migration: reduce time of loading non-iterable vmstate Chuang Xu
2022-12-23 16:06 ` David Hildenbrand
2023-01-04 7:31 ` Chuang Xu
2022-12-23 15:50 ` [RFC v4 0/3] " Peter Xu
2022-12-23 19:11 ` Chuang Xu
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=Y7RpPwGd0WvrENlz@x1n \
--to=peterx@redhat.com \
--cc=david@redhat.com \
--cc=dgilbert@redhat.com \
--cc=pbonzini@redhat.com \
--cc=philmd@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=quintela@redhat.com \
--cc=xuchuangxclwt@bytedance.com \
--cc=zhouyibo@bytedance.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 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.