Lines Matching +full:cpu +full:- +full:read

1 /* SPDX-License-Identifier: GPL-2.0+ */
3 * Sleepable Read-Copy Update mechanism for mutual exclusion,
22 atomic_long_t srcu_locks; /* Locks per CPU. */
23 atomic_long_t srcu_unlocks; /* Unlocks per CPU. */
27 * Per-CPU structure feeding into leaf srcu_node, similar in function
31 /* Read-side state. */
32 struct srcu_ctr srcu_ctrs[2]; /* Locks and unlocks per CPU. */
36 /* Update-side state. */
47 /* ->srcu_data_have_cbs[]. */
48 int cpu; member
58 /* if greater than ->srcu_gp_seq. */
62 int grplo; /* Least CPU for node. */
63 int grphi; /* Biggest CPU for node. */
67 * Per-SRCU-domain structure, update-side data linked from srcu_struct.
73 int srcu_size_state; /* Small-to-big transition state. */
77 unsigned long srcu_gp_seq; /* Grace-period seq #. */
82 unsigned long srcu_size_jiffies; /* Current contention-measurement interval. */
84 unsigned long srcu_n_exp_nodelay; /* # expedited no-delays in current GP phase. */
85 bool sda_is_static; /* May ->sda be passed to free_percpu()? */
100 * Per-SRCU-domain structure, similar in function to rcu_state.
104 struct srcu_data __percpu *sda; /* Per-CPU srcu_data array. */
106 struct srcu_usage *srcu_sup; /* Update-side data. */
109 // Values for size state variable (->srcu_size_state). Once the state
110 // has been set to SRCU_SIZE_ALLOC, the grace-period code advances through
114 #define SRCU_SIZE_SMALL 0 // No srcu_node combining tree, ->node == NULL
116 // and then referenced by ->node. It will not be used.
123 // invocations that were running on a non-boot CPU
124 // and using the boot CPU's callback queue will have
126 #define SRCU_SIZE_WAIT_CBS1 4 // Don't trust the ->srcu_have_cbs[] grace-period
127 #define SRCU_SIZE_WAIT_CBS2 5 // sequence elements or the ->srcu_data_have_cbs[]
128 #define SRCU_SIZE_WAIT_CBS3 6 // CPU-bitmask elements until all four elements of
133 /* Values for state variable (bottom bits of ->srcu_gp_seq). */
146 #define SRCU_GP_SEQ_INITIAL_VAL ((0UL - 100UL) << RCU_SEQ_CTR_SHIFT)
147 #define SRCU_GP_SEQ_INITIAL_VAL_WITH_STATE (SRCU_GP_SEQ_INITIAL_VAL - 1)
176 * Do -not- call init_srcu_struct() nor cleanup_srcu_struct() on it.
179 * files, the per-CPU variable rules nevertheless require that the
191 * See include/linux/percpu-defs.h for the rules on per-CPU variables.
215 // Converts a per-CPU pointer to an ->srcu_ctrs[] array element to that
219 return scpp - &ssp->sda->srcu_ctrs[0]; in __srcu_ptr_to_ctr()
222 // Converts an integer to a per-CPU pointer to the corresponding
223 // ->srcu_ctrs[] array element.
226 return &ssp->sda->srcu_ctrs[idx]; in __srcu_ctr_to_ptr()
230 * Counts the new reader in the appropriate per-CPU element of the
234 * Note that both this_cpu_inc() and atomic_long_inc() are RCU read-side
236 * are a single instruction, or because they are a read-modify-write atomic
240 * on architectures that support NMIs but do not supply NMI-safe
245 struct srcu_ctr __percpu *scp = READ_ONCE(ssp->srcu_ctrp); in __srcu_read_lock_fast()
249 this_cpu_inc(scp->srcu_locks.counter); /* Y */ in __srcu_read_lock_fast()
251 atomic_long_inc(raw_cpu_ptr(&scp->srcu_locks)); /* Z */ in __srcu_read_lock_fast()
258 * per-CPU element of the srcu_struct. Note that this may well be a
259 * different CPU than that which was incremented by the corresponding
262 * Note that both this_cpu_inc() and atomic_long_inc() are RCU read-side
264 * are a single instruction, or because they are a read-modify-write atomic
268 * on architectures that support NMIs but do not supply NMI-safe
275 this_cpu_inc(scp->srcu_unlocks.counter); /* Z */ in __srcu_read_unlock_fast()
277 atomic_long_inc(raw_cpu_ptr(&scp->srcu_unlocks)); /* Z */ in __srcu_read_unlock_fast()
282 * Counts the new reader in the appropriate per-CPU element of the
286 * Note that this_cpu_inc() is an RCU read-side critical section either
288 * or because it is a read-modify-write atomic operation, depending on
293 struct srcu_ctr __percpu *scp = READ_ONCE(ssp->srcu_ctrp); in __srcu_read_lock_lite()
296 this_cpu_inc(scp->srcu_locks.counter); /* Y */ in __srcu_read_lock_lite()
303 * per-CPU element of the srcu_struct. Note that this may well be a
304 * different CPU than that which was incremented by the corresponding
307 * Note that this_cpu_inc() is an RCU read-side critical section either
309 * or because it is a read-modify-write atomic operation, depending on
315 this_cpu_inc(__srcu_ctr_to_ptr(ssp, idx)->srcu_unlocks.counter); /* Z */ in __srcu_read_unlock_lite()
322 // needed only for flavors that require grace-period smp_mb() calls to be
326 struct srcu_data *sdp = raw_cpu_ptr(ssp->sda); in srcu_check_read_flavor_force()
328 if (likely(READ_ONCE(sdp->srcu_reader_flavor) & read_flavor)) in srcu_check_read_flavor_force()
335 // Record non-_lite() usage only for CONFIG_PROVE_RCU=y kernels.