1
2
3
4
5
6
7
8
9
10
11#ifndef _LINUX_SRCU_TREE_H
12#define _LINUX_SRCU_TREE_H
13
14#include <linux/rcu_node_tree.h>
15#include <linux/completion.h>
16
17struct srcu_node;
18struct srcu_struct;
19
20
21
22
23
24struct srcu_data {
25
26 unsigned long srcu_lock_count[2];
27 unsigned long srcu_unlock_count[2];
28
29
30 spinlock_t __private lock ____cacheline_internodealigned_in_smp;
31 struct rcu_segcblist srcu_cblist;
32 unsigned long srcu_gp_seq_needed;
33 unsigned long srcu_gp_seq_needed_exp;
34 bool srcu_cblist_invoking;
35 struct timer_list delay_work;
36 struct work_struct work;
37 struct rcu_head srcu_barrier_head;
38 struct srcu_node *mynode;
39 unsigned long grpmask;
40
41 int cpu;
42 struct srcu_struct *ssp;
43};
44
45
46
47
48struct srcu_node {
49 spinlock_t __private lock;
50 unsigned long srcu_have_cbs[4];
51
52
53 unsigned long srcu_data_have_cbs[4];
54
55 unsigned long srcu_gp_seq_needed_exp;
56 struct srcu_node *srcu_parent;
57 int grplo;
58 int grphi;
59};
60
61
62
63
64struct srcu_struct {
65 struct srcu_node node[NUM_RCU_NODES];
66 struct srcu_node *level[RCU_NUM_LVLS + 1];
67
68 struct mutex srcu_cb_mutex;
69 spinlock_t __private lock;
70 struct mutex srcu_gp_mutex;
71 unsigned int srcu_idx;
72 unsigned long srcu_gp_seq;
73 unsigned long srcu_gp_seq_needed;
74 unsigned long srcu_gp_seq_needed_exp;
75 unsigned long srcu_last_gp_end;
76 struct srcu_data __percpu *sda;
77 unsigned long srcu_barrier_seq;
78 struct mutex srcu_barrier_mutex;
79 struct completion srcu_barrier_completion;
80
81 atomic_t srcu_barrier_cpu_cnt;
82
83
84 struct delayed_work work;
85 struct lockdep_map dep_map;
86};
87
88
89#define SRCU_STATE_IDLE 0
90#define SRCU_STATE_SCAN1 1
91#define SRCU_STATE_SCAN2 2
92
93#define __SRCU_STRUCT_INIT(name, pcpu_name) \
94{ \
95 .sda = &pcpu_name, \
96 .lock = __SPIN_LOCK_UNLOCKED(name.lock), \
97 .srcu_gp_seq_needed = -1UL, \
98 .work = __DELAYED_WORK_INITIALIZER(name.work, NULL, 0), \
99 __SRCU_DEP_MAP_INIT(name) \
100}
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121#ifdef MODULE
122# define __DEFINE_SRCU(name, is_static) \
123 is_static struct srcu_struct name; \
124 struct srcu_struct * const __srcu_struct_##name \
125 __section("___srcu_struct_ptrs") = &name
126#else
127# define __DEFINE_SRCU(name, is_static) \
128 static DEFINE_PER_CPU(struct srcu_data, name##_srcu_data); \
129 is_static struct srcu_struct name = \
130 __SRCU_STRUCT_INIT(name, name##_srcu_data)
131#endif
132#define DEFINE_SRCU(name) __DEFINE_SRCU(name, )
133#define DEFINE_STATIC_SRCU(name) __DEFINE_SRCU(name, static)
134
135void synchronize_srcu_expedited(struct srcu_struct *ssp);
136void srcu_barrier(struct srcu_struct *ssp);
137void srcu_torture_stats_print(struct srcu_struct *ssp, char *tt, char *tf);
138
139#endif
140