[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 17/21] rcu: add g_free_rcu
From: |
Paolo Bonzini |
Subject: |
[Qemu-devel] [PULL 17/21] rcu: add g_free_rcu |
Date: |
Mon, 16 Feb 2015 19:17:58 +0100 |
This simplifies calling g_free from an RCU callback.
Signed-off-by: Paolo Bonzini <address@hidden>
---
docs/rcu.txt | 11 +++++++----
include/qemu/rcu.h | 8 ++++++++
2 files changed, 15 insertions(+), 4 deletions(-)
diff --git a/docs/rcu.txt b/docs/rcu.txt
index 61752b9..21ecb81 100644
--- a/docs/rcu.txt
+++ b/docs/rcu.txt
@@ -120,12 +120,15 @@ The core RCU API is small:
void call_rcu(T *p,
void (*func)(T *p),
field-name);
+ void g_free_rcu(T *p,
+ field-name);
- call_rcu1 is typically used through this macro, in the common case
- where the "struct rcu_head" is the first field in the struct. In
- the above case, one could have written simply:
+ call_rcu1 is typically used through these macro, in the common case
+ where the "struct rcu_head" is the first field in the struct. If
+ the callback function is g_free, in particular, g_free_rcu can be
+ used. In the above case, one could have written simply:
- call_rcu(foo_reclaim, g_free, rcu);
+ g_free_rcu(foo_reclaim, rcu);
typeof(*p) atomic_rcu_read(p);
diff --git a/include/qemu/rcu.h b/include/qemu/rcu.h
index 068a279..506ab58 100644
--- a/include/qemu/rcu.h
+++ b/include/qemu/rcu.h
@@ -140,6 +140,14 @@ extern void call_rcu1(struct rcu_head *head, RCUCBFunc
*func);
}), \
(RCUCBFunc *)(func))
+#define g_free_rcu(obj, field) \
+ call_rcu1(({ \
+ char __attribute__((unused)) \
+ offset_must_be_zero[-offsetof(typeof(*(obj)), field)]; \
+ &(obj)->field; \
+ }), \
+ (RCUCBFunc *)g_free);
+
#ifdef __cplusplus
}
#endif
--
2.3.0
- [Qemu-devel] [PULL 11/21] pci: split shpc_cleanup and shpc_free, (continued)
- [Qemu-devel] [PULL 11/21] pci: split shpc_cleanup and shpc_free, Paolo Bonzini, 2015/02/16
- [Qemu-devel] [PULL 12/21] docs: clarify memory region lifecycle, Paolo Bonzini, 2015/02/16
- [Qemu-devel] [PULL 14/21] exec: make iotlb RCU-friendly, Paolo Bonzini, 2015/02/16
- [Qemu-devel] [PULL 15/21] exec: RCUify AddressSpaceDispatch, Paolo Bonzini, 2015/02/16
- [Qemu-devel] [PULL 09/21] memory: keep the owner of the AddressSpace alive until do_address_space_destroy, Paolo Bonzini, 2015/02/16
- [Qemu-devel] [PULL 13/21] exec: introduce cpu_reload_memory_map, Paolo Bonzini, 2015/02/16
- [Qemu-devel] [PULL 16/21] rcu: introduce RCU-enabled QLIST, Paolo Bonzini, 2015/02/16
- [Qemu-devel] [PULL 19/21] cosmetic changes preparing for the following patches, Paolo Bonzini, 2015/02/16
- [Qemu-devel] [PULL 20/21] exec: convert ram_list to QLIST, Paolo Bonzini, 2015/02/16
- [Qemu-devel] [PULL 21/21] Convert ram_list to RCU, Paolo Bonzini, 2015/02/16
- [Qemu-devel] [PULL 17/21] rcu: add g_free_rcu,
Paolo Bonzini <=
- [Qemu-devel] [PULL 18/21] exec: protect mru_block with RCU, Paolo Bonzini, 2015/02/16
- Re: [Qemu-devel] [PULL 00/21] SCSI, RCU, KVM changes for 2015-02-16, Peter Maydell, 2015/02/25