Lines Matching +full:acquisition +full:- +full:time +full:- +full:ns
1 // SPDX-License-Identifier: GPL-2.0+
3 * Sleepable Read-Copy Update mechanism for mutual exclusion.
11 * For detailed explanation of Read-Copy Update mechanism see -
33 /* Holdoff in nanoseconds for auto-expediting. */
38 /* Overflow-check frequency. N bits roughly says every 2**N grace periods. */
45 * 1: Convert at init_srcu_struct() time.
47 * 3: Decide at boot time based on system shape (default).
63 /* Number of CPUs to trigger init_srcu_struct()-time transition to big. */
71 /* Early-boot callback-management, so early that no lock is required! */
80 /* Wrappers for lock acquisition and release, see raw_spin_lock_rcu_node(). */
117 * Initialize SRCU per-CPU data. Note that statically allocated
120 * is set, don't initialize ->srcu_lock_count[] and ->srcu_unlock_count[].
128 * Initialize the per-CPU srcu_data array, which feeds into the in init_srcu_struct_data()
131 WARN_ON_ONCE(ARRAY_SIZE(sdp->srcu_lock_count) != in init_srcu_struct_data()
132 ARRAY_SIZE(sdp->srcu_unlock_count)); in init_srcu_struct_data()
134 sdp = per_cpu_ptr(ssp->sda, cpu); in init_srcu_struct_data()
136 rcu_segcblist_init(&sdp->srcu_cblist); in init_srcu_struct_data()
137 sdp->srcu_cblist_invoking = false; in init_srcu_struct_data()
138 sdp->srcu_gp_seq_needed = ssp->srcu_sup->srcu_gp_seq; in init_srcu_struct_data()
139 sdp->srcu_gp_seq_needed_exp = ssp->srcu_sup->srcu_gp_seq; in init_srcu_struct_data()
140 sdp->mynode = NULL; in init_srcu_struct_data()
141 sdp->cpu = cpu; in init_srcu_struct_data()
142 INIT_WORK(&sdp->work, srcu_invoke_callbacks); in init_srcu_struct_data()
143 timer_setup(&sdp->delay_work, srcu_delay_timer, 0); in init_srcu_struct_data()
144 sdp->ssp = ssp; in init_srcu_struct_data()
176 ssp->srcu_sup->node = kcalloc(rcu_num_nodes, sizeof(*ssp->srcu_sup->node), gfp_flags); in init_srcu_struct_nodes()
177 if (!ssp->srcu_sup->node) in init_srcu_struct_nodes()
181 ssp->srcu_sup->level[0] = &ssp->srcu_sup->node[0]; in init_srcu_struct_nodes()
183 ssp->srcu_sup->level[i] = ssp->srcu_sup->level[i - 1] + num_rcu_lvl[i - 1]; in init_srcu_struct_nodes()
189 WARN_ON_ONCE(ARRAY_SIZE(snp->srcu_have_cbs) != in init_srcu_struct_nodes()
190 ARRAY_SIZE(snp->srcu_data_have_cbs)); in init_srcu_struct_nodes()
191 for (i = 0; i < ARRAY_SIZE(snp->srcu_have_cbs); i++) { in init_srcu_struct_nodes()
192 snp->srcu_have_cbs[i] = SRCU_SNP_INIT_SEQ; in init_srcu_struct_nodes()
193 snp->srcu_data_have_cbs[i] = 0; in init_srcu_struct_nodes()
195 snp->srcu_gp_seq_needed_exp = SRCU_SNP_INIT_SEQ; in init_srcu_struct_nodes()
196 snp->grplo = -1; in init_srcu_struct_nodes()
197 snp->grphi = -1; in init_srcu_struct_nodes()
198 if (snp == &ssp->srcu_sup->node[0]) { in init_srcu_struct_nodes()
200 snp->srcu_parent = NULL; in init_srcu_struct_nodes()
204 /* Non-root node. */ in init_srcu_struct_nodes()
205 if (snp == ssp->srcu_sup->level[level + 1]) in init_srcu_struct_nodes()
207 snp->srcu_parent = ssp->srcu_sup->level[level - 1] + in init_srcu_struct_nodes()
208 (snp - ssp->srcu_sup->level[level]) / in init_srcu_struct_nodes()
209 levelspread[level - 1]; in init_srcu_struct_nodes()
213 * Initialize the per-CPU srcu_data array, which feeds into the in init_srcu_struct_nodes()
216 level = rcu_num_lvls - 1; in init_srcu_struct_nodes()
217 snp_first = ssp->srcu_sup->level[level]; in init_srcu_struct_nodes()
219 sdp = per_cpu_ptr(ssp->sda, cpu); in init_srcu_struct_nodes()
220 sdp->mynode = &snp_first[cpu / levelspread[level]]; in init_srcu_struct_nodes()
221 for (snp = sdp->mynode; snp != NULL; snp = snp->srcu_parent) { in init_srcu_struct_nodes()
222 if (snp->grplo < 0) in init_srcu_struct_nodes()
223 snp->grplo = cpu; in init_srcu_struct_nodes()
224 snp->grphi = cpu; in init_srcu_struct_nodes()
226 sdp->grpmask = 1UL << (cpu - sdp->mynode->grplo); in init_srcu_struct_nodes()
228 smp_store_release(&ssp->srcu_sup->srcu_size_state, SRCU_SIZE_WAIT_BARRIER); in init_srcu_struct_nodes()
233 * Initialize non-compile-time initialized fields, including the
235 * tells us that ->sda has already been wired up to srcu_data.
240 ssp->srcu_sup = kzalloc(sizeof(*ssp->srcu_sup), GFP_KERNEL); in init_srcu_struct_fields()
241 if (!ssp->srcu_sup) in init_srcu_struct_fields()
242 return -ENOMEM; in init_srcu_struct_fields()
244 spin_lock_init(&ACCESS_PRIVATE(ssp->srcu_sup, lock)); in init_srcu_struct_fields()
245 ssp->srcu_sup->srcu_size_state = SRCU_SIZE_SMALL; in init_srcu_struct_fields()
246 ssp->srcu_sup->node = NULL; in init_srcu_struct_fields()
247 mutex_init(&ssp->srcu_sup->srcu_cb_mutex); in init_srcu_struct_fields()
248 mutex_init(&ssp->srcu_sup->srcu_gp_mutex); in init_srcu_struct_fields()
249 ssp->srcu_idx = 0; in init_srcu_struct_fields()
250 ssp->srcu_sup->srcu_gp_seq = 0; in init_srcu_struct_fields()
251 ssp->srcu_sup->srcu_barrier_seq = 0; in init_srcu_struct_fields()
252 mutex_init(&ssp->srcu_sup->srcu_barrier_mutex); in init_srcu_struct_fields()
253 atomic_set(&ssp->srcu_sup->srcu_barrier_cpu_cnt, 0); in init_srcu_struct_fields()
254 INIT_DELAYED_WORK(&ssp->srcu_sup->work, process_srcu); in init_srcu_struct_fields()
255 ssp->srcu_sup->sda_is_static = is_static; in init_srcu_struct_fields()
257 ssp->sda = alloc_percpu(struct srcu_data); in init_srcu_struct_fields()
258 if (!ssp->sda) { in init_srcu_struct_fields()
260 kfree(ssp->srcu_sup); in init_srcu_struct_fields()
261 return -ENOMEM; in init_srcu_struct_fields()
264 ssp->srcu_sup->srcu_gp_seq_needed_exp = 0; in init_srcu_struct_fields()
265 ssp->srcu_sup->srcu_last_gp_end = ktime_get_mono_fast_ns(); in init_srcu_struct_fields()
266 if (READ_ONCE(ssp->srcu_sup->srcu_size_state) == SRCU_SIZE_SMALL && SRCU_SIZING_IS_INIT()) { in init_srcu_struct_fields()
268 if (!ssp->srcu_sup->sda_is_static) { in init_srcu_struct_fields()
269 free_percpu(ssp->sda); in init_srcu_struct_fields()
270 ssp->sda = NULL; in init_srcu_struct_fields()
271 kfree(ssp->srcu_sup); in init_srcu_struct_fields()
272 return -ENOMEM; in init_srcu_struct_fields()
275 WRITE_ONCE(ssp->srcu_sup->srcu_size_state, SRCU_SIZE_BIG); in init_srcu_struct_fields()
278 ssp->srcu_sup->srcu_ssp = ssp; in init_srcu_struct_fields()
279 smp_store_release(&ssp->srcu_sup->srcu_gp_seq_needed, 0); /* Init done. */ in init_srcu_struct_fields()
288 /* Don't re-initialize a lock while it is held. */ in __init_srcu_struct()
290 lockdep_init_map(&ssp->dep_map, name, key, 0); in __init_srcu_struct()
298 * init_srcu_struct - initialize a sleep-RCU structure
318 lockdep_assert_held(&ACCESS_PRIVATE(ssp->srcu_sup, lock)); in __srcu_transition_to_big()
319 smp_store_release(&ssp->srcu_sup->srcu_size_state, SRCU_SIZE_ALLOC); in __srcu_transition_to_big()
329 /* Double-checked locking on ->srcu_size-state. */ in srcu_transition_to_big()
330 if (smp_load_acquire(&ssp->srcu_sup->srcu_size_state) != SRCU_SIZE_SMALL) in srcu_transition_to_big()
332 spin_lock_irqsave_rcu_node(ssp->srcu_sup, flags); in srcu_transition_to_big()
333 if (smp_load_acquire(&ssp->srcu_sup->srcu_size_state) != SRCU_SIZE_SMALL) { in srcu_transition_to_big()
334 spin_unlock_irqrestore_rcu_node(ssp->srcu_sup, flags); in srcu_transition_to_big()
338 spin_unlock_irqrestore_rcu_node(ssp->srcu_sup, flags); in srcu_transition_to_big()
342 * Check to see if the just-encountered contention event justifies
349 if (!SRCU_SIZING_IS_CONTEND() || ssp->srcu_sup->srcu_size_state) in spin_lock_irqsave_check_contention()
352 if (ssp->srcu_sup->srcu_size_jiffies != j) { in spin_lock_irqsave_check_contention()
353 ssp->srcu_sup->srcu_size_jiffies = j; in spin_lock_irqsave_check_contention()
354 ssp->srcu_sup->srcu_n_lock_retries = 0; in spin_lock_irqsave_check_contention()
356 if (++ssp->srcu_sup->srcu_n_lock_retries <= small_contention_lim) in spin_lock_irqsave_check_contention()
362 * Acquire the specified srcu_data structure's ->lock, but check for
369 struct srcu_struct *ssp = sdp->ssp; in spin_lock_irqsave_sdp_contention()
373 spin_lock_irqsave_rcu_node(ssp->srcu_sup, *flags); in spin_lock_irqsave_sdp_contention()
375 spin_unlock_irqrestore_rcu_node(ssp->srcu_sup, *flags); in spin_lock_irqsave_sdp_contention()
380 * Acquire the specified srcu_struct structure's ->lock, but check for
387 if (spin_trylock_irqsave_rcu_node(ssp->srcu_sup, *flags)) in spin_lock_irqsave_ssp_contention()
389 spin_lock_irqsave_rcu_node(ssp->srcu_sup, *flags); in spin_lock_irqsave_ssp_contention()
394 * First-use initialization of statically allocated srcu_struct
396 * done with compile-time initialization, so this check is added
397 * to each update-side SRCU primitive. Use ssp->lock, which -is-
398 * compile-time initialized, to resolve races involving multiple
399 * CPUs trying to garner first-use privileges.
406 if (!rcu_seq_state(smp_load_acquire(&ssp->srcu_sup->srcu_gp_seq_needed))) /*^^^*/ in check_init_srcu_struct()
408 spin_lock_irqsave_rcu_node(ssp->srcu_sup, flags); in check_init_srcu_struct()
409 if (!rcu_seq_state(ssp->srcu_sup->srcu_gp_seq_needed)) { in check_init_srcu_struct()
410 spin_unlock_irqrestore_rcu_node(ssp->srcu_sup, flags); in check_init_srcu_struct()
414 spin_unlock_irqrestore_rcu_node(ssp->srcu_sup, flags); in check_init_srcu_struct()
418 * Returns approximate total of the readers' ->srcu_lock_count[] values
419 * for the rank of per-CPU counters specified by idx.
427 struct srcu_data *cpuc = per_cpu_ptr(ssp->sda, cpu); in srcu_readers_lock_idx()
429 sum += atomic_long_read(&cpuc->srcu_lock_count[idx]); in srcu_readers_lock_idx()
435 * Returns approximate total of the readers' ->srcu_unlock_count[] values
436 * for the rank of per-CPU counters specified by idx.
445 struct srcu_data *cpuc = per_cpu_ptr(ssp->sda, cpu); in srcu_readers_unlock_idx()
447 sum += atomic_long_read(&cpuc->srcu_unlock_count[idx]); in srcu_readers_unlock_idx()
449 mask = mask | READ_ONCE(cpuc->srcu_nmi_safety); in srcu_readers_unlock_idx()
452 "Mixed NMI-safe readers for srcu_struct at %ps.\n", ssp); in srcu_readers_unlock_idx()
457 * Return true if the number of pre-existing readers is determined to
483 * the current ->srcu_idx but not yet have incremented its CPU's in srcu_readers_active_idx_check()
484 * ->srcu_lock_count[idx] counter. In fact, it is possible in srcu_readers_active_idx_check()
486 * ->srcu_idx and incrementing ->srcu_lock_count[idx]. And there in srcu_readers_active_idx_check()
492 * code for a long time. That now-preempted updater has already in srcu_readers_active_idx_check()
493 * flipped ->srcu_idx (possibly during the preceding grace period), in srcu_readers_active_idx_check()
495 * period), and summed up the ->srcu_unlock_count[idx] counters. in srcu_readers_active_idx_check()
497 * increment the old ->srcu_idx value's ->srcu_lock_count[idx] in srcu_readers_active_idx_check()
501 * the old value of ->srcu_idx and is just about to use that value in srcu_readers_active_idx_check()
502 * to index its increment of ->srcu_lock_count[idx]. But as soon as in srcu_readers_active_idx_check()
503 * it leaves that SRCU read-side critical section, it will increment in srcu_readers_active_idx_check()
504 * ->srcu_unlock_count[idx], which must follow the updater's above in srcu_readers_active_idx_check()
506 * an smp_mb() and a later fetch from ->srcu_idx, that task will be in srcu_readers_active_idx_check()
508 * ->srcu_unlock_count[idx] in __srcu_read_unlock() is after the in srcu_readers_active_idx_check()
509 * smp_mb(), and the fetch from ->srcu_idx in __srcu_read_lock() in srcu_readers_active_idx_check()
511 * value of ->srcu_idx until the -second- __srcu_read_lock(), in srcu_readers_active_idx_check()
513 * ->srcu_lock_count[idx] for the old value of ->srcu_idx twice, in srcu_readers_active_idx_check()
521 * ->srcu_lock_count[idx] for the old index, where Nc is the number in srcu_readers_active_idx_check()
531 * comfortably beyond excessive. Especially on 64-bit systems, in srcu_readers_active_idx_check()
539 * srcu_readers_active - returns true if there are readers. and false
545 * can be useful as an error check at cleanup time.
553 struct srcu_data *cpuc = per_cpu_ptr(ssp->sda, cpu); in srcu_readers_active()
555 sum += atomic_long_read(&cpuc->srcu_lock_count[0]); in srcu_readers_active()
556 sum += atomic_long_read(&cpuc->srcu_lock_count[1]); in srcu_readers_active()
557 sum -= atomic_long_read(&cpuc->srcu_unlock_count[0]); in srcu_readers_active()
558 sum -= atomic_long_read(&cpuc->srcu_unlock_count[1]); in srcu_readers_active()
565 * synchronize_srcu_expedited(). We spin for a fixed time period
566 * (defined below, boot time configurable) to allow SRCU readers to exit
567 * their read-side critical sections. If there are still some readers
568 * after one jiffy, we repeatedly block for one jiffy time periods.
569 * The blocking time is increased as the grace-period age increases,
570 * with max blocking time capped at 10 jiffies.
580 #define SRCU_DEFAULT_MAX_NODELAY_PHASE_LO 3UL // Lowmark on default per-GP-phase
581 // no-delay instances.
582 #define SRCU_DEFAULT_MAX_NODELAY_PHASE_HI 1000UL // Highmark on default per-GP-phase
583 // no-delay instances.
588 // per-GP-phase no-delay instances adjusted to allow non-sleeping poll upto
589 // one jiffies time duration. Mult by 2 is done to factor in the srcu_get_delay()
594 // Maximum per-GP-phase consecutive no-delay instances.
603 // Maximum consecutive no-delay instances.
611 * Return grace-period delay, zero if there are expedited grace
619 struct srcu_usage *sup = ssp->srcu_sup; in srcu_get_delay()
621 if (ULONG_CMP_LT(READ_ONCE(sup->srcu_gp_seq), READ_ONCE(sup->srcu_gp_seq_needed_exp))) in srcu_get_delay()
623 if (rcu_seq_state(READ_ONCE(sup->srcu_gp_seq))) { in srcu_get_delay()
624 j = jiffies - 1; in srcu_get_delay()
625 gpstart = READ_ONCE(sup->srcu_gp_start); in srcu_get_delay()
627 jbase += j - gpstart; in srcu_get_delay()
629 WRITE_ONCE(sup->srcu_n_exp_nodelay, READ_ONCE(sup->srcu_n_exp_nodelay) + 1); in srcu_get_delay()
630 if (READ_ONCE(sup->srcu_n_exp_nodelay) > srcu_max_nodelay_phase) in srcu_get_delay()
638 * cleanup_srcu_struct - deconstruct a sleep-RCU structure
647 struct srcu_usage *sup = ssp->srcu_sup; in cleanup_srcu_struct()
653 flush_delayed_work(&sup->work); in cleanup_srcu_struct()
655 struct srcu_data *sdp = per_cpu_ptr(ssp->sda, cpu); in cleanup_srcu_struct()
657 del_timer_sync(&sdp->delay_work); in cleanup_srcu_struct()
658 flush_work(&sdp->work); in cleanup_srcu_struct()
659 if (WARN_ON(rcu_segcblist_n_cbs(&sdp->srcu_cblist))) in cleanup_srcu_struct()
662 if (WARN_ON(rcu_seq_state(READ_ONCE(sup->srcu_gp_seq)) != SRCU_STATE_IDLE) || in cleanup_srcu_struct()
663 WARN_ON(rcu_seq_current(&sup->srcu_gp_seq) != sup->srcu_gp_seq_needed) || in cleanup_srcu_struct()
666 __func__, ssp, rcu_seq_state(READ_ONCE(sup->srcu_gp_seq)), in cleanup_srcu_struct()
667 rcu_seq_current(&sup->srcu_gp_seq), sup->srcu_gp_seq_needed); in cleanup_srcu_struct()
670 kfree(sup->node); in cleanup_srcu_struct()
671 sup->node = NULL; in cleanup_srcu_struct()
672 sup->srcu_size_state = SRCU_SIZE_SMALL; in cleanup_srcu_struct()
673 if (!sup->sda_is_static) { in cleanup_srcu_struct()
674 free_percpu(ssp->sda); in cleanup_srcu_struct()
675 ssp->sda = NULL; in cleanup_srcu_struct()
677 ssp->srcu_sup = NULL; in cleanup_srcu_struct()
692 /* NMI-unsafe use in NMI is a bad sign */ in srcu_check_nmi_safety()
694 sdp = raw_cpu_ptr(ssp->sda); in srcu_check_nmi_safety()
695 old_nmi_safe_mask = READ_ONCE(sdp->srcu_nmi_safety); in srcu_check_nmi_safety()
697 WRITE_ONCE(sdp->srcu_nmi_safety, nmi_safe_mask); in srcu_check_nmi_safety()
700 …WARN_ONCE(old_nmi_safe_mask != nmi_safe_mask, "CPU %d old state %d new state %d\n", sdp->cpu, old_… in srcu_check_nmi_safety()
706 * Counts the new reader in the appropriate per-CPU element of the
714 idx = READ_ONCE(ssp->srcu_idx) & 0x1; in __srcu_read_lock()
715 this_cpu_inc(ssp->sda->srcu_lock_count[idx].counter); in __srcu_read_lock()
722 * Removes the count for the old reader from the appropriate per-CPU
729 this_cpu_inc(ssp->sda->srcu_unlock_count[idx].counter); in __srcu_read_unlock()
736 * Counts the new reader in the appropriate per-CPU element of the
737 * srcu_struct, but in an NMI-safe manner using RMW atomics.
743 struct srcu_data *sdp = raw_cpu_ptr(ssp->sda); in __srcu_read_lock_nmisafe()
745 idx = READ_ONCE(ssp->srcu_idx) & 0x1; in __srcu_read_lock_nmisafe()
746 atomic_long_inc(&sdp->srcu_lock_count[idx]); in __srcu_read_lock_nmisafe()
753 * Removes the count for the old reader from the appropriate per-CPU
759 struct srcu_data *sdp = raw_cpu_ptr(ssp->sda); in __srcu_read_unlock_nmisafe()
762 atomic_long_inc(&sdp->srcu_unlock_count[idx]); in __srcu_read_unlock_nmisafe()
776 if (smp_load_acquire(&ssp->srcu_sup->srcu_size_state) < SRCU_SIZE_WAIT_BARRIER) in srcu_gp_start()
777 sdp = per_cpu_ptr(ssp->sda, get_boot_cpu_id()); in srcu_gp_start()
779 sdp = this_cpu_ptr(ssp->sda); in srcu_gp_start()
780 lockdep_assert_held(&ACCESS_PRIVATE(ssp->srcu_sup, lock)); in srcu_gp_start()
781 WARN_ON_ONCE(ULONG_CMP_GE(ssp->srcu_sup->srcu_gp_seq, ssp->srcu_sup->srcu_gp_seq_needed)); in srcu_gp_start()
783 rcu_segcblist_advance(&sdp->srcu_cblist, in srcu_gp_start()
784 rcu_seq_current(&ssp->srcu_sup->srcu_gp_seq)); in srcu_gp_start()
785 WARN_ON_ONCE(!rcu_segcblist_segempty(&sdp->srcu_cblist, RCU_NEXT_TAIL)); in srcu_gp_start()
787 WRITE_ONCE(ssp->srcu_sup->srcu_gp_start, jiffies); in srcu_gp_start()
788 WRITE_ONCE(ssp->srcu_sup->srcu_n_exp_nodelay, 0); in srcu_gp_start()
789 smp_mb(); /* Order prior store to ->srcu_gp_seq_needed vs. GP start. */ in srcu_gp_start()
790 rcu_seq_start(&ssp->srcu_sup->srcu_gp_seq); in srcu_gp_start()
791 state = rcu_seq_state(ssp->srcu_sup->srcu_gp_seq); in srcu_gp_start()
800 queue_work_on(sdp->cpu, rcu_gp_wq, &sdp->work); in srcu_delay_timer()
807 queue_work_on(sdp->cpu, rcu_gp_wq, &sdp->work); in srcu_queue_delayed_work_on()
811 timer_reduce(&sdp->delay_work, jiffies + delay); in srcu_queue_delayed_work_on()
826 * just-completed grace period, the one corresponding to idx. If possible,
834 for (cpu = snp->grplo; cpu <= snp->grphi; cpu++) { in srcu_schedule_cbs_snp()
835 if (!(mask & (1UL << (cpu - snp->grplo)))) in srcu_schedule_cbs_snp()
837 srcu_schedule_cbs_sdp(per_cpu_ptr(ssp->sda, cpu), delay); in srcu_schedule_cbs_snp()
845 * The ->srcu_cb_mutex acquisition does not protect any data, but
847 * are initiating callback invocation. This allows the ->srcu_have_cbs[]
864 struct srcu_usage *sup = ssp->srcu_sup; in srcu_gp_end()
867 mutex_lock(&sup->srcu_cb_mutex); in srcu_gp_end()
871 idx = rcu_seq_state(sup->srcu_gp_seq); in srcu_gp_end()
873 if (ULONG_CMP_LT(READ_ONCE(sup->srcu_gp_seq), READ_ONCE(sup->srcu_gp_seq_needed_exp))) in srcu_gp_end()
876 WRITE_ONCE(sup->srcu_last_gp_end, ktime_get_mono_fast_ns()); in srcu_gp_end()
877 rcu_seq_end(&sup->srcu_gp_seq); in srcu_gp_end()
878 gpseq = rcu_seq_current(&sup->srcu_gp_seq); in srcu_gp_end()
879 if (ULONG_CMP_LT(sup->srcu_gp_seq_needed_exp, gpseq)) in srcu_gp_end()
880 WRITE_ONCE(sup->srcu_gp_seq_needed_exp, gpseq); in srcu_gp_end()
882 mutex_unlock(&sup->srcu_gp_mutex); in srcu_gp_end()
886 ss_state = smp_load_acquire(&sup->srcu_size_state); in srcu_gp_end()
888 srcu_schedule_cbs_sdp(per_cpu_ptr(ssp->sda, get_boot_cpu_id()), in srcu_gp_end()
891 idx = rcu_seq_ctr(gpseq) % ARRAY_SIZE(snp->srcu_have_cbs); in srcu_gp_end()
895 last_lvl = snp >= sup->level[rcu_num_lvls - 1]; in srcu_gp_end()
897 cbs = ss_state < SRCU_SIZE_BIG || snp->srcu_have_cbs[idx] == gpseq; in srcu_gp_end()
898 snp->srcu_have_cbs[idx] = gpseq; in srcu_gp_end()
899 rcu_seq_set_state(&snp->srcu_have_cbs[idx], 1); in srcu_gp_end()
900 sgsne = snp->srcu_gp_seq_needed_exp; in srcu_gp_end()
902 WRITE_ONCE(snp->srcu_gp_seq_needed_exp, gpseq); in srcu_gp_end()
906 mask = snp->srcu_data_have_cbs[idx]; in srcu_gp_end()
907 snp->srcu_data_have_cbs[idx] = 0; in srcu_gp_end()
917 sdp = per_cpu_ptr(ssp->sda, cpu); in srcu_gp_end()
919 if (ULONG_CMP_GE(gpseq, sdp->srcu_gp_seq_needed + 100)) in srcu_gp_end()
920 sdp->srcu_gp_seq_needed = gpseq; in srcu_gp_end()
921 if (ULONG_CMP_GE(gpseq, sdp->srcu_gp_seq_needed_exp + 100)) in srcu_gp_end()
922 sdp->srcu_gp_seq_needed_exp = gpseq; in srcu_gp_end()
927 mutex_unlock(&sup->srcu_cb_mutex); in srcu_gp_end()
931 gpseq = rcu_seq_current(&sup->srcu_gp_seq); in srcu_gp_end()
933 ULONG_CMP_LT(gpseq, sup->srcu_gp_seq_needed)) { in srcu_gp_end()
946 smp_store_release(&sup->srcu_size_state, ss_state + 1); in srcu_gp_end()
951 * Funnel-locking scheme to scalably mediate many concurrent expedited
952 * grace-period requests. This function is invoked for the first known
964 for (; snp != NULL; snp = snp->srcu_parent) { in srcu_funnel_exp_start()
965 sgsne = READ_ONCE(snp->srcu_gp_seq_needed_exp); in srcu_funnel_exp_start()
966 if (WARN_ON_ONCE(rcu_seq_done(&ssp->srcu_sup->srcu_gp_seq, s)) || in srcu_funnel_exp_start()
970 sgsne = snp->srcu_gp_seq_needed_exp; in srcu_funnel_exp_start()
975 WRITE_ONCE(snp->srcu_gp_seq_needed_exp, s); in srcu_funnel_exp_start()
979 if (ULONG_CMP_LT(ssp->srcu_sup->srcu_gp_seq_needed_exp, s)) in srcu_funnel_exp_start()
980 WRITE_ONCE(ssp->srcu_sup->srcu_gp_seq_needed_exp, s); in srcu_funnel_exp_start()
981 spin_unlock_irqrestore_rcu_node(ssp->srcu_sup, flags); in srcu_funnel_exp_start()
985 * Funnel-locking scheme to scalably mediate many concurrent grace-period
987 * period s. Losers must either ensure that their desired grace-period
1001 int idx = rcu_seq_ctr(s) % ARRAY_SIZE(sdp->mynode->srcu_have_cbs); in srcu_funnel_gp_start()
1006 struct srcu_usage *sup = ssp->srcu_sup; in srcu_funnel_gp_start()
1009 if (smp_load_acquire(&sup->srcu_size_state) < SRCU_SIZE_WAIT_BARRIER) in srcu_funnel_gp_start()
1012 snp_leaf = sdp->mynode; in srcu_funnel_gp_start()
1016 for (snp = snp_leaf; snp != NULL; snp = snp->srcu_parent) { in srcu_funnel_gp_start()
1017 if (WARN_ON_ONCE(rcu_seq_done(&sup->srcu_gp_seq, s)) && snp != snp_leaf) in srcu_funnel_gp_start()
1020 snp_seq = snp->srcu_have_cbs[idx]; in srcu_funnel_gp_start()
1023 snp->srcu_data_have_cbs[idx] |= sdp->grpmask; in srcu_funnel_gp_start()
1033 snp->srcu_have_cbs[idx] = s; in srcu_funnel_gp_start()
1035 snp->srcu_data_have_cbs[idx] |= sdp->grpmask; in srcu_funnel_gp_start()
1036 sgsne = snp->srcu_gp_seq_needed_exp; in srcu_funnel_gp_start()
1038 WRITE_ONCE(snp->srcu_gp_seq_needed_exp, s); in srcu_funnel_gp_start()
1044 if (ULONG_CMP_LT(sup->srcu_gp_seq_needed, s)) { in srcu_funnel_gp_start()
1049 smp_store_release(&sup->srcu_gp_seq_needed, s); /*^^^*/ in srcu_funnel_gp_start()
1051 if (!do_norm && ULONG_CMP_LT(sup->srcu_gp_seq_needed_exp, s)) in srcu_funnel_gp_start()
1052 WRITE_ONCE(sup->srcu_gp_seq_needed_exp, s); in srcu_funnel_gp_start()
1055 if (!WARN_ON_ONCE(rcu_seq_done(&sup->srcu_gp_seq, s)) && in srcu_funnel_gp_start()
1056 rcu_seq_state(sup->srcu_gp_seq) == SRCU_STATE_IDLE) { in srcu_funnel_gp_start()
1057 WARN_ON_ONCE(ULONG_CMP_GE(sup->srcu_gp_seq, sup->srcu_gp_seq_needed)); in srcu_funnel_gp_start()
1066 queue_delayed_work(rcu_gp_wq, &sup->work, in srcu_funnel_gp_start()
1068 else if (list_empty(&sup->work.work.entry)) in srcu_funnel_gp_start()
1069 list_add(&sup->work.work.entry, &srcu_boot_list); in srcu_funnel_gp_start()
1076 * loop an additional time if there is an expedited grace period pending.
1077 * The caller must ensure that ->srcu_idx is not changed while checking.
1088 if ((--trycount + curdelay) <= 0) in try_check_zero()
1095 * Increment the ->srcu_idx counter so that future SRCU readers will
1096 * use the other rank of the ->srcu_(un)lock_count[] arrays. This allows
1097 * us to wait for pre-existing readers in a starvation-free manner.
1102 * Because the flip of ->srcu_idx is executed only if the in srcu_flip()
1104 * the ->srcu_unlock_count[] and ->srcu_lock_count[] sums matched in srcu_flip()
1109 * __srcu_read_lock(), that reader was using a value of ->srcu_idx in srcu_flip()
1114 * value of ->srcu_idx. in srcu_flip()
1116 * This sum-equality check and ordering also ensures that if in srcu_flip()
1118 * ->srcu_idx, this updater's earlier scans cannot have seen in srcu_flip()
1131 WRITE_ONCE(ssp->srcu_idx, ssp->srcu_idx + 1); // Flip the counter. in srcu_flip()
1147 * Note that it is OK for several current from-idle requests for a new
1158 * This function is also subject to counter-wrap errors, but let's face
1159 * it, if this function was preempted for enough time for the counters
1162 * negligible when amortized over that time period, and the extra latency
1163 * of a needlessly non-expedited grace period is similarly negligible.
1175 sdp = raw_cpu_ptr(ssp->sda); in srcu_might_be_idle()
1177 if (rcu_segcblist_pend_cbs(&sdp->srcu_cblist)) { in srcu_might_be_idle()
1189 /* First, see if enough time has passed since the last GP. */ in srcu_might_be_idle()
1191 tlast = READ_ONCE(ssp->srcu_sup->srcu_last_gp_end); in srcu_might_be_idle()
1197 curseq = rcu_seq_current(&ssp->srcu_sup->srcu_gp_seq); in srcu_might_be_idle()
1198 smp_mb(); /* Order ->srcu_gp_seq with ->srcu_gp_seq_needed. */ in srcu_might_be_idle()
1199 if (ULONG_CMP_LT(curseq, READ_ONCE(ssp->srcu_sup->srcu_gp_seq_needed))) in srcu_might_be_idle()
1201 smp_mb(); /* Order ->srcu_gp_seq with prior access. */ in srcu_might_be_idle()
1202 if (curseq != rcu_seq_current(&ssp->srcu_sup->srcu_gp_seq)) in srcu_might_be_idle()
1215 * Start an SRCU grace period, and also queue the callback if non-NULL.
1232 * SRCU read-side critical section so that the grace-period in srcu_gp_start_if_needed()
1236 ss_state = smp_load_acquire(&ssp->srcu_sup->srcu_size_state); in srcu_gp_start_if_needed()
1238 sdp = per_cpu_ptr(ssp->sda, get_boot_cpu_id()); in srcu_gp_start_if_needed()
1240 sdp = raw_cpu_ptr(ssp->sda); in srcu_gp_start_if_needed()
1243 rcu_segcblist_enqueue(&sdp->srcu_cblist, rhp); in srcu_gp_start_if_needed()
1271 s = rcu_seq_snap(&ssp->srcu_sup->srcu_gp_seq); in srcu_gp_start_if_needed()
1272 rcu_segcblist_advance(&sdp->srcu_cblist, in srcu_gp_start_if_needed()
1273 rcu_seq_current(&ssp->srcu_sup->srcu_gp_seq)); in srcu_gp_start_if_needed()
1274 WARN_ON_ONCE(!rcu_segcblist_accelerate(&sdp->srcu_cblist, s) && rhp); in srcu_gp_start_if_needed()
1275 if (ULONG_CMP_LT(sdp->srcu_gp_seq_needed, s)) { in srcu_gp_start_if_needed()
1276 sdp->srcu_gp_seq_needed = s; in srcu_gp_start_if_needed()
1279 if (!do_norm && ULONG_CMP_LT(sdp->srcu_gp_seq_needed_exp, s)) { in srcu_gp_start_if_needed()
1280 sdp->srcu_gp_seq_needed_exp = s; in srcu_gp_start_if_needed()
1289 sdp_mynode = sdp->mynode; in srcu_gp_start_if_needed()
1302 * grace-period processing if it is not already running.
1305 * all pre-existing SRCU read-side critical section. On systems with
1308 * its last corresponding SRCU read-side critical section whose beginning
1310 * an SRCU read-side critical section that continues beyond the start of
1312 * but before the beginning of that SRCU read-side critical section.
1318 * B are guaranteed to execute a full memory barrier during the time
1332 WRITE_ONCE(rhp->func, srcu_leak_callback); in __call_srcu()
1336 rhp->func = func; in __call_srcu()
1341 * call_srcu() - Queue a callback for invocation after an SRCU grace period
1346 * The callback function will be invoked some time after a full SRCU
1347 * grace period elapses, in other words after all pre-existing SRCU
1348 * read-side critical sections have completed. However, the callback
1349 * function might well execute concurrently with other SRCU read-side
1351 * read-side critical sections are delimited by srcu_read_lock() and
1371 srcu_lock_sync(&ssp->dep_map); in __synchronize_srcu()
1377 "Illegal synchronize_srcu() in same-type SRCU (or in RCU) read-side critical section"); in __synchronize_srcu()
1400 * synchronize_srcu_expedited - Brute-force SRCU grace period
1407 * memory-ordering properties as does synchronize_srcu().
1416 * synchronize_srcu - wait for prior SRCU read-side critical-section completion
1421 * the index=((->srcu_idx & 1) ^ 1) to drain to zero at first,
1427 * SRCU read-side critical section; doing so will result in deadlock.
1429 * srcu_struct from some other srcu_struct's read-side critical section,
1432 * There are memory-ordering constraints implied by synchronize_srcu().
1435 * the end of its last corresponding SRCU read-side critical section
1437 * each CPU having an SRCU read-side critical section that extends beyond
1440 * the beginning of that SRCU read-side critical section. Note that these
1450 * Of course, these memory-ordering guarantees apply only when
1454 * Implementation of these memory-ordering guarantees is similar to
1472 * get_state_synchronize_srcu - Provide an end-of-grace-period cookie
1483 // Any prior manipulation of SRCU-protected data must happen in get_state_synchronize_srcu()
1484 // before the load from ->srcu_gp_seq. in get_state_synchronize_srcu()
1486 return rcu_seq_snap(&ssp->srcu_sup->srcu_gp_seq); in get_state_synchronize_srcu()
1491 * start_poll_synchronize_srcu - Provide cookie and start grace period
1507 * poll_state_synchronize_srcu - Has cookie's grace period ended?
1513 * returns @true if an SRCU grace period elapsed since the time that the
1517 * This is more pronounced on 32-bit systems where cookies are 32 bits,
1519 * 25-microsecond expedited SRCU grace periods. However, a more likely
1521 * one-millisecond SRCU grace periods. Of course, wrapping in a 64-bit
1527 * a 16-bit cookie, which rcutorture routinely wraps in a matter of a
1533 if (!rcu_seq_done(&ssp->srcu_sup->srcu_gp_seq, cookie)) in poll_state_synchronize_srcu()
1551 ssp = sdp->ssp; in srcu_barrier_cb()
1552 if (atomic_dec_and_test(&ssp->srcu_sup->srcu_barrier_cpu_cnt)) in srcu_barrier_cb()
1553 complete(&ssp->srcu_sup->srcu_barrier_completion); in srcu_barrier_cb()
1558 * structure's ->cblist. but only if that ->cblist already has at least one
1567 atomic_inc(&ssp->srcu_sup->srcu_barrier_cpu_cnt); in srcu_barrier_one_cpu()
1568 sdp->srcu_barrier_head.func = srcu_barrier_cb; in srcu_barrier_one_cpu()
1569 debug_rcu_head_queue(&sdp->srcu_barrier_head); in srcu_barrier_one_cpu()
1570 if (!rcu_segcblist_entrain(&sdp->srcu_cblist, in srcu_barrier_one_cpu()
1571 &sdp->srcu_barrier_head)) { in srcu_barrier_one_cpu()
1572 debug_rcu_head_unqueue(&sdp->srcu_barrier_head); in srcu_barrier_one_cpu()
1573 atomic_dec(&ssp->srcu_sup->srcu_barrier_cpu_cnt); in srcu_barrier_one_cpu()
1579 * srcu_barrier - Wait until all in-flight call_srcu() callbacks complete.
1580 * @ssp: srcu_struct on which to wait for in-flight callbacks.
1586 unsigned long s = rcu_seq_snap(&ssp->srcu_sup->srcu_barrier_seq); in srcu_barrier()
1589 mutex_lock(&ssp->srcu_sup->srcu_barrier_mutex); in srcu_barrier()
1590 if (rcu_seq_done(&ssp->srcu_sup->srcu_barrier_seq, s)) { in srcu_barrier()
1592 mutex_unlock(&ssp->srcu_sup->srcu_barrier_mutex); in srcu_barrier()
1595 rcu_seq_start(&ssp->srcu_sup->srcu_barrier_seq); in srcu_barrier()
1596 init_completion(&ssp->srcu_sup->srcu_barrier_completion); in srcu_barrier()
1599 atomic_set(&ssp->srcu_sup->srcu_barrier_cpu_cnt, 1); in srcu_barrier()
1602 if (smp_load_acquire(&ssp->srcu_sup->srcu_size_state) < SRCU_SIZE_WAIT_BARRIER) in srcu_barrier()
1603 srcu_barrier_one_cpu(ssp, per_cpu_ptr(ssp->sda, get_boot_cpu_id())); in srcu_barrier()
1606 srcu_barrier_one_cpu(ssp, per_cpu_ptr(ssp->sda, cpu)); in srcu_barrier()
1610 if (atomic_dec_and_test(&ssp->srcu_sup->srcu_barrier_cpu_cnt)) in srcu_barrier()
1611 complete(&ssp->srcu_sup->srcu_barrier_completion); in srcu_barrier()
1612 wait_for_completion(&ssp->srcu_sup->srcu_barrier_completion); in srcu_barrier()
1614 rcu_seq_end(&ssp->srcu_sup->srcu_barrier_seq); in srcu_barrier()
1615 mutex_unlock(&ssp->srcu_sup->srcu_barrier_mutex); in srcu_barrier()
1620 * srcu_batches_completed - return batches completed.
1628 return READ_ONCE(ssp->srcu_idx); in srcu_batches_completed()
1633 * Core SRCU state machine. Push state bits of ->srcu_gp_seq
1641 mutex_lock(&ssp->srcu_sup->srcu_gp_mutex); in srcu_advance_state()
1645 * fetching ->srcu_idx for their index, at any point in time there in srcu_advance_state()
1650 * The load-acquire ensures that we see the accesses performed in srcu_advance_state()
1653 idx = rcu_seq_state(smp_load_acquire(&ssp->srcu_sup->srcu_gp_seq)); /* ^^^ */ in srcu_advance_state()
1655 spin_lock_irq_rcu_node(ssp->srcu_sup); in srcu_advance_state()
1656 if (ULONG_CMP_GE(ssp->srcu_sup->srcu_gp_seq, ssp->srcu_sup->srcu_gp_seq_needed)) { in srcu_advance_state()
1657 WARN_ON_ONCE(rcu_seq_state(ssp->srcu_sup->srcu_gp_seq)); in srcu_advance_state()
1658 spin_unlock_irq_rcu_node(ssp->srcu_sup); in srcu_advance_state()
1659 mutex_unlock(&ssp->srcu_sup->srcu_gp_mutex); in srcu_advance_state()
1662 idx = rcu_seq_state(READ_ONCE(ssp->srcu_sup->srcu_gp_seq)); in srcu_advance_state()
1665 spin_unlock_irq_rcu_node(ssp->srcu_sup); in srcu_advance_state()
1667 mutex_unlock(&ssp->srcu_sup->srcu_gp_mutex); in srcu_advance_state()
1672 if (rcu_seq_state(READ_ONCE(ssp->srcu_sup->srcu_gp_seq)) == SRCU_STATE_SCAN1) { in srcu_advance_state()
1673 idx = 1 ^ (ssp->srcu_idx & 1); in srcu_advance_state()
1675 mutex_unlock(&ssp->srcu_sup->srcu_gp_mutex); in srcu_advance_state()
1679 spin_lock_irq_rcu_node(ssp->srcu_sup); in srcu_advance_state()
1680 rcu_seq_set_state(&ssp->srcu_sup->srcu_gp_seq, SRCU_STATE_SCAN2); in srcu_advance_state()
1681 ssp->srcu_sup->srcu_n_exp_nodelay = 0; in srcu_advance_state()
1682 spin_unlock_irq_rcu_node(ssp->srcu_sup); in srcu_advance_state()
1685 if (rcu_seq_state(READ_ONCE(ssp->srcu_sup->srcu_gp_seq)) == SRCU_STATE_SCAN2) { in srcu_advance_state()
1688 * SRCU read-side critical sections are normally short, in srcu_advance_state()
1691 idx = 1 ^ (ssp->srcu_idx & 1); in srcu_advance_state()
1693 mutex_unlock(&ssp->srcu_sup->srcu_gp_mutex); in srcu_advance_state()
1696 ssp->srcu_sup->srcu_n_exp_nodelay = 0; in srcu_advance_state()
1697 srcu_gp_end(ssp); /* Releases ->srcu_gp_mutex. */ in srcu_advance_state()
1718 ssp = sdp->ssp; in srcu_invoke_callbacks()
1721 WARN_ON_ONCE(!rcu_segcblist_segempty(&sdp->srcu_cblist, RCU_NEXT_TAIL)); in srcu_invoke_callbacks()
1722 rcu_segcblist_advance(&sdp->srcu_cblist, in srcu_invoke_callbacks()
1723 rcu_seq_current(&ssp->srcu_sup->srcu_gp_seq)); in srcu_invoke_callbacks()
1724 if (sdp->srcu_cblist_invoking || in srcu_invoke_callbacks()
1725 !rcu_segcblist_ready_cbs(&sdp->srcu_cblist)) { in srcu_invoke_callbacks()
1731 sdp->srcu_cblist_invoking = true; in srcu_invoke_callbacks()
1732 rcu_segcblist_extract_done_cbs(&sdp->srcu_cblist, &ready_cbs); in srcu_invoke_callbacks()
1740 rhp->func(rhp); in srcu_invoke_callbacks()
1750 rcu_segcblist_add_len(&sdp->srcu_cblist, -len); in srcu_invoke_callbacks()
1751 sdp->srcu_cblist_invoking = false; in srcu_invoke_callbacks()
1752 more = rcu_segcblist_ready_cbs(&sdp->srcu_cblist); in srcu_invoke_callbacks()
1760 * more SRCU callbacks queued, otherwise put SRCU into not-running state.
1766 spin_lock_irq_rcu_node(ssp->srcu_sup); in srcu_reschedule()
1767 if (ULONG_CMP_GE(ssp->srcu_sup->srcu_gp_seq, ssp->srcu_sup->srcu_gp_seq_needed)) { in srcu_reschedule()
1768 if (!WARN_ON_ONCE(rcu_seq_state(ssp->srcu_sup->srcu_gp_seq))) { in srcu_reschedule()
1769 /* All requests fulfilled, time to go idle. */ in srcu_reschedule()
1772 } else if (!rcu_seq_state(ssp->srcu_sup->srcu_gp_seq)) { in srcu_reschedule()
1776 spin_unlock_irq_rcu_node(ssp->srcu_sup); in srcu_reschedule()
1779 queue_delayed_work(rcu_gp_wq, &ssp->srcu_sup->work, delay); in srcu_reschedule()
1783 * This is the work-queue function that handles SRCU grace periods.
1793 ssp = sup->srcu_ssp; in process_srcu()
1798 WRITE_ONCE(sup->reschedule_count, 0); in process_srcu()
1801 if (READ_ONCE(sup->reschedule_jiffies) == j) { in process_srcu()
1802 WRITE_ONCE(sup->reschedule_count, READ_ONCE(sup->reschedule_count) + 1); in process_srcu()
1803 if (READ_ONCE(sup->reschedule_count) > srcu_max_nodelay) in process_srcu()
1806 WRITE_ONCE(sup->reschedule_count, 1); in process_srcu()
1807 WRITE_ONCE(sup->reschedule_jiffies, j); in process_srcu()
1820 *gp_seq = rcu_seq_current(&ssp->srcu_sup->srcu_gp_seq); in srcutorture_get_gp_data()
1842 int ss_state = READ_ONCE(ssp->srcu_sup->srcu_size_state); in srcu_torture_stats_print()
1845 idx = ssp->srcu_idx & 0x1; in srcu_torture_stats_print()
1847 ss_state_idx = ARRAY_SIZE(srcu_size_state_name) - 1; in srcu_torture_stats_print()
1849 tt, tf, rcu_seq_current(&ssp->srcu_sup->srcu_gp_seq), ss_state, in srcu_torture_stats_print()
1851 if (!ssp->sda) { in srcu_torture_stats_print()
1853 pr_cont(" No per-CPU srcu_data structures (->sda == NULL).\n"); in srcu_torture_stats_print()
1855 pr_cont(" per-CPU(idx=%d):", idx); in srcu_torture_stats_print()
1862 sdp = per_cpu_ptr(ssp->sda, cpu); in srcu_torture_stats_print()
1863 u0 = data_race(atomic_long_read(&sdp->srcu_unlock_count[!idx])); in srcu_torture_stats_print()
1864 u1 = data_race(atomic_long_read(&sdp->srcu_unlock_count[idx])); in srcu_torture_stats_print()
1872 l0 = data_race(atomic_long_read(&sdp->srcu_lock_count[!idx])); in srcu_torture_stats_print()
1873 l1 = data_race(atomic_long_read(&sdp->srcu_lock_count[idx])); in srcu_torture_stats_print()
1875 c0 = l0 - u0; in srcu_torture_stats_print()
1876 c1 = l1 - u1; in srcu_torture_stats_print()
1879 "C."[rcu_segcblist_empty(&sdp->srcu_cblist)]); in srcu_torture_stats_print()
1894 pr_info("\tNon-default auto-expedite holdoff of %lu ns.\n", exp_holdoff); in srcu_bootup_announce()
1896 pr_info("\tNon-default retry check delay of %lu us.\n", srcu_retry_check_delay); in srcu_bootup_announce()
1898 pr_info("\tNon-default max no-delay of %lu.\n", srcu_max_nodelay); in srcu_bootup_announce()
1899 pr_info("\tMax phase no-delay instances is %lu.\n", srcu_max_nodelay_phase); in srcu_bootup_announce()
1908 /* Decide on srcu_struct-size strategy. */ in srcu_init()
1928 list_del_init(&sup->work.work.entry); in srcu_init()
1930 sup->srcu_size_state == SRCU_SIZE_SMALL) in srcu_init()
1931 sup->srcu_size_state = SRCU_SIZE_ALLOC; in srcu_init()
1932 queue_work(rcu_gp_wq, &sup->work.work); in srcu_init()
1938 /* Initialize any global-scope srcu_struct structures used by this module. */
1943 struct srcu_struct **sspp = mod->srcu_struct_ptrs; in srcu_module_coming()
1945 for (i = 0; i < mod->num_srcu_structs; i++) { in srcu_module_coming()
1947 ssp->sda = alloc_percpu(struct srcu_data); in srcu_module_coming()
1948 if (WARN_ON_ONCE(!ssp->sda)) in srcu_module_coming()
1949 return -ENOMEM; in srcu_module_coming()
1954 /* Clean up any global-scope srcu_struct structures used by this module. */
1959 struct srcu_struct **sspp = mod->srcu_struct_ptrs; in srcu_module_going()
1961 for (i = 0; i < mod->num_srcu_structs; i++) { in srcu_module_going()
1963 if (!rcu_seq_state(smp_load_acquire(&ssp->srcu_sup->srcu_gp_seq_needed)) && in srcu_module_going()
1964 !WARN_ON_ONCE(!ssp->srcu_sup->sda_is_static)) in srcu_module_going()
1967 free_percpu(ssp->sda); in srcu_module_going()