kernel/locking/rtmutex_api.c
Source file repositories/reference/linux-study-clean/kernel/locking/rtmutex_api.c
File Facts
- System
- Linux kernel
- Corpus path
kernel/locking/rtmutex_api.c- Extension
.c- Size
- 18686 bytes
- Lines
- 684
- Domain
- Core OS
- Bucket
- Scheduler, Processes, Timers, Sync, And Syscalls
- Inferred role
- Core OS: exported/initcall integration point
- Status
- integration 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.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- 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/spinlock.hlinux/export.hrtmutex.c
Detected Declarations
function init_rtmutex_sysctlfunction __rt_mutex_lock_commonfunction rt_mutex_base_initfunction rt_mutex_lock_nestedfunction _rt_mutex_lock_nest_lockfunction rt_mutex_lockfunction rt_mutex_lock_interruptiblefunction rt_mutex_lock_killablefunction rt_mutex_trylockfunction rt_mutex_unlockfunction rt_mutex_futex_trylockfunction __rt_mutex_futex_trylockfunction __rt_mutex_futex_unlockfunction rt_mutex_futex_unlockfunction __rt_mutex_initfunction rt_mutex_init_proxy_lockedfunction rt_mutex_proxy_unlockfunction rt_mutex_wait_proxy_lockfunction rt_mutex_start_proxy_lockfunction rt_mutex_wait_proxy_lockfunction rt_mutex_wait_proxy_lockfunction rt_mutex_adjust_pifunction rt_mutex_postunlockfunction rt_mutex_debug_task_freefunction __mutex_rt_init_genericfunction mutex_rt_init_lockdepfunction mutex_lock_nestedfunction _mutex_lock_nest_lockfunction mutex_lock_interruptible_nestedfunction _mutex_lock_killablefunction mutex_lock_io_nestedfunction _mutex_trylock_nest_lockfunction mutex_rt_init_genericfunction mutex_lockfunction mutex_lock_interruptiblefunction mutex_lock_killablefunction mutex_lock_iofunction mutex_trylockmodule init init_rtmutex_sysctlexport rt_mutex_base_initexport rt_mutex_lock_nestedexport _rt_mutex_lock_nest_lockexport rt_mutex_lockexport rt_mutex_lock_interruptibleexport rt_mutex_lock_killableexport rt_mutex_trylockexport rt_mutex_unlockexport __rt_mutex_init
Annotated Snippet
subsys_initcall(init_rtmutex_sysctl);
/*
* Debug aware fast / slowpath lock,trylock,unlock
*
* The atomic acquire/release ops are compiled away, when either the
* architecture does not support cmpxchg or when debugging is enabled.
*/
static __always_inline int __rt_mutex_lock_common(struct rt_mutex *lock,
unsigned int state,
struct lockdep_map *nest_lock,
unsigned int subclass)
__cond_acquires(0, lock)
{
int ret;
might_sleep();
mutex_acquire_nest(&lock->dep_map, subclass, 0, nest_lock, _RET_IP_);
ret = __rt_mutex_lock(&lock->rtmutex, state);
if (ret)
mutex_release(&lock->dep_map, _RET_IP_);
return ret;
}
void rt_mutex_base_init(struct rt_mutex_base *rtb)
{
__rt_mutex_base_init(rtb);
}
EXPORT_SYMBOL(rt_mutex_base_init);
#ifdef CONFIG_DEBUG_LOCK_ALLOC
/**
* rt_mutex_lock_nested - lock a rt_mutex
*
* @lock: the rt_mutex to be locked
* @subclass: the lockdep subclass
*/
void __sched rt_mutex_lock_nested(struct rt_mutex *lock, unsigned int subclass)
{
if (__rt_mutex_lock_common(lock, TASK_UNINTERRUPTIBLE, NULL, subclass) == 0)
return;
/*
* The code below is never reached because __rt_mutex_lock_common() only
* returns an error code if interrupted by a signal or upon a timeout.
*/
WARN_ON_ONCE(true);
__acquire(lock);
}
EXPORT_SYMBOL_GPL(rt_mutex_lock_nested);
void __sched _rt_mutex_lock_nest_lock(struct rt_mutex *lock, struct lockdep_map *nest_lock)
{
if (__rt_mutex_lock_common(lock, TASK_UNINTERRUPTIBLE, nest_lock, 0) == 0)
return;
/*
* The code below is never reached because __rt_mutex_lock_common() only
* returns an error code if interrupted by a signal or upon a timeout.
*/
WARN_ON_ONCE(true);
__acquire(lock);
}
EXPORT_SYMBOL_GPL(_rt_mutex_lock_nest_lock);
#else /* !CONFIG_DEBUG_LOCK_ALLOC */
/**
* rt_mutex_lock - lock a rt_mutex
*
* @lock: the rt_mutex to be locked
*/
void __sched rt_mutex_lock(struct rt_mutex *lock)
{
if (__rt_mutex_lock_common(lock, TASK_UNINTERRUPTIBLE, NULL, 0) == 0)
return;
/*
* The code below is never reached because __rt_mutex_lock_common() only
* returns an error code if interrupted by a signal or upon a timeout.
*/
WARN_ON_ONCE(true);
__acquire(lock);
}
EXPORT_SYMBOL_GPL(rt_mutex_lock);
#endif
/**
* rt_mutex_lock_interruptible - lock a rt_mutex interruptible
*
* @lock: the rt_mutex to be locked
*
* Returns:
Annotation
- Immediate include surface: `linux/spinlock.h`, `linux/export.h`, `rtmutex.c`.
- Detected declarations: `function init_rtmutex_sysctl`, `function __rt_mutex_lock_common`, `function rt_mutex_base_init`, `function rt_mutex_lock_nested`, `function _rt_mutex_lock_nest_lock`, `function rt_mutex_lock`, `function rt_mutex_lock_interruptible`, `function rt_mutex_lock_killable`, `function rt_mutex_trylock`, `function rt_mutex_unlock`.
- Atlas domain: Core OS / Scheduler, Processes, Timers, Sync, And Syscalls.
- Implementation status: integration 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.