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 rt_prio(int prio)9static inline bool rt_prio(int prio) 10 { 11 return unlikely(prio < MAX_RT_PRIO && prio >= MAX_DL_PRIO); 12 } 13 rt_or_dl_prio(int prio)14static 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 */ rt_task(struct task_struct * p)23static inline bool rt_task(struct task_struct *p) 24 { 25 return rt_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 */ rt_or_dl_task(struct task_struct * p)33static inline bool rt_or_dl_task(struct task_struct *p) 34 { 35 return rt_or_dl_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 */ rt_or_dl_task_policy(struct task_struct * tsk)42static 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_futex_pre_schedule(void); 56 extern void rt_mutex_schedule(void); 57 extern void rt_mutex_post_schedule(void); 58 extern void rt_mutex_futex_post_schedule(void); 59 60 /* 61 * Must hold either p->pi_lock or task_rq(p)->lock. 62 */ rt_mutex_get_top_task(struct task_struct * p)63static inline struct task_struct *rt_mutex_get_top_task(struct task_struct *p) 64 { 65 return p->pi_top_task; 66 } 67 extern void rt_mutex_setprio(struct task_struct *p, struct task_struct *pi_task); 68 extern void rt_mutex_adjust_pi(struct task_struct *p); 69 #else rt_mutex_get_top_task(struct task_struct * task)70static inline struct task_struct *rt_mutex_get_top_task(struct task_struct *task) 71 { 72 return NULL; 73 } 74 # define rt_mutex_adjust_pi(p) do { } while (0) 75 #endif 76 77 extern void normalize_rt_tasks(void); 78 79 80 /* 81 * default timeslice is 100 msecs (used only for SCHED_RR tasks). 82 * Timeslices get refilled after they expire. 83 */ 84 #define RR_TIMESLICE (100 * HZ / 1000) 85 86 #endif /* _LINUX_SCHED_RT_H */ 87