diff mbox series

[RFC,2/4] memory: Use rcu list variance for address_spaces modifications

Message ID 20230225163141.1209368-3-peterx@redhat.com (mailing list archive)
State New, archived
Headers show
Series memory: Fix (/ Discuss) a few rcu issues | expand

Commit Message

Peter Xu Feb. 25, 2023, 4:31 p.m. UTC
AddressSpace should be safe to RCU since it's released with call_rcu.
Change the list insert/removal to use RCU variances.

Signed-off-by: Peter Xu <peterx@redhat.com>
---
 softmmu/memory.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/softmmu/memory.c b/softmmu/memory.c
index a63e0bcbb7..c48e9cc6ed 100644
--- a/softmmu/memory.c
+++ b/softmmu/memory.c
@@ -3079,7 +3079,7 @@  void address_space_init(AddressSpace *as, MemoryRegion *root, const char *name)
     as->ioeventfd_nb = 0;
     as->ioeventfds = NULL;
     QTAILQ_INIT(&as->listeners);
-    QTAILQ_INSERT_TAIL(&address_spaces, as, address_spaces_link);
+    QTAILQ_INSERT_TAIL_RCU(&address_spaces, as, address_spaces_link);
     as->name = g_strdup(name ? name : "anonymous");
     address_space_update_topology(as);
     address_space_update_ioeventfds(as);
@@ -3103,7 +3103,7 @@  void address_space_destroy(AddressSpace *as)
     memory_region_transaction_begin();
     as->root = NULL;
     memory_region_transaction_commit();
-    QTAILQ_REMOVE(&address_spaces, as, address_spaces_link);
+    QTAILQ_REMOVE_RCU(&address_spaces, as, address_spaces_link);
 
     /* At this point, as->dispatch and as->current_map are dummy
      * entries that the guest should never use.  Wait for the old