|
From: | Paolo Bonzini |
Subject: | Re: [RFC v4 2/3] memory: add depth assert in address_space_to_flatview |
Date: | Fri, 23 Dec 2022 16:47:57 +0100 |
User-agent: | Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.5.1 |
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.
Paolo
[Prev in Thread] | Current Thread | [Next in Thread] |