Something went wrong. Try again.
(I'm so sorry!) Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
Something went wrong. Try again.
C
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141/* SPDX-License-Identifier: GPL-2.0 *//* * RT Mutexes: blocking mutual exclusion locks with PI support * * started by Ingo Molnar and Thomas Gleixner: * * Copyright (C) 2004-2006 Red Hat, Inc., Ingo Molnar <mingo@redhat.com> * Copyright (C) 2006, Timesys Corp., Thomas Gleixner <tglx@timesys.com> * * This file contains the public data structure and API definitions. */
#ifndef __LINUX_RT_MUTEX_H#define __LINUX_RT_MUTEX_H
#include <linux/compiler.h>#include <linux/linkage.h>#include <linux/rbtree_types.h>#include <linux/spinlock_types_raw.h>
extern int max_lock_depth;
struct rt_mutex_base { raw_spinlock_t wait_lock; struct rb_root_cached waiters __guarded_by(&wait_lock); struct task_struct *owner __guarded_by(&wait_lock);};
#define __RT_MUTEX_BASE_INITIALIZER(rtbasename) \{ \ .wait_lock = __RAW_SPIN_LOCK_UNLOCKED(rtbasename.wait_lock), \ .waiters = RB_ROOT_CACHED, \ .owner = NULL \}
/** * rt_mutex_base_is_locked - is the rtmutex locked * @lock: the mutex to be queried * * Returns true if the mutex is locked, false if unlocked. */static inline bool rt_mutex_base_is_locked(struct rt_mutex_base *lock){ return data_race(READ_ONCE(lock->owner) != NULL);}
#ifdef CONFIG_RT_MUTEXES#define RT_MUTEX_HAS_WAITERS 1UL
static inline struct task_struct *rt_mutex_owner(struct rt_mutex_base *lock){ unsigned long owner = (unsigned long) data_race(READ_ONCE(lock->owner));
return (struct task_struct *) (owner & ~RT_MUTEX_HAS_WAITERS);}#endifextern void rt_mutex_base_init(struct rt_mutex_base *rtb);
context_lock_struct(rt_mutex);
/** * The rt_mutex structure * * @wait_lock: spinlock to protect the structure * @waiters: rbtree root to enqueue waiters in priority order; * caches top-waiter (leftmost node). * @owner: the mutex owner */struct rt_mutex { struct rt_mutex_base rtmutex;#ifdef CONFIG_DEBUG_LOCK_ALLOC struct lockdep_map dep_map;#endif};
struct rt_mutex_waiter;struct hrtimer_sleeper;
#ifdef CONFIG_DEBUG_RT_MUTEXESextern void rt_mutex_debug_task_free(struct task_struct *tsk);#elsestatic inline void rt_mutex_debug_task_free(struct task_struct *tsk) { }#endif
#define rt_mutex_init(mutex) \do { \ static struct lock_class_key __key; \ __rt_mutex_init(mutex, __func__, &__key); \} while (0)
#ifdef CONFIG_DEBUG_LOCK_ALLOC#define __DEP_MAP_RT_MUTEX_INITIALIZER(mutexname) \ .dep_map = { \ .name = #mutexname, \ .wait_type_inner = LD_WAIT_SLEEP, \ }#else#define __DEP_MAP_RT_MUTEX_INITIALIZER(mutexname)#endif
#define __RT_MUTEX_INITIALIZER(mutexname) \{ \ .rtmutex = __RT_MUTEX_BASE_INITIALIZER(mutexname.rtmutex), \ __DEP_MAP_RT_MUTEX_INITIALIZER(mutexname) \}
#define DEFINE_RT_MUTEX(mutexname) \ struct rt_mutex mutexname = __RT_MUTEX_INITIALIZER(mutexname)
extern void __rt_mutex_init(struct rt_mutex *lock, const char *name, struct lock_class_key *key);
#ifdef CONFIG_DEBUG_LOCK_ALLOCextern void rt_mutex_lock_nested(struct rt_mutex *lock, unsigned int subclass) __acquires(lock);extern void _rt_mutex_lock_nest_lock(struct rt_mutex *lock, struct lockdep_map *nest_lock) __acquires(lock);#define rt_mutex_lock(lock) rt_mutex_lock_nested(lock, 0)#define rt_mutex_lock_nest_lock(lock, nest_lock) \ do { \ typecheck(struct lockdep_map *, &(nest_lock)->dep_map); \ _rt_mutex_lock_nest_lock(lock, &(nest_lock)->dep_map); \ } while (0)
#elseextern void rt_mutex_lock(struct rt_mutex *lock) __acquires(lock);#define rt_mutex_lock_nested(lock, subclass) rt_mutex_lock(lock)#define rt_mutex_lock_nest_lock(lock, nest_lock) rt_mutex_lock(lock)#endif
extern int rt_mutex_lock_interruptible(struct rt_mutex *lock) __cond_acquires(0, lock);extern int rt_mutex_lock_killable(struct rt_mutex *lock) __cond_acquires(0, lock);extern int rt_mutex_trylock(struct rt_mutex *lock) __cond_acquires(true, lock);
extern void rt_mutex_unlock(struct rt_mutex *lock) __releases(lock);
#endif