XenevaOS
Loading...
Searching...
No Matches
rcupdate.h
Go to the documentation of this file.
1/*
2 * DCL rcupdate.h -- no-op RCU for single-CPU Xeneva.
3 *
4 * mainline drm/xarray call the read-side + grace-period API; here there is no
5 * preemption and no callback queue, so rcu_dereference degrades to a plain
6 * load and call_rcu runs the callback immediately. Immediate execution keeps
7 * the xa_node free path honest: mainline never touches an object after
8 * call_rcu() on it, which is exactly the contract a synchronous free needs.
9 */
10#ifndef _LINUX_RCUUPDATE_H
11#define _LINUX_RCUUPDATE_H
12
13#include <linux/compiler.h>
14#include <linux/types.h>
15#include <linux/cleanup.h>
16#include <linux/list.h>
17
18struct rcu_head {
19 struct rcu_head *next;
20 void (*func)(struct rcu_head *head);
21};
22
23#define __rcu
24#define __rcu_alloc_check
25
26#define list_for_each_entry_rcu(pos, head, member, ...) \
27 list_for_each_entry(pos, head, member)
28#define list_add_rcu(new, head) list_add((new), (head))
29#define list_add_tail_rcu(new, head) list_add_tail((new), (head))
30#define list_del_rcu(entry) list_del((entry))
31
32#define rcu_read_lock() do { } while (0)
33#define rcu_read_unlock() do { } while (0)
34#define rcu_read_lock_sched() do { } while (0)
35#define rcu_read_unlock_sched() do { } while (0)
36#define rcu_read_lock_bh() do { } while (0)
37#define rcu_read_unlock_bh() do { } while (0)
38#define rcu_read_lock_held() 1
39#define rcu_read_lock_sched_held() 1
40
41#define rcu_dereference(p) (p)
42#define rcu_dereference_raw(p) (p)
43#define rcu_dereference_check(p, c) (p)
44#define rcu_dereference_protected(p, c) (p)
45#define rcu_dereference_bh(p) (p)
46#define rcu_replace_pointer(p, v, c) ({ typeof(p) __tmp = (p); (p) = (v); __tmp; })
47#define rcu_access_pointer(p) (p)
48#define rcu_dereference_sparse(p, c)
49
50#define RCU_INIT_POINTER(p, v) do { (p) = (v); } while (0)
51#define rcu_assign_pointer(p, v) do { (p) = (v); } while (0)
52#define RCU_POINTER_INITIALIZER(p, v) (v)
53
54/*
55 * RCU_INITIALIZER(), unrcu_pointer(), rcu_pointer_handoff() -- mainline's
56 * three annotation helpers (rcupdate.h:525/:491/:788), with the sparse
57 * markers left out because they are empty here: __rcu is above and __force
58 * is kernel.h:239, so `(typeof(*(v)) __force __rcu *)(v)` and
59 * `(typeof(*(v)) *)(v)` are the same cast. What remains of the cast is its
60 * one real job -- the type check -- so it is kept rather than dropped.
61 *
62 * RCU_INITIALIZER() adds the annotation and unrcu_pointer() removes it, and
63 * both have exactly one caller: dma-fence-chain.c:65, the cmpxchg() in
64 * dma_fence_chain_alloc(), which reads
65 *
66 * tmp = unrcu_pointer(cmpxchg(&chain->prev, RCU_INITIALIZER(prev),
67 * RCU_INITIALIZER(replacement)));
68 *
69 * and reaches this header via dma-fence-chain.h -> dma-fence.h. The first
70 * argument of that cmpxchg is `struct dma_fence __rcu **`, so the casts have
71 * to land on that same pointer type or cmpxchg's argument check rejects
72 * them; `typeof(*(v))` is the pointee with the annotation already stripped,
73 * which is why the pointer spelling is the right one to cast to.
74 *
75 * rcu_pointer_handoff()'s one caller is dma-fence.h:380, in
76 * dma_fence_get_rcu_safe(): it marks the moment a reference stops being
77 * RCU-protected and becomes an owned one, which is a statement about the
78 * caller, not a change to the pointer.
79 */
80#define RCU_INITIALIZER(v) ((typeof(*(v)) *)(v))
81#define unrcu_pointer(p) ((typeof(*(p)) *)(p))
82#define rcu_pointer_handoff(p) (p)
83
84typedef struct { int held; } dclg_rcu;
85static inline void dclg_rcu_release(dclg_rcu* g) { (void)g; rcu_read_unlock(); }
86static inline dclg_rcu dclg_rcu_ctor(void)
87{
88 dclg_rcu g = { .held = 1 };
90 return g;
91}
92
93static inline void synchronize_rcu(void) { }
94static inline void synchronize_rcu_expedited(void) { }
95
96static inline void call_rcu(struct rcu_head *head, void (*func)(struct rcu_head *))
97{
98 func(head);
99}
100
101#define kfree_rcu(ptr, rhf) kfree(ptr)
102
103#define rcu_seq_start(s) do { } while (0)
104#define rcu_seq_done(s, c) 1
105
106#endif /* _LINUX_RCUUPDATE_H */
int const struct list_head const struct list_head struct list_head * head
Definition list_sort.h:13
#define rcu_read_unlock()
Definition rcupdate.h:33
#define rcu_read_lock()
Definition rcupdate.h:32
Definition rcupdate.h:84
int held
Definition rcupdate.h:84
Definition rcupdate.h:18
struct rcu_head * next
Definition rcupdate.h:19
void(* func)(struct rcu_head *head)
Definition rcupdate.h:20