| 1 | /* SPDX-License-Identifier: GPL-2.0 */ | 
|---|
| 2 | #ifndef _LINUX_SCHED_RT_H | 
|---|
| 3 | #define _LINUX_SCHED_RT_H | 
|---|
| 4 |  | 
|---|
| 5 | #include <linux/sched.h> | 
|---|
| 6 |  | 
|---|
| 7 | struct task_struct; | 
|---|
| 8 |  | 
|---|
| 9 | static inline bool rt_prio(int prio) | 
|---|
| 10 | { | 
|---|
| 11 | return unlikely(prio < MAX_RT_PRIO && prio >= MAX_DL_PRIO); | 
|---|
| 12 | } | 
|---|
| 13 |  | 
|---|
| 14 | static inline bool rt_or_dl_prio(int prio) | 
|---|
| 15 | { | 
|---|
| 16 | return unlikely(prio < MAX_RT_PRIO); | 
|---|
| 17 | } | 
|---|
| 18 |  | 
|---|
| 19 | /* | 
|---|
| 20 | * Returns true if a task has a priority that belongs to RT class. PI-boosted | 
|---|
| 21 | * tasks will return true. Use rt_policy() to ignore PI-boosted tasks. | 
|---|
| 22 | */ | 
|---|
| 23 | static inline bool rt_task(struct task_struct *p) | 
|---|
| 24 | { | 
|---|
| 25 | return rt_prio(prio: p->prio); | 
|---|
| 26 | } | 
|---|
| 27 |  | 
|---|
| 28 | /* | 
|---|
| 29 | * Returns true if a task has a priority that belongs to RT or DL classes. | 
|---|
| 30 | * PI-boosted tasks will return true. Use rt_or_dl_task_policy() to ignore | 
|---|
| 31 | * PI-boosted tasks. | 
|---|
| 32 | */ | 
|---|
| 33 | static inline bool rt_or_dl_task(struct task_struct *p) | 
|---|
| 34 | { | 
|---|
| 35 | return rt_or_dl_prio(prio: p->prio); | 
|---|
| 36 | } | 
|---|
| 37 |  | 
|---|
| 38 | /* | 
|---|
| 39 | * Returns true if a task has a policy that belongs to RT or DL classes. | 
|---|
| 40 | * PI-boosted tasks will return false. | 
|---|
| 41 | */ | 
|---|
| 42 | static inline bool rt_or_dl_task_policy(struct task_struct *tsk) | 
|---|
| 43 | { | 
|---|
| 44 | int policy = tsk->policy; | 
|---|
| 45 |  | 
|---|
| 46 | if (policy == SCHED_FIFO || policy == SCHED_RR) | 
|---|
| 47 | return true; | 
|---|
| 48 | if (policy == SCHED_DEADLINE) | 
|---|
| 49 | return true; | 
|---|
| 50 | return false; | 
|---|
| 51 | } | 
|---|
| 52 |  | 
|---|
| 53 | #ifdef CONFIG_RT_MUTEXES | 
|---|
| 54 | extern void rt_mutex_pre_schedule(void); | 
|---|
| 55 | extern void rt_mutex_schedule(void); | 
|---|
| 56 | extern void rt_mutex_post_schedule(void); | 
|---|
| 57 |  | 
|---|
| 58 | /* | 
|---|
| 59 | * Must hold either p->pi_lock or task_rq(p)->lock. | 
|---|
| 60 | */ | 
|---|
| 61 | static inline struct task_struct *rt_mutex_get_top_task(struct task_struct *p) | 
|---|
| 62 | { | 
|---|
| 63 | return p->pi_top_task; | 
|---|
| 64 | } | 
|---|
| 65 | extern void rt_mutex_setprio(struct task_struct *p, struct task_struct *pi_task); | 
|---|
| 66 | extern void rt_mutex_adjust_pi(struct task_struct *p); | 
|---|
| 67 | #else | 
|---|
| 68 | static inline struct task_struct *rt_mutex_get_top_task(struct task_struct *task) | 
|---|
| 69 | { | 
|---|
| 70 | return NULL; | 
|---|
| 71 | } | 
|---|
| 72 | # define rt_mutex_adjust_pi(p)		do { } while (0) | 
|---|
| 73 | #endif | 
|---|
| 74 |  | 
|---|
| 75 | extern void normalize_rt_tasks(void); | 
|---|
| 76 |  | 
|---|
| 77 |  | 
|---|
| 78 | /* | 
|---|
| 79 | * default timeslice is 100 msecs (used only for SCHED_RR tasks). | 
|---|
| 80 | * Timeslices get refilled after they expire. | 
|---|
| 81 | */ | 
|---|
| 82 | #define RR_TIMESLICE		(100 * HZ / 1000) | 
|---|
| 83 |  | 
|---|
| 84 | #endif /* _LINUX_SCHED_RT_H */ | 
|---|
| 85 |  | 
|---|