mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-31 22:11:53 -06:00
rcu: use coroutine TLS macros
RCU may be used from coroutines. Standard __thread variables cannot be used by coroutines. Use the coroutine TLS macros instead. Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> Message-Id: <20220222140150.27240-4-stefanha@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
This commit is contained in:
parent
47b7446456
commit
17c78154b0
4 changed files with 16 additions and 15 deletions
|
@ -29,6 +29,7 @@
|
|||
#include "qemu/atomic.h"
|
||||
#include "qemu/notify.h"
|
||||
#include "qemu/sys_membarrier.h"
|
||||
#include "qemu/coroutine-tls.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
@ -76,11 +77,11 @@ struct rcu_reader_data {
|
|||
NotifierList force_rcu;
|
||||
};
|
||||
|
||||
extern __thread struct rcu_reader_data rcu_reader;
|
||||
QEMU_DECLARE_CO_TLS(struct rcu_reader_data, rcu_reader)
|
||||
|
||||
static inline void rcu_read_lock(void)
|
||||
{
|
||||
struct rcu_reader_data *p_rcu_reader = &rcu_reader;
|
||||
struct rcu_reader_data *p_rcu_reader = get_ptr_rcu_reader();
|
||||
unsigned ctr;
|
||||
|
||||
if (p_rcu_reader->depth++ > 0) {
|
||||
|
@ -96,7 +97,7 @@ static inline void rcu_read_lock(void)
|
|||
|
||||
static inline void rcu_read_unlock(void)
|
||||
{
|
||||
struct rcu_reader_data *p_rcu_reader = &rcu_reader;
|
||||
struct rcu_reader_data *p_rcu_reader = get_ptr_rcu_reader();
|
||||
|
||||
assert(p_rcu_reader->depth != 0);
|
||||
if (--p_rcu_reader->depth > 0) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue