include/linux/srcu.h
Source file repositories/reference/linux-study-clean/include/linux/srcu.h
File Facts
- System
- Linux kernel
- Corpus path
include/linux/srcu.h- Extension
.h- Size
- 24052 bytes
- Lines
- 642
- Domain
- Core OS
- Bucket
- Core Kernel Interface
- Inferred role
- Core OS: implementation source
- Status
- source implementation candidate
Why This File Exists
Core operating-system implementation surface: boot, tasks, memory, VFS, syscall-facing interfaces, synchronization, credentials, and isolation.
- Core operating-system implementation surface: boot, tasks, memory, VFS, syscall-facing interfaces, synchronization, credentials, and isolation.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/mutex.hlinux/rcupdate.hlinux/workqueue.hlinux/rcu_segcblist.hlinux/srcutiny.hlinux/srcutree.h
Detected Declarations
function poll_state_synchronize_srcufunction get_state_synchronize_srcufunction __srcu_read_lock_nmisafefunction __srcu_read_unlock_nmisafefunction debug_lockdep_rcu_enabledfunction srcu_lock_syncfunction srcu_lock_releasefunction srcu_lock_syncfunction srcu_read_lock_heldfunction __guarded_byfunction rcu_dereference_checkfunction smp_mbfunction smp_mbfunction srcu_read_lock_fastfunction srcu_down_readfunction srcu_read_lockfunction srcu_read_lock_notracefunction synchronize_srcufunction srcu_read_unlockfunction srcu_read_unlock_fastfunction srcu_read_unlock_fast_updownfunction srcu_read_unlock_fastfunction srcu_down_read_fastfunction srcu_read_unlock_nmisafefunction srcu_read_unlock_notracefunction srcu_down_readfunction smp_mb__after_srcu_read_unlock
Annotated Snippet
static inline void __srcu_read_lock_must_hold(const struct srcu_struct *ssp) __must_hold_shared(ssp) { }
/**
* srcu_dereference_check - fetch SRCU-protected pointer for later dereferencing
* @p: the pointer to fetch and protect for later dereferencing
* @ssp: pointer to the srcu_struct, which is used to check that we
* really are in an SRCU read-side critical section.
* @c: condition to check for update-side use
*
* If PROVE_RCU is enabled, invoking this outside of an RCU read-side
* critical section will result in an RCU-lockdep splat, unless @c evaluates
* to 1. The @c argument will normally be a logical expression containing
* lockdep_is_held() calls.
*/
#define srcu_dereference_check(p, ssp, c) \
({ \
__srcu_read_lock_must_hold(ssp); \
__acquire_shared_ctx_lock(RCU); \
__auto_type __v = __rcu_dereference_check((p), __UNIQUE_ID(rcu), \
(c) || srcu_read_lock_held(ssp), __rcu); \
__release_shared_ctx_lock(RCU); \
__v; \
})
/**
* srcu_dereference - fetch SRCU-protected pointer for later dereferencing
* @p: the pointer to fetch and protect for later dereferencing
* @ssp: pointer to the srcu_struct, which is used to check that we
* really are in an SRCU read-side critical section.
*
* Makes rcu_dereference_check() do the dirty work. If PROVE_RCU
* is enabled, invoking this outside of an RCU read-side critical
* section will result in an RCU-lockdep splat.
*/
#define srcu_dereference(p, ssp) srcu_dereference_check((p), (ssp), 0)
/**
* srcu_dereference_notrace - no tracing and no lockdep calls from here
* @p: the pointer to fetch and protect for later dereferencing
* @ssp: pointer to the srcu_struct, which is used to check that we
* really are in an SRCU read-side critical section.
*/
#define srcu_dereference_notrace(p, ssp) srcu_dereference_check((p), (ssp), 1)
/**
* srcu_read_lock - register a new reader for an SRCU-protected structure.
* @ssp: srcu_struct in which to register the new reader.
*
* Enter an SRCU read-side critical section. Note that SRCU read-side
* critical sections may be nested. However, it is illegal to
* call anything that waits on an SRCU grace period for the same
* srcu_struct, whether directly or indirectly. Please note that
* one way to indirectly wait on an SRCU grace period is to acquire
* a mutex that is held elsewhere while calling synchronize_srcu() or
* synchronize_srcu_expedited().
*
* The return value from srcu_read_lock() is guaranteed to be
* non-negative. This value must be passed unaltered to the matching
* srcu_read_unlock(). Note that srcu_read_lock() and the matching
* srcu_read_unlock() must occur in the same context, for example, it is
* illegal to invoke srcu_read_unlock() in an irq handler if the matching
* srcu_read_lock() was invoked in process context. Or, for that matter to
* invoke srcu_read_unlock() from one task and the matching srcu_read_lock()
* from another.
*/
static inline int srcu_read_lock(struct srcu_struct *ssp)
__acquires_shared(ssp)
{
int retval;
srcu_check_read_flavor(ssp, SRCU_READ_FLAVOR_NORMAL);
retval = __srcu_read_lock(ssp);
srcu_lock_acquire(&ssp->dep_map);
return retval;
}
/**
* srcu_read_lock_fast - register a new reader for an SRCU-protected structure.
* @ssp: srcu_struct in which to register the new reader.
*
* Enter an SRCU read-side critical section, but for a light-weight
* smp_mb()-free reader. See srcu_read_lock() for more information. This
* function is NMI-safe, in a manner similar to srcu_read_lock_nmisafe().
*
* For srcu_read_lock_fast() to be used on an srcu_struct structure,
* that structure must have been defined using either DEFINE_SRCU_FAST()
* or DEFINE_STATIC_SRCU_FAST() on the one hand or initialized with
* init_srcu_struct_fast() on the other. Such an srcu_struct structure
* cannot be passed to any non-fast variant of srcu_read_{,un}lock() or
* srcu_{down,up}_read(). In kernels built with CONFIG_PROVE_RCU=y,
Annotation
- Immediate include surface: `linux/mutex.h`, `linux/rcupdate.h`, `linux/workqueue.h`, `linux/rcu_segcblist.h`, `linux/srcutiny.h`, `linux/srcutree.h`.
- Detected declarations: `function poll_state_synchronize_srcu`, `function get_state_synchronize_srcu`, `function __srcu_read_lock_nmisafe`, `function __srcu_read_unlock_nmisafe`, `function debug_lockdep_rcu_enabled`, `function srcu_lock_sync`, `function srcu_lock_release`, `function srcu_lock_sync`, `function srcu_read_lock_held`, `function __guarded_by`.
- Atlas domain: Core OS / Core Kernel Interface.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.