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#ifdef CONFIG_DEBUG_LOCK_ALLOC
86 struct lockdep_map dep_map;
87#endif
88};
89
90
91#define SRCU_STATE_IDLE 0
92#define SRCU_STATE_SCAN1 1
93#define SRCU_STATE_SCAN2 2
94
95#define __SRCU_STRUCT_INIT(name, pcpu_name) \
96{ \
97 .sda = &pcpu_name, \
98 .lock = __SPIN_LOCK_UNLOCKED(name.lock), \
99 .srcu_gp_seq_needed = -1UL, \
100 .work = __DELAYED_WORK_INITIALIZER(name.work, NULL, 0), \
101 __SRCU_DEP_MAP_INIT(name) \
102}
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123#ifdef MODULE
124# define __DEFINE_SRCU(name, is_static) \
125 is_static struct srcu_struct name; \
126 struct srcu_struct * const __srcu_struct_##name \
127 __section("___srcu_struct_ptrs") = &name
128#else
129# define __DEFINE_SRCU(name, is_static) \
130 static DEFINE_PER_CPU(struct srcu_data, name##_srcu_data); \
131 is_static struct srcu_struct name = \
132 __SRCU_STRUCT_INIT(name, name##_srcu_data)
133#endif
134#define DEFINE_SRCU(name) __DEFINE_SRCU(name, )
135#define DEFINE_STATIC_SRCU(name) __DEFINE_SRCU(name, static)
136
137void synchronize_srcu_expedited(struct srcu_struct *ssp);
138void srcu_barrier(struct srcu_struct *ssp);
139void srcu_torture_stats_print(struct srcu_struct *ssp, char *tt, char *tf);
140
141#endif
142