[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [RFC v4 2/3] memory: add depth assert in address_space_to_flatview
From: |
Peter Xu |
Subject: |
Re: [RFC v4 2/3] memory: add depth assert in address_space_to_flatview |
Date: |
Fri, 23 Dec 2022 10:54:44 -0500 |
Hi, Paolo,
On Fri, Dec 23, 2022 at 04:47:57PM +0100, Paolo Bonzini wrote:
> On 12/23/22 15:23, Chuang Xu wrote:
> > static inline FlatView *address_space_to_flatview(AddressSpace *as)
> > {
> > + /*
> > + * Before using any flatview, sanity check we're not during a memory
> > + * region transaction or the map can be invalid. Note that this can
> > + * also be called during commit phase of memory transaction, but that
> > + * should also only happen when the depth decreases to 0 first.
> > + */
> > + assert(memory_region_transaction_get_depth() == 0 ||
> > rcu_read_locked());
> > return qatomic_rcu_read(&as->current_map);
> > }
>
> 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?
Thanks,
--
Peter Xu