include/linux/spinlock_rt.h
Source file repositories/reference/linux-study-clean/include/linux/spinlock_rt.h
File Facts
- System
- Linux kernel
- Corpus path
include/linux/spinlock_rt.h- Extension
.h- Size
- 4379 bytes
- Lines
- 158
- 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/rwlock_rt.h
Detected Declarations
function __rt_spin_lock_initfunction spin_lockfunction spin_lock_bhfunction spin_lock_irqfunction spin_unlockfunction spin_unlock_bhfunction spin_unlock_irqfunction spin_unlock_irqrestorefunction _spin_trylock_irqsavefunction spin_is_locked
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0-only
#ifndef __LINUX_SPINLOCK_RT_H
#define __LINUX_SPINLOCK_RT_H
#ifndef __LINUX_INSIDE_SPINLOCK_H
#error Do not include directly. Use spinlock.h
#endif
#ifdef CONFIG_DEBUG_LOCK_ALLOC
extern void __rt_spin_lock_init(spinlock_t *lock, const char *name,
struct lock_class_key *key, bool percpu);
#else
static inline void __rt_spin_lock_init(spinlock_t *lock, const char *name,
struct lock_class_key *key, bool percpu)
{
}
#endif
#define __spin_lock_init(slock, name, key, percpu) \
do { \
rt_mutex_base_init(&(slock)->lock); \
__rt_spin_lock_init(slock, name, key, percpu); \
} while (0)
#define _spin_lock_init(slock, percpu) \
do { \
static struct lock_class_key __key; \
__spin_lock_init(slock, #slock, &__key, percpu); \
} while (0)
#define spin_lock_init(slock) _spin_lock_init(slock, false)
#define local_spin_lock_init(slock) _spin_lock_init(slock, true)
extern void rt_spin_lock(spinlock_t *lock) __acquires(lock);
extern void rt_spin_lock_nested(spinlock_t *lock, int subclass) __acquires(lock);
extern void rt_spin_lock_nest_lock(spinlock_t *lock, struct lockdep_map *nest_lock) __acquires(lock);
extern void rt_spin_unlock(spinlock_t *lock) __releases(lock);
extern void rt_spin_lock_unlock(spinlock_t *lock);
extern int rt_spin_trylock_bh(spinlock_t *lock) __cond_acquires(true, lock);
extern int rt_spin_trylock(spinlock_t *lock) __cond_acquires(true, lock);
static __always_inline void spin_lock(spinlock_t *lock)
__acquires(lock)
{
rt_spin_lock(lock);
}
#ifdef CONFIG_LOCKDEP
# define __spin_lock_nested(lock, subclass) \
rt_spin_lock_nested(lock, subclass)
# define __spin_lock_nest_lock(lock, nest_lock) \
do { \
typecheck(struct lockdep_map *, &(nest_lock)->dep_map); \
rt_spin_lock_nest_lock(lock, &(nest_lock)->dep_map); \
} while (0)
# define __spin_lock_irqsave_nested(lock, flags, subclass) \
do { \
typecheck(unsigned long, flags); \
flags = 0; \
__spin_lock_nested(lock, subclass); \
} while (0)
#else
/*
* Always evaluate the 'subclass' argument to avoid that the compiler
* warns about set-but-not-used variables when building with
* CONFIG_DEBUG_LOCK_ALLOC=n and with W=1.
*/
# define __spin_lock_nested(lock, subclass) spin_lock(((void)(subclass), (lock)))
# define __spin_lock_nest_lock(lock, subclass) spin_lock(((void)(subclass), (lock)))
# define __spin_lock_irqsave_nested(lock, flags, subclass) \
spin_lock_irqsave(((void)(subclass), (lock)), flags)
#endif
#define spin_lock_nested(lock, subclass) \
__spin_lock_nested(lock, subclass)
#define spin_lock_nest_lock(lock, nest_lock) \
__spin_lock_nest_lock(lock, nest_lock)
#define spin_lock_irqsave_nested(lock, flags, subclass) \
__spin_lock_irqsave_nested(lock, flags, subclass)
static __always_inline void spin_lock_bh(spinlock_t *lock)
__acquires(lock)
{
/* Investigate: Drop bh when blocking ? */
local_bh_disable();
rt_spin_lock(lock);
Annotation
- Immediate include surface: `linux/rwlock_rt.h`.
- Detected declarations: `function __rt_spin_lock_init`, `function spin_lock`, `function spin_lock_bh`, `function spin_lock_irq`, `function spin_unlock`, `function spin_unlock_bh`, `function spin_unlock_irq`, `function spin_unlock_irqrestore`, `function _spin_trylock_irqsave`, `function spin_is_locked`.
- 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.