Lines Matching refs:sp
45 int init_srcu_struct(struct srcu_struct *sp) in init_srcu_struct() argument
47 sp->completed = 0; in init_srcu_struct()
48 mutex_init(&sp->mutex); in init_srcu_struct()
49 sp->per_cpu_ref = alloc_percpu(struct srcu_struct_array); in init_srcu_struct()
50 return (sp->per_cpu_ref ? 0 : -ENOMEM); in init_srcu_struct()
58 static int srcu_readers_active_idx(struct srcu_struct *sp, int idx) in srcu_readers_active_idx() argument
65 sum += per_cpu_ptr(sp->per_cpu_ref, cpu)->c[idx]; in srcu_readers_active_idx()
77 static int srcu_readers_active(struct srcu_struct *sp) in srcu_readers_active() argument
79 return srcu_readers_active_idx(sp, 0) + srcu_readers_active_idx(sp, 1); in srcu_readers_active()
89 void cleanup_srcu_struct(struct srcu_struct *sp) in cleanup_srcu_struct() argument
93 sum = srcu_readers_active(sp); in cleanup_srcu_struct()
97 free_percpu(sp->per_cpu_ref); in cleanup_srcu_struct()
98 sp->per_cpu_ref = NULL; in cleanup_srcu_struct()
109 int srcu_read_lock(struct srcu_struct *sp) in srcu_read_lock() argument
114 idx = sp->completed & 0x1; in srcu_read_lock()
116 per_cpu_ptr(sp->per_cpu_ref, smp_processor_id())->c[idx]++; in srcu_read_lock()
132 void srcu_read_unlock(struct srcu_struct *sp, int idx) in srcu_read_unlock() argument
136 per_cpu_ptr(sp->per_cpu_ref, smp_processor_id())->c[idx]--; in srcu_read_unlock()
154 void synchronize_srcu(struct srcu_struct *sp) in synchronize_srcu() argument
158 idx = sp->completed; in synchronize_srcu()
159 mutex_lock(&sp->mutex); in synchronize_srcu()
171 if ((sp->completed - idx) >= 2) { in synchronize_srcu()
172 mutex_unlock(&sp->mutex); in synchronize_srcu()
190 idx = sp->completed & 0x1; in synchronize_srcu()
191 sp->completed++; in synchronize_srcu()
203 while (srcu_readers_active_idx(sp, idx)) in synchronize_srcu()
236 mutex_unlock(&sp->mutex); in synchronize_srcu()
247 long srcu_batches_completed(struct srcu_struct *sp) in srcu_batches_completed() argument
249 return sp->completed; in srcu_batches_completed()