1 /* SPDX-License-Identifier: GPL-2.0 */ 2 #ifndef _LINUX_SCHED_DEADLINE_H 3 #define _LINUX_SCHED_DEADLINE_H 4 5 /* 6 * SCHED_DEADLINE tasks has negative priorities, reflecting 7 * the fact that any of them has higher prio than RT and 8 * NORMAL/BATCH tasks. 9 */ 10 11 #include <linux/sched.h> 12 dl_prio(int prio)13static inline bool dl_prio(int prio) 14 { 15 return unlikely(prio < MAX_DL_PRIO); 16 } 17 18 /* 19 * Returns true if a task has a priority that belongs to DL class. PI-boosted 20 * tasks will return true. Use dl_policy() to ignore PI-boosted tasks. 21 */ dl_task(struct task_struct * p)22static inline bool dl_task(struct task_struct *p) 23 { 24 return dl_prio(p->prio); 25 } 26 dl_time_before(u64 a,u64 b)27static inline bool dl_time_before(u64 a, u64 b) 28 { 29 return (s64)(a - b) < 0; 30 } 31 32 struct root_domain; 33 extern void dl_add_task_root_domain(struct task_struct *p); 34 extern void dl_clear_root_domain(struct root_domain *rd); 35 extern void dl_clear_root_domain_cpu(int cpu); 36 /* 37 * Return whether moving DL task @p to @new_mask requires moving DL 38 * bandwidth accounting between root domains. This helper is specific to 39 * DL bandwidth move accounting semantics and is shared by 40 * cpuset_can_attach() and set_cpus_allowed_dl() so both paths use the 41 * same source root-domain test. 42 */ 43 extern bool dl_task_needs_bw_move(struct task_struct *p, 44 const struct cpumask *new_mask); 45 46 extern u64 dl_cookie; 47 extern bool dl_bw_visited(int cpu, u64 cookie); 48 dl_server(struct sched_dl_entity * dl_se)49static inline bool dl_server(struct sched_dl_entity *dl_se) 50 { 51 return dl_se->dl_server; 52 } 53 dl_task_of(struct sched_dl_entity * dl_se)54static inline struct task_struct *dl_task_of(struct sched_dl_entity *dl_se) 55 { 56 BUG_ON(dl_server(dl_se)); 57 return container_of(dl_se, struct task_struct, dl); 58 } 59 60 /* 61 * Regarding the deadline, a task with implicit deadline has a relative 62 * deadline == relative period. A task with constrained deadline has a 63 * relative deadline <= relative period. 64 * 65 * We support constrained deadline tasks. However, there are some restrictions 66 * applied only for tasks which do not have an implicit deadline. See 67 * update_dl_entity() to know more about such restrictions. 68 * 69 * The dl_is_implicit() returns true if the task has an implicit deadline. 70 */ dl_is_implicit(struct sched_dl_entity * dl_se)71static inline bool dl_is_implicit(struct sched_dl_entity *dl_se) 72 { 73 return dl_se->dl_deadline == dl_se->dl_period; 74 } 75 76 #endif /* _LINUX_SCHED_DEADLINE_H */ 77