mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-28 20:41:52 -06:00
rcu: add call_rcu
Asynchronous callbacks provided by call_rcu are particularly important for QEMU, because the BQL makes it hard to use synchronize_rcu. In addition, the current RCU implementation is not particularly friendly to multiple concurrent synchronize_rcu callers, making call_rcu even more important. Reviewed-by: Fam Zheng <famz@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:
parent
d62cb4f2fd
commit
26387f86c9
3 changed files with 247 additions and 4 deletions
|
@ -118,6 +118,28 @@ extern void synchronize_rcu(void);
|
|||
extern void rcu_register_thread(void);
|
||||
extern void rcu_unregister_thread(void);
|
||||
|
||||
struct rcu_head;
|
||||
typedef void RCUCBFunc(struct rcu_head *head);
|
||||
|
||||
struct rcu_head {
|
||||
struct rcu_head *next;
|
||||
RCUCBFunc *func;
|
||||
};
|
||||
|
||||
extern void call_rcu1(struct rcu_head *head, RCUCBFunc *func);
|
||||
|
||||
/* The operands of the minus operator must have the same type,
|
||||
* which must be the one that we specify in the cast.
|
||||
*/
|
||||
#define call_rcu(head, func, field) \
|
||||
call_rcu1(({ \
|
||||
char __attribute__((unused)) \
|
||||
offset_must_be_zero[-offsetof(typeof(*(head)), field)], \
|
||||
func_type_invalid = (func) - (void (*)(typeof(head)))(func); \
|
||||
&(head)->field; \
|
||||
}), \
|
||||
(RCUCBFunc *)(func))
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue