summary refs log tree commit diff stats
path: root/include
diff options
context:
space:
mode:
authorPeter Maydell <peter.maydell@linaro.org>2025-09-29 15:42:26 +0100
committerPeter Xu <peterx@redhat.com>2025-10-03 09:48:02 -0400
commit9e7bfda4909cc688dd0327e17985019f08a78d5d (patch)
tree6d144abd6f6d2d9afa721e5c5d9c1ae952673631 /include
parentd943cef76090b5255e68ba38ce6ddf20537b07bc (diff)
downloadfocaccia-qemu-9e7bfda4909cc688dd0327e17985019f08a78d5d.tar.gz
focaccia-qemu-9e7bfda4909cc688dd0327e17985019f08a78d5d.zip
include/system/memory.h: Clarify address_space_destroy() behaviour
address_space_destroy() doesn't actually immediately destroy the AS;
it queues it to be destroyed via RCU. This means you can't g_free()
the memory the AS struct is in until that has happened.

Clarify this in the documentation.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: David Hildenbrand <david@redhat.com>
Link: https://lore.kernel.org/r/20250929144228.1994037-2-peter.maydell@linaro.org
Signed-off-by: Peter Xu <peterx@redhat.com>
Diffstat (limited to 'include')
-rw-r--r--include/system/memory.h11
1 files changed, 8 insertions, 3 deletions
diff --git a/include/system/memory.h b/include/system/memory.h
index aa85fc27a1..827e2c5aa4 100644
--- a/include/system/memory.h
+++ b/include/system/memory.h
@@ -2727,9 +2727,14 @@ void address_space_init(AddressSpace *as, MemoryRegion *root, const char *name);
 /**
  * address_space_destroy: destroy an address space
  *
- * Releases all resources associated with an address space.  After an address space
- * is destroyed, its root memory region (given by address_space_init()) may be destroyed
- * as well.
+ * Releases all resources associated with an address space.  After an
+ * address space is destroyed, the reference the AddressSpace had to
+ * its root memory region is dropped, which may result in the
+ * destruction of that memory region as well.
+ *
+ * Note that destruction of the AddressSpace is done via RCU;
+ * it is therefore not valid to free the memory the AddressSpace
+ * struct is in until after that RCU callback has completed.
  *
  * @as: address space to be destroyed
  */