kernel/locking/rtmutex_common.h
Source file repositories/reference/linux-study-clean/kernel/locking/rtmutex_common.h
File Facts
- System
- Linux kernel
- Corpus path
kernel/locking/rtmutex_common.h- Extension
.h- Size
- 6897 bytes
- Lines
- 238
- Domain
- Core OS
- Bucket
- Scheduler, Processes, Timers, Sync, And Syscalls
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/debug_locks.hlinux/rtmutex.hlinux/sched/wake_q.h
Detected Declarations
struct rt_waiter_nodestruct rt_mutex_waiterstruct rt_wake_q_headenum rtmutex_chainwalkfunction rt_mutex_has_waitersfunction rt_mutex_waiter_is_top_waiterfunction task_has_pi_waitersfunction __rt_mutex_base_initfunction debug_rt_mutex_unlockfunction debug_rt_mutex_proxy_unlockfunction debug_rt_mutex_init_waiterfunction debug_rt_mutex_free_waiterfunction rt_mutex_init_waiterfunction rt_mutex_init_rtlock_waiter
Annotated Snippet
struct rt_waiter_node {
struct rb_node entry;
int prio;
u64 deadline;
};
/*
* This is the control structure for tasks blocked on a rt_mutex,
* which is allocated on the kernel stack on of the blocked task.
*
* @tree: node to enqueue into the mutex waiters tree
* @pi_tree: node to enqueue into the mutex owner waiters tree
* @task: task reference to the blocked task
* @lock: Pointer to the rt_mutex on which the waiter blocks
* @wake_state: Wakeup state to use (TASK_NORMAL or TASK_RTLOCK_WAIT)
* @ww_ctx: WW context pointer
*
* @tree is ordered by @lock->wait_lock
* @pi_tree is ordered by rt_mutex_owner(@lock)->pi_lock
*/
struct rt_mutex_waiter {
struct rt_waiter_node tree;
struct rt_waiter_node pi_tree;
struct task_struct *task;
struct rt_mutex_base *lock;
unsigned int wake_state;
struct ww_acquire_ctx *ww_ctx;
};
/**
* struct rt_wake_q_head - Wrapper around regular wake_q_head to support
* "sleeping" spinlocks on RT
* @head: The regular wake_q_head for sleeping lock variants
* @rtlock_task: Task pointer for RT lock (spin/rwlock) wakeups
*/
struct rt_wake_q_head {
struct wake_q_head head;
struct task_struct *rtlock_task;
};
#define DEFINE_RT_WAKE_Q(name) \
struct rt_wake_q_head name = { \
.head = WAKE_Q_HEAD_INITIALIZER(name.head), \
.rtlock_task = NULL, \
}
/*
* PI-futex support (proxy locking functions, etc.):
*/
extern void rt_mutex_init_proxy_locked(struct rt_mutex_base *lock,
struct task_struct *proxy_owner)
__must_hold(&lock->wait_lock);
extern void rt_mutex_proxy_unlock(struct rt_mutex_base *lock)
__must_hold(&lock->wait_lock);
extern int __rt_mutex_start_proxy_lock(struct rt_mutex_base *lock,
struct rt_mutex_waiter *waiter,
struct task_struct *task,
struct wake_q_head *)
__must_hold(&lock->wait_lock);
extern int rt_mutex_start_proxy_lock(struct rt_mutex_base *lock,
struct rt_mutex_waiter *waiter,
struct task_struct *task);
extern int rt_mutex_wait_proxy_lock(struct rt_mutex_base *lock,
struct hrtimer_sleeper *to,
struct rt_mutex_waiter *waiter);
extern bool rt_mutex_cleanup_proxy_lock(struct rt_mutex_base *lock,
struct rt_mutex_waiter *waiter);
extern int rt_mutex_futex_trylock(struct rt_mutex_base *lock);
extern int __rt_mutex_futex_trylock(struct rt_mutex_base *lock)
__must_hold(&lock->wait_lock);
extern void rt_mutex_futex_unlock(struct rt_mutex_base *lock);
extern bool __rt_mutex_futex_unlock(struct rt_mutex_base *lock,
struct rt_wake_q_head *wqh);
extern void rt_mutex_postunlock(struct rt_wake_q_head *wqh);
/*
* Must be guarded because this header is included from rcu/tree_plugin.h
* unconditionally.
*/
#ifdef CONFIG_RT_MUTEXES
static inline int rt_mutex_has_waiters(struct rt_mutex_base *lock)
__must_hold(&lock->wait_lock)
{
return !RB_EMPTY_ROOT(&lock->waiters.rb_root);
Annotation
- Immediate include surface: `linux/debug_locks.h`, `linux/rtmutex.h`, `linux/sched/wake_q.h`.
- Detected declarations: `struct rt_waiter_node`, `struct rt_mutex_waiter`, `struct rt_wake_q_head`, `enum rtmutex_chainwalk`, `function rt_mutex_has_waiters`, `function rt_mutex_waiter_is_top_waiter`, `function task_has_pi_waiters`, `function __rt_mutex_base_init`, `function debug_rt_mutex_unlock`, `function debug_rt_mutex_proxy_unlock`.
- Atlas domain: Core OS / Scheduler, Processes, Timers, Sync, And Syscalls.
- Implementation status: source implementation candidate.
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.