Home | History | Annotate | Download | only in linux

Lines Matching defs:srcu

36  * SRCU: Sleepable RCU
38 * (This is not exactly SRCU as Linux implements it; it is my
41 * For each srcu context, representing a related set of read
45 * All new srcu read sections get counted in the active epoch.
55 * no new readers -- srcu uses two counts per CPU instead of one
69 #include <linux/srcu.h>
76 * _init_srcu_struct(srcu, name)
78 * Initialize the srcu state with the specified name. Caller must
87 _init_srcu_struct(struct srcu_struct *srcu, const char *name)
92 srcu->srcu_percpu = percpu_alloc(sizeof(struct srcu_cpu));
93 mutex_init(&srcu->srcu_lock, MUTEX_DEFAULT, IPL_VM);
94 cv_init(&srcu->srcu_cv, name);
95 srcu->srcu_sync = NULL;
96 srcu->srcu_total = 0;
97 srcu->srcu_gen = 0;
101 * cleanup_srcu_struct(srcu)
103 * Finalize an srcu state, which must not be in use right now. If
104 * any srcu read sections might be active, caller must wait for
110 cleanup_srcu_struct(struct srcu_struct *srcu)
115 KASSERTMSG((srcu->srcu_sync == NULL),
117 __func__, curlwp, srcu->srcu_sync);
118 cv_destroy(&srcu->srcu_cv);
119 mutex_destroy(&srcu->srcu_lock);
120 percpu_free(srcu->srcu_percpu, sizeof(struct srcu_cpu));
124 * srcu_adjust(srcu, gen, delta)
132 srcu_adjust(struct srcu_struct *srcu, unsigned gen, int delta)
137 cpu = percpu_getref(srcu->srcu_percpu);
139 percpu_putref(srcu->srcu_percpu);
143 * srcu_read_lock(srcu)
145 * Enter an srcu read section and return a ticket for it. Any
147 * srcu_read_unlock(srcu, ticket).
152 srcu_read_lock(struct srcu_struct *srcu)
161 gen = srcu->srcu_gen;
162 srcu_adjust(srcu, gen, +1);
175 * srcu_read_unlock(srcu, ticket)
177 * Exit an srcu read section started with srcu_read_lock returning
184 srcu_read_unlock(struct srcu_struct *srcu, int ticket)
202 if (__predict_true(gen == srcu->srcu_gen)) {
209 srcu_adjust(srcu, gen, -1);
218 mutex_spin_enter(&srcu->srcu_lock);
219 KASSERT(srcu->srcu_sync != NULL);
220 if (--srcu->srcu_total == 0)
221 cv_broadcast(&srcu->srcu_cv);
222 mutex_spin_exit(&srcu->srcu_lock);
231 * pointer; b is ignored. Transfer the local count of srcu
233 * under the srcu sync lock.
238 struct srcu_struct *srcu = a;
244 mutex_spin_enter(&srcu->srcu_lock);
246 gen = srcu->srcu_gen; /* active generation */
250 cpu = percpu_getref(srcu->srcu_percpu);
252 srcu->srcu_total += local;
255 percpu_putref(srcu->srcu_percpu);
257 mutex_spin_exit(&srcu->srcu_lock);
261 * synchronize_srcu(srcu)
263 * Wait for all srcu readers on all CPUs that may have begun
269 synchronize_srcu(struct srcu_struct *srcu)
275 mutex_spin_enter(&srcu->srcu_lock);
276 while (srcu->srcu_sync != NULL)
277 cv_wait(&srcu->srcu_cv, &srcu->srcu_lock);
278 KASSERT(srcu->srcu_total == 0);
279 srcu->srcu_sync = curlwp;
280 srcu->srcu_gen++;
281 mutex_spin_exit(&srcu->srcu_lock);
288 xc_wait(xc_broadcast(0, synchronize_srcu_xc, srcu, NULL));
294 mutex_spin_enter(&srcu->srcu_lock);
295 while (srcu->srcu_total != 0)
296 cv_wait(&srcu->srcu_cv, &srcu->srcu_lock);
297 srcu->srcu_sync = NULL;
298 cv_broadcast(&srcu->srcu_cv);
299 mutex_spin_exit(&srcu->srcu_lock);
303 * synchronize_srcu_expedited(srcu)
305 * Wait for all srcu readers on all CPUs that may have begun
313 synchronize_srcu_expedited(struct srcu_struct *srcu)
316 synchronize_srcu(srcu);