[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 58/66] qom: Use atomics for object refcounting
From: |
Paolo Bonzini |
Subject: |
[Qemu-devel] [PATCH 58/66] qom: Use atomics for object refcounting |
Date: |
Thu, 4 Jul 2013 17:13:54 +0200 |
From: Jan Kiszka <address@hidden>
Object reference counts will soon be changed outside the BQL. So we need
to use atomics in object_ref/unref.
Based on a patch by Liu Ping Fan.
Signed-off-by: Liu Ping Fan <address@hidden>
Signed-off-by: Jan Kiszka <address@hidden>
Signed-off-by: Paolo Bonzini <address@hidden>
---
qom/object.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/qom/object.c b/qom/object.c
index 803b94b..cbd7e86 100644
--- a/qom/object.c
+++ b/qom/object.c
@@ -683,16 +683,15 @@ GSList *object_class_get_list(const char *implements_type,
void object_ref(Object *obj)
{
- obj->ref++;
+ atomic_inc(&obj->ref);
}
void object_unref(Object *obj)
{
g_assert(obj->ref > 0);
- obj->ref--;
/* parent always holds a reference to its children */
- if (obj->ref == 0) {
+ if (atomic_fetch_dec(&obj->ref) == 1) {
object_finalize(obj);
}
}
--
1.8.1.4
- [Qemu-devel] [PATCH 46/66] hw/gpio: pass owner to memory_region_init* functions, (continued)
- [Qemu-devel] [PATCH 46/66] hw/gpio: pass owner to memory_region_init* functions, Paolo Bonzini, 2013/07/04
- [Qemu-devel] [PATCH 47/66] hw/i*: pass owner to memory_region_init* functions, Paolo Bonzini, 2013/07/04
- [Qemu-devel] [PATCH 48/66] hw/m*: pass owner to memory_region_init* functions, Paolo Bonzini, 2013/07/04
- [Qemu-devel] [PATCH 49/66] hw/n*: pass owner to memory_region_init* functions, Paolo Bonzini, 2013/07/04
- [Qemu-devel] [PATCH 51/66] hw/s*: pass owner to memory_region_init* functions, Paolo Bonzini, 2013/07/04
- [Qemu-devel] [PATCH 50/66] hw/p*: pass owner to memory_region_init* functions, Paolo Bonzini, 2013/07/04
- [Qemu-devel] [PATCH 55/66] memory: access FlatView from a local variable, Paolo Bonzini, 2013/07/04
- [Qemu-devel] [PATCH 56/66] memory: use a new FlatView pointer on every topology update, Paolo Bonzini, 2013/07/04
- [Qemu-devel] [PATCH 54/66] add a header file for atomic operations, Paolo Bonzini, 2013/07/04
- [Qemu-devel] [PATCH 57/66] memory: add reference counting to FlatView, Paolo Bonzini, 2013/07/04
- [Qemu-devel] [PATCH 58/66] qom: Use atomics for object refcounting,
Paolo Bonzini <=
- [Qemu-devel] [PATCH 59/66] exec: change well-known physical sections to macros, Paolo Bonzini, 2013/07/04
- [Qemu-devel] [PATCH 60/66] exec: separate current memory map from the one being built, Paolo Bonzini, 2013/07/04
- [Qemu-devel] [PATCH 61/66] memory: move MemoryListener declaration earlier, Paolo Bonzini, 2013/07/04
- [Qemu-devel] [PATCH 63/66] exec: separate current radix tree from the one being built, Paolo Bonzini, 2013/07/04
- [Qemu-devel] [PATCH 62/66] exec: move listener from AddressSpaceDispatch to AddressSpace, Paolo Bonzini, 2013/07/04
- [Qemu-devel] [PATCH 64/66] exec: put memory map in AddressSpaceDispatch, Paolo Bonzini, 2013/07/04
- [Qemu-devel] [PATCH 65/66] exec: remove cur_map, Paolo Bonzini, 2013/07/04
- [Qemu-devel] [PATCH 66/66] exec: change some APIs to take AddressSpaceDispatch, Paolo Bonzini, 2013/07/04
- [Qemu-devel] [PATCH 53/66] hw/[u-x]*: pass owner to memory_region_init* functions, Paolo Bonzini, 2013/07/04
- Re: [Qemu-devel] [PULL 00/66] Memory API changes for 1.6: ownership, I/O ports, RCU preparation, Paolo Bonzini, 2013/07/04