Lines Matching +full:ideal +full:- +full:factor +full:- +full:value
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. */
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! */
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->srcu_barrier_head.next = &sdp->srcu_barrier_head; in init_srcu_struct_data()
141 sdp->mynode = NULL; in init_srcu_struct_data()
142 sdp->cpu = cpu; in init_srcu_struct_data()
143 INIT_WORK(&sdp->work, srcu_invoke_callbacks); in init_srcu_struct_data()
144 timer_setup(&sdp->delay_work, srcu_delay_timer, 0); in init_srcu_struct_data()
145 sdp->ssp = ssp; in init_srcu_struct_data()
177 ssp->srcu_sup->node = kcalloc(rcu_num_nodes, sizeof(*ssp->srcu_sup->node), gfp_flags); in init_srcu_struct_nodes()
178 if (!ssp->srcu_sup->node) in init_srcu_struct_nodes()
182 ssp->srcu_sup->level[0] = &ssp->srcu_sup->node[0]; in init_srcu_struct_nodes()
184 ssp->srcu_sup->level[i] = ssp->srcu_sup->level[i - 1] + num_rcu_lvl[i - 1]; in init_srcu_struct_nodes()
190 WARN_ON_ONCE(ARRAY_SIZE(snp->srcu_have_cbs) != in init_srcu_struct_nodes()
191 ARRAY_SIZE(snp->srcu_data_have_cbs)); in init_srcu_struct_nodes()
192 for (i = 0; i < ARRAY_SIZE(snp->srcu_have_cbs); i++) { in init_srcu_struct_nodes()
193 snp->srcu_have_cbs[i] = SRCU_SNP_INIT_SEQ; in init_srcu_struct_nodes()
194 snp->srcu_data_have_cbs[i] = 0; in init_srcu_struct_nodes()
196 snp->srcu_gp_seq_needed_exp = SRCU_SNP_INIT_SEQ; in init_srcu_struct_nodes()
197 snp->grplo = -1; in init_srcu_struct_nodes()
198 snp->grphi = -1; in init_srcu_struct_nodes()
199 if (snp == &ssp->srcu_sup->node[0]) { in init_srcu_struct_nodes()
201 snp->srcu_parent = NULL; in init_srcu_struct_nodes()
205 /* Non-root node. */ in init_srcu_struct_nodes()
206 if (snp == ssp->srcu_sup->level[level + 1]) in init_srcu_struct_nodes()
208 snp->srcu_parent = ssp->srcu_sup->level[level - 1] + in init_srcu_struct_nodes()
209 (snp - ssp->srcu_sup->level[level]) / in init_srcu_struct_nodes()
210 levelspread[level - 1]; in init_srcu_struct_nodes()
214 * Initialize the per-CPU srcu_data array, which feeds into the in init_srcu_struct_nodes()
217 level = rcu_num_lvls - 1; in init_srcu_struct_nodes()
218 snp_first = ssp->srcu_sup->level[level]; in init_srcu_struct_nodes()
220 sdp = per_cpu_ptr(ssp->sda, cpu); in init_srcu_struct_nodes()
221 sdp->mynode = &snp_first[cpu / levelspread[level]]; in init_srcu_struct_nodes()
222 for (snp = sdp->mynode; snp != NULL; snp = snp->srcu_parent) { in init_srcu_struct_nodes()
223 if (snp->grplo < 0) in init_srcu_struct_nodes()
224 snp->grplo = cpu; in init_srcu_struct_nodes()
225 snp->grphi = cpu; in init_srcu_struct_nodes()
227 sdp->grpmask = 1UL << (cpu - sdp->mynode->grplo); in init_srcu_struct_nodes()
229 smp_store_release(&ssp->srcu_sup->srcu_size_state, SRCU_SIZE_WAIT_BARRIER); in init_srcu_struct_nodes()
234 * Initialize non-compile-time initialized fields, including the
236 * tells us that ->sda has already been wired up to srcu_data.
241 ssp->srcu_sup = kzalloc(sizeof(*ssp->srcu_sup), GFP_KERNEL); in init_srcu_struct_fields()
242 if (!ssp->srcu_sup) in init_srcu_struct_fields()
243 return -ENOMEM; in init_srcu_struct_fields()
245 spin_lock_init(&ACCESS_PRIVATE(ssp->srcu_sup, lock)); in init_srcu_struct_fields()
246 ssp->srcu_sup->srcu_size_state = SRCU_SIZE_SMALL; in init_srcu_struct_fields()
247 ssp->srcu_sup->node = NULL; in init_srcu_struct_fields()
248 mutex_init(&ssp->srcu_sup->srcu_cb_mutex); in init_srcu_struct_fields()
249 mutex_init(&ssp->srcu_sup->srcu_gp_mutex); in init_srcu_struct_fields()
250 ssp->srcu_idx = 0; in init_srcu_struct_fields()
251 ssp->srcu_sup->srcu_gp_seq = SRCU_GP_SEQ_INITIAL_VAL; in init_srcu_struct_fields()
252 ssp->srcu_sup->srcu_barrier_seq = 0; in init_srcu_struct_fields()
253 mutex_init(&ssp->srcu_sup->srcu_barrier_mutex); in init_srcu_struct_fields()
254 atomic_set(&ssp->srcu_sup->srcu_barrier_cpu_cnt, 0); in init_srcu_struct_fields()
255 INIT_DELAYED_WORK(&ssp->srcu_sup->work, process_srcu); in init_srcu_struct_fields()
256 ssp->srcu_sup->sda_is_static = is_static; in init_srcu_struct_fields()
258 ssp->sda = alloc_percpu(struct srcu_data); in init_srcu_struct_fields()
259 if (!ssp->sda) in init_srcu_struct_fields()
262 ssp->srcu_sup->srcu_gp_seq_needed_exp = SRCU_GP_SEQ_INITIAL_VAL; in init_srcu_struct_fields()
263 ssp->srcu_sup->srcu_last_gp_end = ktime_get_mono_fast_ns(); in init_srcu_struct_fields()
264 if (READ_ONCE(ssp->srcu_sup->srcu_size_state) == SRCU_SIZE_SMALL && SRCU_SIZING_IS_INIT()) { in init_srcu_struct_fields()
267 WRITE_ONCE(ssp->srcu_sup->srcu_size_state, SRCU_SIZE_BIG); in init_srcu_struct_fields()
269 ssp->srcu_sup->srcu_ssp = ssp; in init_srcu_struct_fields()
270 smp_store_release(&ssp->srcu_sup->srcu_gp_seq_needed, in init_srcu_struct_fields()
276 free_percpu(ssp->sda); in init_srcu_struct_fields()
277 ssp->sda = NULL; in init_srcu_struct_fields()
281 kfree(ssp->srcu_sup); in init_srcu_struct_fields()
282 ssp->srcu_sup = NULL; in init_srcu_struct_fields()
284 return -ENOMEM; in init_srcu_struct_fields()
292 /* Don't re-initialize a lock while it is held. */ in __init_srcu_struct()
294 lockdep_init_map(&ssp->dep_map, name, key, 0); in __init_srcu_struct()
302 * init_srcu_struct - initialize a sleep-RCU structure
322 lockdep_assert_held(&ACCESS_PRIVATE(ssp->srcu_sup, lock)); in __srcu_transition_to_big()
323 smp_store_release(&ssp->srcu_sup->srcu_size_state, SRCU_SIZE_ALLOC); in __srcu_transition_to_big()
333 /* Double-checked locking on ->srcu_size-state. */ in srcu_transition_to_big()
334 if (smp_load_acquire(&ssp->srcu_sup->srcu_size_state) != SRCU_SIZE_SMALL) in srcu_transition_to_big()
336 spin_lock_irqsave_rcu_node(ssp->srcu_sup, flags); in srcu_transition_to_big()
337 if (smp_load_acquire(&ssp->srcu_sup->srcu_size_state) != SRCU_SIZE_SMALL) { in srcu_transition_to_big()
338 spin_unlock_irqrestore_rcu_node(ssp->srcu_sup, flags); in srcu_transition_to_big()
342 spin_unlock_irqrestore_rcu_node(ssp->srcu_sup, flags); in srcu_transition_to_big()
346 * Check to see if the just-encountered contention event justifies
353 if (!SRCU_SIZING_IS_CONTEND() || ssp->srcu_sup->srcu_size_state) in spin_lock_irqsave_check_contention()
356 if (ssp->srcu_sup->srcu_size_jiffies != j) { in spin_lock_irqsave_check_contention()
357 ssp->srcu_sup->srcu_size_jiffies = j; in spin_lock_irqsave_check_contention()
358 ssp->srcu_sup->srcu_n_lock_retries = 0; in spin_lock_irqsave_check_contention()
360 if (++ssp->srcu_sup->srcu_n_lock_retries <= small_contention_lim) in spin_lock_irqsave_check_contention()
366 * Acquire the specified srcu_data structure's ->lock, but check for
373 struct srcu_struct *ssp = sdp->ssp; in spin_lock_irqsave_sdp_contention()
377 spin_lock_irqsave_rcu_node(ssp->srcu_sup, *flags); in spin_lock_irqsave_sdp_contention()
379 spin_unlock_irqrestore_rcu_node(ssp->srcu_sup, *flags); in spin_lock_irqsave_sdp_contention()
384 * Acquire the specified srcu_struct structure's ->lock, but check for
391 if (spin_trylock_irqsave_rcu_node(ssp->srcu_sup, *flags)) in spin_lock_irqsave_ssp_contention()
393 spin_lock_irqsave_rcu_node(ssp->srcu_sup, *flags); in spin_lock_irqsave_ssp_contention()
398 * First-use initialization of statically allocated srcu_struct
400 * done with compile-time initialization, so this check is added
401 * to each update-side SRCU primitive. Use ssp->lock, which -is-
402 * compile-time initialized, to resolve races involving multiple
403 * CPUs trying to garner first-use privileges.
410 if (!rcu_seq_state(smp_load_acquire(&ssp->srcu_sup->srcu_gp_seq_needed))) /*^^^*/ in check_init_srcu_struct()
412 spin_lock_irqsave_rcu_node(ssp->srcu_sup, flags); in check_init_srcu_struct()
413 if (!rcu_seq_state(ssp->srcu_sup->srcu_gp_seq_needed)) { in check_init_srcu_struct()
414 spin_unlock_irqrestore_rcu_node(ssp->srcu_sup, flags); in check_init_srcu_struct()
418 spin_unlock_irqrestore_rcu_node(ssp->srcu_sup, flags); in check_init_srcu_struct()
422 * Returns approximate total of the readers' ->srcu_lock_count[] values
423 * for the rank of per-CPU counters specified by idx.
431 struct srcu_data *cpuc = per_cpu_ptr(ssp->sda, cpu); in srcu_readers_lock_idx()
433 sum += atomic_long_read(&cpuc->srcu_lock_count[idx]); in srcu_readers_lock_idx()
439 * Returns approximate total of the readers' ->srcu_unlock_count[] values
440 * for the rank of per-CPU counters specified by idx.
449 struct srcu_data *cpuc = per_cpu_ptr(ssp->sda, cpu); in srcu_readers_unlock_idx()
451 sum += atomic_long_read(&cpuc->srcu_unlock_count[idx]); in srcu_readers_unlock_idx()
453 mask = mask | READ_ONCE(cpuc->srcu_nmi_safety); in srcu_readers_unlock_idx()
456 "Mixed NMI-safe readers for srcu_struct at %ps.\n", ssp); in srcu_readers_unlock_idx()
461 * Return true if the number of pre-existing readers is determined to
487 * the current ->srcu_idx but not yet have incremented its CPU's in srcu_readers_active_idx_check()
488 * ->srcu_lock_count[idx] counter. In fact, it is possible in srcu_readers_active_idx_check()
490 * ->srcu_idx and incrementing ->srcu_lock_count[idx]. And there in srcu_readers_active_idx_check()
496 * code for a long time. That now-preempted updater has already in srcu_readers_active_idx_check()
497 * flipped ->srcu_idx (possibly during the preceding grace period), in srcu_readers_active_idx_check()
499 * period), and summed up the ->srcu_unlock_count[idx] counters. in srcu_readers_active_idx_check()
501 * increment the old ->srcu_idx value's ->srcu_lock_count[idx] in srcu_readers_active_idx_check()
505 * the old value of ->srcu_idx and is just about to use that value in srcu_readers_active_idx_check()
506 * to index its increment of ->srcu_lock_count[idx]. But as soon as in srcu_readers_active_idx_check()
507 * it leaves that SRCU read-side critical section, it will increment in srcu_readers_active_idx_check()
508 * ->srcu_unlock_count[idx], which must follow the updater's above in srcu_readers_active_idx_check()
509 * read from that same value. Thus, as soon the reading task does in srcu_readers_active_idx_check()
510 * an smp_mb() and a later fetch from ->srcu_idx, that task will be in srcu_readers_active_idx_check()
512 * ->srcu_unlock_count[idx] in __srcu_read_unlock() is after the in srcu_readers_active_idx_check()
513 * smp_mb(), and the fetch from ->srcu_idx in __srcu_read_lock() in srcu_readers_active_idx_check()
515 * value of ->srcu_idx until the -second- __srcu_read_lock(), in srcu_readers_active_idx_check()
517 * ->srcu_lock_count[idx] for the old value of ->srcu_idx twice, in srcu_readers_active_idx_check()
525 * ->srcu_lock_count[idx] for the old index, where Nc is the number in srcu_readers_active_idx_check()
527 * structure limits the value of Nt and current systems limit Nc in srcu_readers_active_idx_check()
535 * comfortably beyond excessive. Especially on 64-bit systems, in srcu_readers_active_idx_check()
543 * srcu_readers_active - returns true if there are readers. and false
557 struct srcu_data *cpuc = per_cpu_ptr(ssp->sda, cpu); in srcu_readers_active()
559 sum += atomic_long_read(&cpuc->srcu_lock_count[0]); in srcu_readers_active()
560 sum += atomic_long_read(&cpuc->srcu_lock_count[1]); in srcu_readers_active()
561 sum -= atomic_long_read(&cpuc->srcu_unlock_count[0]); in srcu_readers_active()
562 sum -= atomic_long_read(&cpuc->srcu_unlock_count[1]); in srcu_readers_active()
571 * their read-side critical sections. If there are still some readers
573 * The blocking time is increased as the grace-period age increases,
584 #define SRCU_DEFAULT_MAX_NODELAY_PHASE_LO 3UL // Lowmark on default per-GP-phase
585 // no-delay instances.
586 #define SRCU_DEFAULT_MAX_NODELAY_PHASE_HI 1000UL // Highmark on default per-GP-phase
587 // no-delay instances.
592 // per-GP-phase no-delay instances adjusted to allow non-sleeping poll upto
593 // one jiffies time duration. Mult by 2 is done to factor in the srcu_get_delay()
598 // Maximum per-GP-phase consecutive no-delay instances.
607 // Maximum consecutive no-delay instances.
615 * Return grace-period delay, zero if there are expedited grace
623 struct srcu_usage *sup = ssp->srcu_sup; in srcu_get_delay()
625 if (ULONG_CMP_LT(READ_ONCE(sup->srcu_gp_seq), READ_ONCE(sup->srcu_gp_seq_needed_exp))) in srcu_get_delay()
627 if (rcu_seq_state(READ_ONCE(sup->srcu_gp_seq))) { in srcu_get_delay()
628 j = jiffies - 1; in srcu_get_delay()
629 gpstart = READ_ONCE(sup->srcu_gp_start); in srcu_get_delay()
631 jbase += j - gpstart; in srcu_get_delay()
633 ASSERT_EXCLUSIVE_WRITER(sup->srcu_n_exp_nodelay); in srcu_get_delay()
634 WRITE_ONCE(sup->srcu_n_exp_nodelay, READ_ONCE(sup->srcu_n_exp_nodelay) + 1); in srcu_get_delay()
635 if (READ_ONCE(sup->srcu_n_exp_nodelay) > srcu_max_nodelay_phase) in srcu_get_delay()
643 * cleanup_srcu_struct - deconstruct a sleep-RCU structure
652 struct srcu_usage *sup = ssp->srcu_sup; in cleanup_srcu_struct()
658 flush_delayed_work(&sup->work); in cleanup_srcu_struct()
660 struct srcu_data *sdp = per_cpu_ptr(ssp->sda, cpu); in cleanup_srcu_struct()
662 del_timer_sync(&sdp->delay_work); in cleanup_srcu_struct()
663 flush_work(&sdp->work); in cleanup_srcu_struct()
664 if (WARN_ON(rcu_segcblist_n_cbs(&sdp->srcu_cblist))) in cleanup_srcu_struct()
667 if (WARN_ON(rcu_seq_state(READ_ONCE(sup->srcu_gp_seq)) != SRCU_STATE_IDLE) || in cleanup_srcu_struct()
668 WARN_ON(rcu_seq_current(&sup->srcu_gp_seq) != sup->srcu_gp_seq_needed) || in cleanup_srcu_struct()
671 __func__, ssp, rcu_seq_state(READ_ONCE(sup->srcu_gp_seq)), in cleanup_srcu_struct()
672 rcu_seq_current(&sup->srcu_gp_seq), sup->srcu_gp_seq_needed); in cleanup_srcu_struct()
678 kfree(sup->node); in cleanup_srcu_struct()
679 sup->node = NULL; in cleanup_srcu_struct()
680 sup->srcu_size_state = SRCU_SIZE_SMALL; in cleanup_srcu_struct()
681 if (!sup->sda_is_static) { in cleanup_srcu_struct()
682 free_percpu(ssp->sda); in cleanup_srcu_struct()
683 ssp->sda = NULL; in cleanup_srcu_struct()
685 ssp->srcu_sup = NULL; in cleanup_srcu_struct()
700 /* NMI-unsafe use in NMI is a bad sign */ in srcu_check_nmi_safety()
702 sdp = raw_cpu_ptr(ssp->sda); in srcu_check_nmi_safety()
703 old_nmi_safe_mask = READ_ONCE(sdp->srcu_nmi_safety); in srcu_check_nmi_safety()
705 WRITE_ONCE(sdp->srcu_nmi_safety, nmi_safe_mask); in srcu_check_nmi_safety()
708 …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()
714 * Counts the new reader in the appropriate per-CPU element of the
722 idx = READ_ONCE(ssp->srcu_idx) & 0x1; in __srcu_read_lock()
723 this_cpu_inc(ssp->sda->srcu_lock_count[idx].counter); in __srcu_read_lock()
730 * Removes the count for the old reader from the appropriate per-CPU
737 this_cpu_inc(ssp->sda->srcu_unlock_count[idx].counter); in __srcu_read_unlock()
744 * Counts the new reader in the appropriate per-CPU element of the
745 * srcu_struct, but in an NMI-safe manner using RMW atomics.
751 struct srcu_data *sdp = raw_cpu_ptr(ssp->sda); in __srcu_read_lock_nmisafe()
753 idx = READ_ONCE(ssp->srcu_idx) & 0x1; in __srcu_read_lock_nmisafe()
754 atomic_long_inc(&sdp->srcu_lock_count[idx]); in __srcu_read_lock_nmisafe()
761 * Removes the count for the old reader from the appropriate per-CPU
767 struct srcu_data *sdp = raw_cpu_ptr(ssp->sda); in __srcu_read_unlock_nmisafe()
770 atomic_long_inc(&sdp->srcu_unlock_count[idx]); in __srcu_read_unlock_nmisafe()
783 lockdep_assert_held(&ACCESS_PRIVATE(ssp->srcu_sup, lock)); in srcu_gp_start()
784 WARN_ON_ONCE(ULONG_CMP_GE(ssp->srcu_sup->srcu_gp_seq, ssp->srcu_sup->srcu_gp_seq_needed)); in srcu_gp_start()
785 WRITE_ONCE(ssp->srcu_sup->srcu_gp_start, jiffies); in srcu_gp_start()
786 WRITE_ONCE(ssp->srcu_sup->srcu_n_exp_nodelay, 0); in srcu_gp_start()
787 smp_mb(); /* Order prior store to ->srcu_gp_seq_needed vs. GP start. */ in srcu_gp_start()
788 rcu_seq_start(&ssp->srcu_sup->srcu_gp_seq); in srcu_gp_start()
789 state = rcu_seq_state(ssp->srcu_sup->srcu_gp_seq); in srcu_gp_start()
798 queue_work_on(sdp->cpu, rcu_gp_wq, &sdp->work); in srcu_delay_timer()
805 queue_work_on(sdp->cpu, rcu_gp_wq, &sdp->work); in srcu_queue_delayed_work_on()
809 timer_reduce(&sdp->delay_work, jiffies + delay); in srcu_queue_delayed_work_on()
824 * just-completed grace period, the one corresponding to idx. If possible,
832 for (cpu = snp->grplo; cpu <= snp->grphi; cpu++) { in srcu_schedule_cbs_snp()
833 if (!(mask & (1UL << (cpu - snp->grplo)))) in srcu_schedule_cbs_snp()
835 srcu_schedule_cbs_sdp(per_cpu_ptr(ssp->sda, cpu), delay); in srcu_schedule_cbs_snp()
843 * The ->srcu_cb_mutex acquisition does not protect any data, but
845 * are initiating callback invocation. This allows the ->srcu_have_cbs[]
861 struct srcu_usage *sup = ssp->srcu_sup; in srcu_gp_end()
864 mutex_lock(&sup->srcu_cb_mutex); in srcu_gp_end()
868 idx = rcu_seq_state(sup->srcu_gp_seq); in srcu_gp_end()
870 if (ULONG_CMP_LT(READ_ONCE(sup->srcu_gp_seq), READ_ONCE(sup->srcu_gp_seq_needed_exp))) in srcu_gp_end()
873 WRITE_ONCE(sup->srcu_last_gp_end, ktime_get_mono_fast_ns()); in srcu_gp_end()
874 rcu_seq_end(&sup->srcu_gp_seq); in srcu_gp_end()
875 gpseq = rcu_seq_current(&sup->srcu_gp_seq); in srcu_gp_end()
876 if (ULONG_CMP_LT(sup->srcu_gp_seq_needed_exp, gpseq)) in srcu_gp_end()
877 WRITE_ONCE(sup->srcu_gp_seq_needed_exp, gpseq); in srcu_gp_end()
879 mutex_unlock(&sup->srcu_gp_mutex); in srcu_gp_end()
883 ss_state = smp_load_acquire(&sup->srcu_size_state); in srcu_gp_end()
885 srcu_schedule_cbs_sdp(per_cpu_ptr(ssp->sda, get_boot_cpu_id()), in srcu_gp_end()
888 idx = rcu_seq_ctr(gpseq) % ARRAY_SIZE(snp->srcu_have_cbs); in srcu_gp_end()
892 last_lvl = snp >= sup->level[rcu_num_lvls - 1]; in srcu_gp_end()
894 cbs = ss_state < SRCU_SIZE_BIG || snp->srcu_have_cbs[idx] == gpseq; in srcu_gp_end()
895 snp->srcu_have_cbs[idx] = gpseq; in srcu_gp_end()
896 rcu_seq_set_state(&snp->srcu_have_cbs[idx], 1); in srcu_gp_end()
897 sgsne = snp->srcu_gp_seq_needed_exp; in srcu_gp_end()
899 WRITE_ONCE(snp->srcu_gp_seq_needed_exp, gpseq); in srcu_gp_end()
903 mask = snp->srcu_data_have_cbs[idx]; in srcu_gp_end()
904 snp->srcu_data_have_cbs[idx] = 0; in srcu_gp_end()
914 sdp = per_cpu_ptr(ssp->sda, cpu); in srcu_gp_end()
916 if (ULONG_CMP_GE(gpseq, sdp->srcu_gp_seq_needed + 100)) in srcu_gp_end()
917 sdp->srcu_gp_seq_needed = gpseq; in srcu_gp_end()
918 if (ULONG_CMP_GE(gpseq, sdp->srcu_gp_seq_needed_exp + 100)) in srcu_gp_end()
919 sdp->srcu_gp_seq_needed_exp = gpseq; in srcu_gp_end()
924 mutex_unlock(&sup->srcu_cb_mutex); in srcu_gp_end()
928 gpseq = rcu_seq_current(&sup->srcu_gp_seq); in srcu_gp_end()
930 ULONG_CMP_LT(gpseq, sup->srcu_gp_seq_needed)) { in srcu_gp_end()
943 smp_store_release(&sup->srcu_size_state, ss_state + 1); in srcu_gp_end()
948 * Funnel-locking scheme to scalably mediate many concurrent expedited
949 * grace-period requests. This function is invoked for the first known
961 for (; snp != NULL; snp = snp->srcu_parent) { in srcu_funnel_exp_start()
962 sgsne = READ_ONCE(snp->srcu_gp_seq_needed_exp); in srcu_funnel_exp_start()
963 if (WARN_ON_ONCE(rcu_seq_done(&ssp->srcu_sup->srcu_gp_seq, s)) || in srcu_funnel_exp_start()
967 sgsne = snp->srcu_gp_seq_needed_exp; in srcu_funnel_exp_start()
972 WRITE_ONCE(snp->srcu_gp_seq_needed_exp, s); in srcu_funnel_exp_start()
976 if (ULONG_CMP_LT(ssp->srcu_sup->srcu_gp_seq_needed_exp, s)) in srcu_funnel_exp_start()
977 WRITE_ONCE(ssp->srcu_sup->srcu_gp_seq_needed_exp, s); in srcu_funnel_exp_start()
978 spin_unlock_irqrestore_rcu_node(ssp->srcu_sup, flags); in srcu_funnel_exp_start()
982 * Funnel-locking scheme to scalably mediate many concurrent grace-period
984 * period s. Losers must either ensure that their desired grace-period
998 int idx = rcu_seq_ctr(s) % ARRAY_SIZE(sdp->mynode->srcu_have_cbs); in srcu_funnel_gp_start()
1003 struct srcu_usage *sup = ssp->srcu_sup; in srcu_funnel_gp_start()
1006 if (smp_load_acquire(&sup->srcu_size_state) < SRCU_SIZE_WAIT_BARRIER) in srcu_funnel_gp_start()
1009 snp_leaf = sdp->mynode; in srcu_funnel_gp_start()
1013 for (snp = snp_leaf; snp != NULL; snp = snp->srcu_parent) { in srcu_funnel_gp_start()
1014 if (WARN_ON_ONCE(rcu_seq_done(&sup->srcu_gp_seq, s)) && snp != snp_leaf) in srcu_funnel_gp_start()
1017 snp_seq = snp->srcu_have_cbs[idx]; in srcu_funnel_gp_start()
1020 snp->srcu_data_have_cbs[idx] |= sdp->grpmask; in srcu_funnel_gp_start()
1030 snp->srcu_have_cbs[idx] = s; in srcu_funnel_gp_start()
1032 snp->srcu_data_have_cbs[idx] |= sdp->grpmask; in srcu_funnel_gp_start()
1033 sgsne = snp->srcu_gp_seq_needed_exp; in srcu_funnel_gp_start()
1035 WRITE_ONCE(snp->srcu_gp_seq_needed_exp, s); in srcu_funnel_gp_start()
1041 if (ULONG_CMP_LT(sup->srcu_gp_seq_needed, s)) { in srcu_funnel_gp_start()
1046 smp_store_release(&sup->srcu_gp_seq_needed, s); /*^^^*/ in srcu_funnel_gp_start()
1048 if (!do_norm && ULONG_CMP_LT(sup->srcu_gp_seq_needed_exp, s)) in srcu_funnel_gp_start()
1049 WRITE_ONCE(sup->srcu_gp_seq_needed_exp, s); in srcu_funnel_gp_start()
1052 if (!WARN_ON_ONCE(rcu_seq_done(&sup->srcu_gp_seq, s)) && in srcu_funnel_gp_start()
1053 rcu_seq_state(sup->srcu_gp_seq) == SRCU_STATE_IDLE) { in srcu_funnel_gp_start()
1054 WARN_ON_ONCE(ULONG_CMP_GE(sup->srcu_gp_seq, sup->srcu_gp_seq_needed)); in srcu_funnel_gp_start()
1063 queue_delayed_work(rcu_gp_wq, &sup->work, in srcu_funnel_gp_start()
1065 else if (list_empty(&sup->work.work.entry)) in srcu_funnel_gp_start()
1066 list_add(&sup->work.work.entry, &srcu_boot_list); in srcu_funnel_gp_start()
1074 * The caller must ensure that ->srcu_idx is not changed while checking.
1085 if ((--trycount + curdelay) <= 0) in try_check_zero()
1092 * Increment the ->srcu_idx counter so that future SRCU readers will
1093 * use the other rank of the ->srcu_(un)lock_count[] arrays. This allows
1094 * us to wait for pre-existing readers in a starvation-free manner.
1099 * Because the flip of ->srcu_idx is executed only if the in srcu_flip()
1101 * the ->srcu_unlock_count[] and ->srcu_lock_count[] sums matched in srcu_flip()
1106 * __srcu_read_lock(), that reader was using a value of ->srcu_idx in srcu_flip()
1111 * value of ->srcu_idx. in srcu_flip()
1113 * This sum-equality check and ordering also ensures that if in srcu_flip()
1114 * a given call to __srcu_read_lock() uses the new value of in srcu_flip()
1115 * ->srcu_idx, this updater's earlier scans cannot have seen in srcu_flip()
1128 WRITE_ONCE(ssp->srcu_idx, ssp->srcu_idx + 1); // Flip the counter. in srcu_flip()
1144 * Note that it is OK for several current from-idle requests for a new
1150 * ideal, but the overhead of checking all CPUs' callback lists is even
1151 * less ideal, especially on large systems. Furthermore, the wakeup
1155 * This function is also subject to counter-wrap errors, but let's face
1160 * of a needlessly non-expedited grace period is similarly negligible.
1172 sdp = raw_cpu_ptr(ssp->sda); in srcu_might_be_idle()
1174 if (rcu_segcblist_pend_cbs(&sdp->srcu_cblist)) { in srcu_might_be_idle()
1188 tlast = READ_ONCE(ssp->srcu_sup->srcu_last_gp_end); in srcu_might_be_idle()
1194 curseq = rcu_seq_current(&ssp->srcu_sup->srcu_gp_seq); in srcu_might_be_idle()
1195 smp_mb(); /* Order ->srcu_gp_seq with ->srcu_gp_seq_needed. */ in srcu_might_be_idle()
1196 if (ULONG_CMP_LT(curseq, READ_ONCE(ssp->srcu_sup->srcu_gp_seq_needed))) in srcu_might_be_idle()
1198 smp_mb(); /* Order ->srcu_gp_seq with prior access. */ in srcu_might_be_idle()
1199 if (curseq != rcu_seq_current(&ssp->srcu_sup->srcu_gp_seq)) in srcu_might_be_idle()
1212 * Start an SRCU grace period, and also queue the callback if non-NULL.
1229 * SRCU read-side critical section so that the grace-period in srcu_gp_start_if_needed()
1233 ss_state = smp_load_acquire(&ssp->srcu_sup->srcu_size_state); in srcu_gp_start_if_needed()
1235 sdp = per_cpu_ptr(ssp->sda, get_boot_cpu_id()); in srcu_gp_start_if_needed()
1237 sdp = raw_cpu_ptr(ssp->sda); in srcu_gp_start_if_needed()
1240 rcu_segcblist_enqueue(&sdp->srcu_cblist, rhp); in srcu_gp_start_if_needed()
1263 * 3) This value is passed to rcu_segcblist_advance() which can't move in srcu_gp_start_if_needed()
1272 * 5) The value of X + 12 is passed to rcu_segcblist_accelerate() but the in srcu_gp_start_if_needed()
1277 s = rcu_seq_snap(&ssp->srcu_sup->srcu_gp_seq); in srcu_gp_start_if_needed()
1279 rcu_segcblist_advance(&sdp->srcu_cblist, in srcu_gp_start_if_needed()
1280 rcu_seq_current(&ssp->srcu_sup->srcu_gp_seq)); in srcu_gp_start_if_needed()
1283 * used for acceleration is <= the value of gp_seq used for in srcu_gp_start_if_needed()
1288 WARN_ON_ONCE(!rcu_segcblist_accelerate(&sdp->srcu_cblist, s)); in srcu_gp_start_if_needed()
1290 if (ULONG_CMP_LT(sdp->srcu_gp_seq_needed, s)) { in srcu_gp_start_if_needed()
1291 sdp->srcu_gp_seq_needed = s; in srcu_gp_start_if_needed()
1294 if (!do_norm && ULONG_CMP_LT(sdp->srcu_gp_seq_needed_exp, s)) { in srcu_gp_start_if_needed()
1295 sdp->srcu_gp_seq_needed_exp = s; in srcu_gp_start_if_needed()
1304 sdp_mynode = sdp->mynode; in srcu_gp_start_if_needed()
1317 * grace-period processing if it is not already running.
1320 * all pre-existing SRCU read-side critical section. On systems with
1323 * its last corresponding SRCU read-side critical section whose beginning
1325 * an SRCU read-side critical section that continues beyond the start of
1327 * but before the beginning of that SRCU read-side critical section.
1347 WRITE_ONCE(rhp->func, srcu_leak_callback); in __call_srcu()
1351 rhp->func = func; in __call_srcu()
1356 * call_srcu() - Queue a callback for invocation after an SRCU grace period
1362 * grace period elapses, in other words after all pre-existing SRCU
1363 * read-side critical sections have completed. However, the callback
1364 * function might well execute concurrently with other SRCU read-side
1366 * read-side critical sections are delimited by srcu_read_lock() and
1386 srcu_lock_sync(&ssp->dep_map); in __synchronize_srcu()
1392 "Illegal synchronize_srcu() in same-type SRCU (or in RCU) read-side critical section"); in __synchronize_srcu()
1415 * synchronize_srcu_expedited - Brute-force SRCU grace period
1422 * memory-ordering properties as does synchronize_srcu().
1431 * synchronize_srcu - wait for prior SRCU read-side critical-section completion
1436 * the index=((->srcu_idx & 1) ^ 1) to drain to zero at first,
1442 * SRCU read-side critical section; doing so will result in deadlock.
1444 * srcu_struct from some other srcu_struct's read-side critical section,
1447 * There are memory-ordering constraints implied by synchronize_srcu().
1450 * the end of its last corresponding SRCU read-side critical section
1452 * each CPU having an SRCU read-side critical section that extends beyond
1455 * the beginning of that SRCU read-side critical section. Note that these
1465 * Of course, these memory-ordering guarantees apply only when
1469 * Implementation of these memory-ordering guarantees is similar to
1487 * get_state_synchronize_srcu - Provide an end-of-grace-period cookie
1498 // Any prior manipulation of SRCU-protected data must happen in get_state_synchronize_srcu()
1499 // before the load from ->srcu_gp_seq. in get_state_synchronize_srcu()
1501 return rcu_seq_snap(&ssp->srcu_sup->srcu_gp_seq); in get_state_synchronize_srcu()
1506 * start_poll_synchronize_srcu - Provide cookie and start grace period
1522 * poll_state_synchronize_srcu - Has cookie's grace period ended?
1524 * @cookie: Return value from get_state_synchronize_srcu() or start_poll_synchronize_srcu().
1532 * This is more pronounced on 32-bit systems where cookies are 32 bits,
1534 * 25-microsecond expedited SRCU grace periods. However, a more likely
1536 * one-millisecond SRCU grace periods. Of course, wrapping in a 64-bit
1542 * a 16-bit cookie, which rcutorture routinely wraps in a matter of a
1549 !rcu_seq_done(&ssp->srcu_sup->srcu_gp_seq, cookie)) in poll_state_synchronize_srcu()
1566 rhp->next = rhp; // Mark the callback as having been invoked. in srcu_barrier_cb()
1568 ssp = sdp->ssp; in srcu_barrier_cb()
1569 if (atomic_dec_and_test(&ssp->srcu_sup->srcu_barrier_cpu_cnt)) in srcu_barrier_cb()
1570 complete(&ssp->srcu_sup->srcu_barrier_completion); in srcu_barrier_cb()
1575 * structure's ->cblist. but only if that ->cblist already has at least one
1584 atomic_inc(&ssp->srcu_sup->srcu_barrier_cpu_cnt); in srcu_barrier_one_cpu()
1585 sdp->srcu_barrier_head.func = srcu_barrier_cb; in srcu_barrier_one_cpu()
1586 debug_rcu_head_queue(&sdp->srcu_barrier_head); in srcu_barrier_one_cpu()
1587 if (!rcu_segcblist_entrain(&sdp->srcu_cblist, in srcu_barrier_one_cpu()
1588 &sdp->srcu_barrier_head)) { in srcu_barrier_one_cpu()
1589 debug_rcu_head_unqueue(&sdp->srcu_barrier_head); in srcu_barrier_one_cpu()
1590 atomic_dec(&ssp->srcu_sup->srcu_barrier_cpu_cnt); in srcu_barrier_one_cpu()
1596 * srcu_barrier - Wait until all in-flight call_srcu() callbacks complete.
1597 * @ssp: srcu_struct on which to wait for in-flight callbacks.
1603 unsigned long s = rcu_seq_snap(&ssp->srcu_sup->srcu_barrier_seq); in srcu_barrier()
1606 mutex_lock(&ssp->srcu_sup->srcu_barrier_mutex); in srcu_barrier()
1607 if (rcu_seq_done(&ssp->srcu_sup->srcu_barrier_seq, s)) { in srcu_barrier()
1609 mutex_unlock(&ssp->srcu_sup->srcu_barrier_mutex); in srcu_barrier()
1612 rcu_seq_start(&ssp->srcu_sup->srcu_barrier_seq); in srcu_barrier()
1613 init_completion(&ssp->srcu_sup->srcu_barrier_completion); in srcu_barrier()
1616 atomic_set(&ssp->srcu_sup->srcu_barrier_cpu_cnt, 1); in srcu_barrier()
1619 if (smp_load_acquire(&ssp->srcu_sup->srcu_size_state) < SRCU_SIZE_WAIT_BARRIER) in srcu_barrier()
1620 srcu_barrier_one_cpu(ssp, per_cpu_ptr(ssp->sda, get_boot_cpu_id())); in srcu_barrier()
1623 srcu_barrier_one_cpu(ssp, per_cpu_ptr(ssp->sda, cpu)); in srcu_barrier()
1627 if (atomic_dec_and_test(&ssp->srcu_sup->srcu_barrier_cpu_cnt)) in srcu_barrier()
1628 complete(&ssp->srcu_sup->srcu_barrier_completion); in srcu_barrier()
1629 wait_for_completion(&ssp->srcu_sup->srcu_barrier_completion); in srcu_barrier()
1631 rcu_seq_end(&ssp->srcu_sup->srcu_barrier_seq); in srcu_barrier()
1632 mutex_unlock(&ssp->srcu_sup->srcu_barrier_mutex); in srcu_barrier()
1637 * srcu_batches_completed - return batches completed.
1645 return READ_ONCE(ssp->srcu_idx); in srcu_batches_completed()
1650 * Core SRCU state machine. Push state bits of ->srcu_gp_seq
1658 mutex_lock(&ssp->srcu_sup->srcu_gp_mutex); in srcu_advance_state()
1662 * fetching ->srcu_idx for their index, at any point in time there in srcu_advance_state()
1667 * The load-acquire ensures that we see the accesses performed in srcu_advance_state()
1670 idx = rcu_seq_state(smp_load_acquire(&ssp->srcu_sup->srcu_gp_seq)); /* ^^^ */ in srcu_advance_state()
1672 spin_lock_irq_rcu_node(ssp->srcu_sup); in srcu_advance_state()
1673 if (ULONG_CMP_GE(ssp->srcu_sup->srcu_gp_seq, ssp->srcu_sup->srcu_gp_seq_needed)) { in srcu_advance_state()
1674 WARN_ON_ONCE(rcu_seq_state(ssp->srcu_sup->srcu_gp_seq)); in srcu_advance_state()
1675 spin_unlock_irq_rcu_node(ssp->srcu_sup); in srcu_advance_state()
1676 mutex_unlock(&ssp->srcu_sup->srcu_gp_mutex); in srcu_advance_state()
1679 idx = rcu_seq_state(READ_ONCE(ssp->srcu_sup->srcu_gp_seq)); in srcu_advance_state()
1682 spin_unlock_irq_rcu_node(ssp->srcu_sup); in srcu_advance_state()
1684 mutex_unlock(&ssp->srcu_sup->srcu_gp_mutex); in srcu_advance_state()
1689 if (rcu_seq_state(READ_ONCE(ssp->srcu_sup->srcu_gp_seq)) == SRCU_STATE_SCAN1) { in srcu_advance_state()
1690 idx = 1 ^ (ssp->srcu_idx & 1); in srcu_advance_state()
1692 mutex_unlock(&ssp->srcu_sup->srcu_gp_mutex); in srcu_advance_state()
1696 spin_lock_irq_rcu_node(ssp->srcu_sup); in srcu_advance_state()
1697 rcu_seq_set_state(&ssp->srcu_sup->srcu_gp_seq, SRCU_STATE_SCAN2); in srcu_advance_state()
1698 ssp->srcu_sup->srcu_n_exp_nodelay = 0; in srcu_advance_state()
1699 spin_unlock_irq_rcu_node(ssp->srcu_sup); in srcu_advance_state()
1702 if (rcu_seq_state(READ_ONCE(ssp->srcu_sup->srcu_gp_seq)) == SRCU_STATE_SCAN2) { in srcu_advance_state()
1705 * SRCU read-side critical sections are normally short, in srcu_advance_state()
1708 idx = 1 ^ (ssp->srcu_idx & 1); in srcu_advance_state()
1710 mutex_unlock(&ssp->srcu_sup->srcu_gp_mutex); in srcu_advance_state()
1713 ssp->srcu_sup->srcu_n_exp_nodelay = 0; in srcu_advance_state()
1714 srcu_gp_end(ssp); /* Releases ->srcu_gp_mutex. */ in srcu_advance_state()
1735 ssp = sdp->ssp; in srcu_invoke_callbacks()
1738 WARN_ON_ONCE(!rcu_segcblist_segempty(&sdp->srcu_cblist, RCU_NEXT_TAIL)); in srcu_invoke_callbacks()
1739 rcu_segcblist_advance(&sdp->srcu_cblist, in srcu_invoke_callbacks()
1740 rcu_seq_current(&ssp->srcu_sup->srcu_gp_seq)); in srcu_invoke_callbacks()
1742 * Although this function is theoretically re-entrant, concurrent in srcu_invoke_callbacks()
1746 if (sdp->srcu_cblist_invoking || in srcu_invoke_callbacks()
1747 !rcu_segcblist_ready_cbs(&sdp->srcu_cblist)) { in srcu_invoke_callbacks()
1753 sdp->srcu_cblist_invoking = true; in srcu_invoke_callbacks()
1754 rcu_segcblist_extract_done_cbs(&sdp->srcu_cblist, &ready_cbs); in srcu_invoke_callbacks()
1762 rhp->func(rhp); in srcu_invoke_callbacks()
1772 rcu_segcblist_add_len(&sdp->srcu_cblist, -len); in srcu_invoke_callbacks()
1773 sdp->srcu_cblist_invoking = false; in srcu_invoke_callbacks()
1774 more = rcu_segcblist_ready_cbs(&sdp->srcu_cblist); in srcu_invoke_callbacks()
1783 * more SRCU callbacks queued, otherwise put SRCU into not-running state.
1789 spin_lock_irq_rcu_node(ssp->srcu_sup); in srcu_reschedule()
1790 if (ULONG_CMP_GE(ssp->srcu_sup->srcu_gp_seq, ssp->srcu_sup->srcu_gp_seq_needed)) { in srcu_reschedule()
1791 if (!WARN_ON_ONCE(rcu_seq_state(ssp->srcu_sup->srcu_gp_seq))) { in srcu_reschedule()
1795 } else if (!rcu_seq_state(ssp->srcu_sup->srcu_gp_seq)) { in srcu_reschedule()
1799 spin_unlock_irq_rcu_node(ssp->srcu_sup); in srcu_reschedule()
1802 queue_delayed_work(rcu_gp_wq, &ssp->srcu_sup->work, delay); in srcu_reschedule()
1806 * This is the work-queue function that handles SRCU grace periods.
1816 ssp = sup->srcu_ssp; in process_srcu()
1821 WRITE_ONCE(sup->reschedule_count, 0); in process_srcu()
1824 if (READ_ONCE(sup->reschedule_jiffies) == j) { in process_srcu()
1825 ASSERT_EXCLUSIVE_WRITER(sup->reschedule_count); in process_srcu()
1826 WRITE_ONCE(sup->reschedule_count, READ_ONCE(sup->reschedule_count) + 1); in process_srcu()
1827 if (READ_ONCE(sup->reschedule_count) > srcu_max_nodelay) in process_srcu()
1830 WRITE_ONCE(sup->reschedule_count, 1); in process_srcu()
1831 WRITE_ONCE(sup->reschedule_jiffies, j); in process_srcu()
1841 *gp_seq = rcu_seq_current(&ssp->srcu_sup->srcu_gp_seq); in srcutorture_get_gp_data()
1863 int ss_state = READ_ONCE(ssp->srcu_sup->srcu_size_state); in srcu_torture_stats_print()
1866 idx = ssp->srcu_idx & 0x1; in srcu_torture_stats_print()
1868 ss_state_idx = ARRAY_SIZE(srcu_size_state_name) - 1; in srcu_torture_stats_print()
1870 tt, tf, rcu_seq_current(&ssp->srcu_sup->srcu_gp_seq), ss_state, in srcu_torture_stats_print()
1872 if (!ssp->sda) { in srcu_torture_stats_print()
1874 pr_cont(" No per-CPU srcu_data structures (->sda == NULL).\n"); in srcu_torture_stats_print()
1876 pr_cont(" per-CPU(idx=%d):", idx); in srcu_torture_stats_print()
1883 sdp = per_cpu_ptr(ssp->sda, cpu); in srcu_torture_stats_print()
1884 u0 = data_race(atomic_long_read(&sdp->srcu_unlock_count[!idx])); in srcu_torture_stats_print()
1885 u1 = data_race(atomic_long_read(&sdp->srcu_unlock_count[idx])); in srcu_torture_stats_print()
1893 l0 = data_race(atomic_long_read(&sdp->srcu_lock_count[!idx])); in srcu_torture_stats_print()
1894 l1 = data_race(atomic_long_read(&sdp->srcu_lock_count[idx])); in srcu_torture_stats_print()
1896 c0 = l0 - u0; in srcu_torture_stats_print()
1897 c1 = l1 - u1; in srcu_torture_stats_print()
1900 "C."[rcu_segcblist_empty(&sdp->srcu_cblist)]); in srcu_torture_stats_print()
1915 pr_info("\tNon-default auto-expedite holdoff of %lu ns.\n", exp_holdoff); in srcu_bootup_announce()
1917 pr_info("\tNon-default retry check delay of %lu us.\n", srcu_retry_check_delay); in srcu_bootup_announce()
1919 pr_info("\tNon-default max no-delay of %lu.\n", srcu_max_nodelay); in srcu_bootup_announce()
1920 pr_info("\tMax phase no-delay instances is %lu.\n", srcu_max_nodelay_phase); in srcu_bootup_announce()
1929 /* Decide on srcu_struct-size strategy. */ in srcu_init()
1949 list_del_init(&sup->work.work.entry); in srcu_init()
1951 sup->srcu_size_state == SRCU_SIZE_SMALL) in srcu_init()
1952 sup->srcu_size_state = SRCU_SIZE_ALLOC; in srcu_init()
1953 queue_work(rcu_gp_wq, &sup->work.work); in srcu_init()
1959 /* Initialize any global-scope srcu_struct structures used by this module. */
1964 struct srcu_struct **sspp = mod->srcu_struct_ptrs; in srcu_module_coming()
1966 for (i = 0; i < mod->num_srcu_structs; i++) { in srcu_module_coming()
1968 ssp->sda = alloc_percpu(struct srcu_data); in srcu_module_coming()
1969 if (WARN_ON_ONCE(!ssp->sda)) in srcu_module_coming()
1970 return -ENOMEM; in srcu_module_coming()
1975 /* Clean up any global-scope srcu_struct structures used by this module. */
1980 struct srcu_struct **sspp = mod->srcu_struct_ptrs; in srcu_module_going()
1982 for (i = 0; i < mod->num_srcu_structs; i++) { in srcu_module_going()
1984 if (!rcu_seq_state(smp_load_acquire(&ssp->srcu_sup->srcu_gp_seq_needed)) && in srcu_module_going()
1985 !WARN_ON_ONCE(!ssp->srcu_sup->sda_is_static)) in srcu_module_going()
1988 free_percpu(ssp->sda); in srcu_module_going()