Lines Matching refs:rq

121 static inline struct rq *rq_of_rt_rq(struct rt_rq *rt_rq)  in rq_of_rt_rq()
123 return rt_rq->rq; in rq_of_rt_rq()
131 static inline struct rq *rq_of_rt_se(struct sched_rt_entity *rt_se) in rq_of_rt_se()
135 return rt_rq->rq; in rq_of_rt_se()
160 struct rq *rq = cpu_rq(cpu); in init_tg_rt_entry() local
164 rt_rq->rq = rq; in init_tg_rt_entry()
174 rt_se->rt_rq = &rq->rt; in init_tg_rt_entry()
232 static inline struct rq *rq_of_rt_rq(struct rt_rq *rt_rq) in rq_of_rt_rq()
234 return container_of(rt_rq, struct rq, rt); in rq_of_rt_rq()
237 static inline struct rq *rq_of_rt_se(struct sched_rt_entity *rt_se) in rq_of_rt_se()
246 struct rq *rq = rq_of_rt_se(rt_se); in rt_rq_of_se() local
248 return &rq->rt; in rt_rq_of_se()
261 static void pull_rt_task(struct rq *this_rq);
263 static inline bool need_pull_rt_task(struct rq *rq, struct task_struct *prev) in need_pull_rt_task() argument
266 return rq->rt.highest_prio.curr > prev->prio; in need_pull_rt_task()
269 static inline int rt_overloaded(struct rq *rq) in rt_overloaded() argument
271 return atomic_read(&rq->rd->rto_count); in rt_overloaded()
274 static inline void rt_set_overload(struct rq *rq) in rt_set_overload() argument
276 if (!rq->online) in rt_set_overload()
279 cpumask_set_cpu(rq->cpu, rq->rd->rto_mask); in rt_set_overload()
290 atomic_inc(&rq->rd->rto_count); in rt_set_overload()
293 static inline void rt_clear_overload(struct rq *rq) in rt_clear_overload() argument
295 if (!rq->online) in rt_clear_overload()
299 atomic_dec(&rq->rd->rto_count); in rt_clear_overload()
300 cpumask_clear_cpu(rq->cpu, rq->rd->rto_mask); in rt_clear_overload()
350 static inline int has_pushable_tasks(struct rq *rq) in has_pushable_tasks() argument
352 return !plist_head_empty(&rq->rt.pushable_tasks); in has_pushable_tasks()
358 static void push_rt_tasks(struct rq *);
359 static void pull_rt_task(struct rq *);
361 static inline void rt_queue_push_tasks(struct rq *rq) in rt_queue_push_tasks() argument
363 if (!has_pushable_tasks(rq)) in rt_queue_push_tasks()
366 queue_balance_callback(rq, &per_cpu(rt_push_head, rq->cpu), push_rt_tasks); in rt_queue_push_tasks()
369 static inline void rt_queue_pull_task(struct rq *rq) in rt_queue_pull_task() argument
371 queue_balance_callback(rq, &per_cpu(rt_pull_head, rq->cpu), pull_rt_task); in rt_queue_pull_task()
374 static void enqueue_pushable_task(struct rq *rq, struct task_struct *p) in enqueue_pushable_task() argument
376 plist_del(&p->pushable_tasks, &rq->rt.pushable_tasks); in enqueue_pushable_task()
378 plist_add(&p->pushable_tasks, &rq->rt.pushable_tasks); in enqueue_pushable_task()
381 if (p->prio < rq->rt.highest_prio.next) in enqueue_pushable_task()
382 rq->rt.highest_prio.next = p->prio; in enqueue_pushable_task()
385 static void dequeue_pushable_task(struct rq *rq, struct task_struct *p) in dequeue_pushable_task() argument
387 plist_del(&p->pushable_tasks, &rq->rt.pushable_tasks); in dequeue_pushable_task()
390 if (has_pushable_tasks(rq)) { in dequeue_pushable_task()
391 p = plist_first_entry(&rq->rt.pushable_tasks, in dequeue_pushable_task()
393 rq->rt.highest_prio.next = p->prio; in dequeue_pushable_task()
395 rq->rt.highest_prio.next = MAX_RT_PRIO; in dequeue_pushable_task()
400 static inline void enqueue_pushable_task(struct rq *rq, struct task_struct *p) in enqueue_pushable_task() argument
404 static inline void dequeue_pushable_task(struct rq *rq, struct task_struct *p) in dequeue_pushable_task() argument
418 static inline bool need_pull_rt_task(struct rq *rq, struct task_struct *prev) in need_pull_rt_task() argument
423 static inline void pull_rt_task(struct rq *this_rq) in pull_rt_task()
427 static inline void rt_queue_push_tasks(struct rq *rq) in rt_queue_push_tasks() argument
470 #define for_each_rt_rq(rt_rq, iter, rq) \ argument
473 (rt_rq = iter->rt_rq[cpu_of(rq)]);)
489 struct rq *rq = rq_of_rt_rq(rt_rq); in sched_rt_rq_enqueue() local
492 int cpu = cpu_of(rq); in sched_rt_rq_enqueue()
503 resched_curr(rq); in sched_rt_rq_enqueue()
577 #define for_each_rt_rq(rt_rq, iter, rq) \ argument
578 for ((void) iter, rt_rq = &rq->rt; rt_rq; rt_rq = NULL)
590 struct rq *rq = rq_of_rt_rq(rt_rq); in sched_rt_rq_enqueue() local
596 resched_curr(rq); in sched_rt_rq_enqueue()
691 static void __disable_runtime(struct rq *rq) in __disable_runtime() argument
693 struct root_domain *rd = rq->rd; in __disable_runtime()
700 for_each_rt_rq(rt_rq, iter, rq) { in __disable_runtime()
773 static void __enable_runtime(struct rq *rq) in __enable_runtime() argument
784 for_each_rt_rq(rt_rq, iter, rq) { in __enable_runtime()
834 struct rq *rq = rq_of_rt_rq(rt_rq); in do_sched_rt_period_timer() local
849 raw_spin_lock(&rq->lock); in do_sched_rt_period_timer()
850 update_rq_clock(rq); in do_sched_rt_period_timer()
871 if (rt_rq->rt_nr_running && rq->curr == rq->idle) in do_sched_rt_period_timer()
872 rq_clock_cancel_skipupdate(rq); in do_sched_rt_period_timer()
887 raw_spin_unlock(&rq->lock); in do_sched_rt_period_timer()
955 static void update_curr_rt(struct rq *rq) in update_curr_rt() argument
957 struct task_struct *curr = rq->curr; in update_curr_rt()
965 now = rq_clock_task(rq); in update_curr_rt()
989 resched_curr(rq); in update_curr_rt()
998 struct rq *rq = rq_of_rt_rq(rt_rq); in dequeue_top_rt_rq() local
1000 BUG_ON(&rq->rt != rt_rq); in dequeue_top_rt_rq()
1005 BUG_ON(!rq->nr_running); in dequeue_top_rt_rq()
1007 sub_nr_running(rq, rt_rq->rt_nr_running); in dequeue_top_rt_rq()
1015 struct rq *rq = rq_of_rt_rq(rt_rq); in enqueue_top_rt_rq() local
1017 BUG_ON(&rq->rt != rt_rq); in enqueue_top_rt_rq()
1026 add_nr_running(rq, rt_rq->rt_nr_running); in enqueue_top_rt_rq()
1031 cpufreq_update_util(rq, 0); in enqueue_top_rt_rq()
1039 struct rq *rq = rq_of_rt_rq(rt_rq); in inc_rt_prio_smp() local
1045 if (&rq->rt != rt_rq) in inc_rt_prio_smp()
1048 if (rq->online && prio < prev_prio) in inc_rt_prio_smp()
1049 cpupri_set(&rq->rd->cpupri, rq->cpu, prio); in inc_rt_prio_smp()
1055 struct rq *rq = rq_of_rt_rq(rt_rq); in dec_rt_prio_smp() local
1061 if (&rq->rt != rt_rq) in dec_rt_prio_smp()
1064 if (rq->online && rt_rq->highest_prio.curr != prev_prio) in dec_rt_prio_smp()
1065 cpupri_set(&rq->rd->cpupri, rq->cpu, rt_rq->highest_prio.curr); in dec_rt_prio_smp()
1302 struct rq *rq = rq_of_rt_se(rt_se); in enqueue_rt_entity() local
1307 enqueue_top_rt_rq(&rq->rt); in enqueue_rt_entity()
1312 struct rq *rq = rq_of_rt_se(rt_se); in dequeue_rt_entity() local
1322 enqueue_top_rt_rq(&rq->rt); in dequeue_rt_entity()
1329 enqueue_task_rt(struct rq *rq, struct task_struct *p, int flags) in enqueue_task_rt() argument
1338 if (!task_current(rq, p) && p->nr_cpus_allowed > 1) in enqueue_task_rt()
1339 enqueue_pushable_task(rq, p); in enqueue_task_rt()
1342 static void dequeue_task_rt(struct rq *rq, struct task_struct *p, int flags) in dequeue_task_rt() argument
1346 update_curr_rt(rq); in dequeue_task_rt()
1349 dequeue_pushable_task(rq, p); in dequeue_task_rt()
1370 static void requeue_task_rt(struct rq *rq, struct task_struct *p, int head) in requeue_task_rt() argument
1381 static void yield_task_rt(struct rq *rq) in yield_task_rt() argument
1383 requeue_task_rt(rq, rq->curr, 0); in yield_task_rt()
1393 struct rq *rq; in select_task_rq_rt() local
1399 rq = cpu_rq(cpu); in select_task_rq_rt()
1402 curr = READ_ONCE(rq->curr); /* unlocked access */ in select_task_rq_rt()
1445 static void check_preempt_equal_prio(struct rq *rq, struct task_struct *p) in check_preempt_equal_prio() argument
1451 if (rq->curr->nr_cpus_allowed == 1 || in check_preempt_equal_prio()
1452 !cpupri_find(&rq->rd->cpupri, rq->curr, NULL)) in check_preempt_equal_prio()
1460 && cpupri_find(&rq->rd->cpupri, p, NULL)) in check_preempt_equal_prio()
1468 requeue_task_rt(rq, p, 1); in check_preempt_equal_prio()
1469 resched_curr(rq); in check_preempt_equal_prio()
1472 static int balance_rt(struct rq *rq, struct task_struct *p, struct rq_flags *rf) in balance_rt() argument
1474 if (!on_rt_rq(&p->rt) && need_pull_rt_task(rq, p)) { in balance_rt()
1481 rq_unpin_lock(rq, rf); in balance_rt()
1482 pull_rt_task(rq); in balance_rt()
1483 rq_repin_lock(rq, rf); in balance_rt()
1486 return sched_stop_runnable(rq) || sched_dl_runnable(rq) || sched_rt_runnable(rq); in balance_rt()
1493 static void check_preempt_curr_rt(struct rq *rq, struct task_struct *p, int flags) in check_preempt_curr_rt() argument
1495 if (p->prio < rq->curr->prio) { in check_preempt_curr_rt()
1496 resched_curr(rq); in check_preempt_curr_rt()
1513 if (p->prio == rq->curr->prio && !test_tsk_need_resched(rq->curr)) in check_preempt_curr_rt()
1514 check_preempt_equal_prio(rq, p); in check_preempt_curr_rt()
1518 static inline void set_next_task_rt(struct rq *rq, struct task_struct *p) in set_next_task_rt() argument
1520 p->se.exec_start = rq_clock_task(rq); in set_next_task_rt()
1523 dequeue_pushable_task(rq, p); in set_next_task_rt()
1530 if (rq->curr->sched_class != &rt_sched_class) in set_next_task_rt()
1531 update_rt_rq_load_avg(rq_clock_pelt(rq), rq, 0); in set_next_task_rt()
1533 rt_queue_push_tasks(rq); in set_next_task_rt()
1536 static struct sched_rt_entity *pick_next_rt_entity(struct rq *rq, in pick_next_rt_entity() argument
1553 static struct task_struct *_pick_next_task_rt(struct rq *rq) in _pick_next_task_rt() argument
1556 struct rt_rq *rt_rq = &rq->rt; in _pick_next_task_rt()
1559 rt_se = pick_next_rt_entity(rq, rt_rq); in _pick_next_task_rt()
1568 pick_next_task_rt(struct rq *rq, struct task_struct *prev, struct rq_flags *rf) in pick_next_task_rt() argument
1574 if (!sched_rt_runnable(rq)) in pick_next_task_rt()
1577 p = _pick_next_task_rt(rq); in pick_next_task_rt()
1578 set_next_task_rt(rq, p); in pick_next_task_rt()
1582 static void put_prev_task_rt(struct rq *rq, struct task_struct *p) in put_prev_task_rt() argument
1584 update_curr_rt(rq); in put_prev_task_rt()
1586 update_rt_rq_load_avg(rq_clock_pelt(rq), rq, 1); in put_prev_task_rt()
1593 enqueue_pushable_task(rq, p); in put_prev_task_rt()
1601 static int pick_rt_task(struct rq *rq, struct task_struct *p, int cpu) in pick_rt_task() argument
1603 if (!task_running(rq, p) && in pick_rt_task()
1614 static struct task_struct *pick_highest_pushable_task(struct rq *rq, int cpu) in pick_highest_pushable_task() argument
1616 struct plist_head *head = &rq->rt.pushable_tasks; in pick_highest_pushable_task()
1619 if (!has_pushable_tasks(rq)) in pick_highest_pushable_task()
1623 if (pick_rt_task(rq, p, cpu)) in pick_highest_pushable_task()
1708 static struct rq *find_lock_lowest_rq(struct task_struct *task, struct rq *rq) in find_lock_lowest_rq() argument
1710 struct rq *lowest_rq = NULL; in find_lock_lowest_rq()
1717 if ((cpu == -1) || (cpu == rq->cpu)) in find_lock_lowest_rq()
1733 if (double_lock_balance(rq, lowest_rq)) { in find_lock_lowest_rq()
1740 if (unlikely(task_rq(task) != rq || in find_lock_lowest_rq()
1742 task_running(rq, task) || in find_lock_lowest_rq()
1746 double_unlock_balance(rq, lowest_rq); in find_lock_lowest_rq()
1757 double_unlock_balance(rq, lowest_rq); in find_lock_lowest_rq()
1764 static struct task_struct *pick_next_pushable_task(struct rq *rq) in pick_next_pushable_task() argument
1768 if (!has_pushable_tasks(rq)) in pick_next_pushable_task()
1771 p = plist_first_entry(&rq->rt.pushable_tasks, in pick_next_pushable_task()
1774 BUG_ON(rq->cpu != task_cpu(p)); in pick_next_pushable_task()
1775 BUG_ON(task_current(rq, p)); in pick_next_pushable_task()
1789 static int push_rt_task(struct rq *rq) in push_rt_task() argument
1792 struct rq *lowest_rq; in push_rt_task()
1795 if (!rq->rt.overloaded) in push_rt_task()
1798 next_task = pick_next_pushable_task(rq); in push_rt_task()
1803 if (WARN_ON(next_task == rq->curr)) in push_rt_task()
1811 if (unlikely(next_task->prio < rq->curr->prio)) { in push_rt_task()
1812 resched_curr(rq); in push_rt_task()
1820 lowest_rq = find_lock_lowest_rq(next_task, rq); in push_rt_task()
1831 task = pick_next_pushable_task(rq); in push_rt_task()
1854 deactivate_task(rq, next_task, 0); in push_rt_task()
1861 double_unlock_balance(rq, lowest_rq); in push_rt_task()
1869 static void push_rt_tasks(struct rq *rq) in push_rt_tasks() argument
1872 while (push_rt_task(rq)) in push_rt_tasks()
1976 static void tell_cpu_to_push(struct rq *rq) in tell_cpu_to_push() argument
1981 atomic_inc(&rq->rd->rto_loop_next); in tell_cpu_to_push()
1984 if (!rto_start_trylock(&rq->rd->rto_loop_start)) in tell_cpu_to_push()
1987 raw_spin_lock(&rq->rd->rto_lock); in tell_cpu_to_push()
1995 if (rq->rd->rto_cpu < 0) in tell_cpu_to_push()
1996 cpu = rto_next_cpu(rq->rd); in tell_cpu_to_push()
1998 raw_spin_unlock(&rq->rd->rto_lock); in tell_cpu_to_push()
2000 rto_start_unlock(&rq->rd->rto_loop_start); in tell_cpu_to_push()
2004 sched_get_rd(rq->rd); in tell_cpu_to_push()
2005 irq_work_queue_on(&rq->rd->rto_push_work, cpu); in tell_cpu_to_push()
2014 struct rq *rq; in rto_push_irq_work_func() local
2017 rq = this_rq(); in rto_push_irq_work_func()
2023 if (has_pushable_tasks(rq)) { in rto_push_irq_work_func()
2024 raw_spin_lock(&rq->lock); in rto_push_irq_work_func()
2025 push_rt_tasks(rq); in rto_push_irq_work_func()
2026 raw_spin_unlock(&rq->lock); in rto_push_irq_work_func()
2046 static void pull_rt_task(struct rq *this_rq) in pull_rt_task()
2051 struct rq *src_rq; in pull_rt_task()
2148 static void task_woken_rt(struct rq *rq, struct task_struct *p) in task_woken_rt() argument
2150 if (!task_running(rq, p) && in task_woken_rt()
2151 !test_tsk_need_resched(rq->curr) && in task_woken_rt()
2153 (dl_task(rq->curr) || rt_task(rq->curr)) && in task_woken_rt()
2154 (rq->curr->nr_cpus_allowed < 2 || in task_woken_rt()
2155 rq->curr->prio <= p->prio)) in task_woken_rt()
2156 push_rt_tasks(rq); in task_woken_rt()
2160 static void rq_online_rt(struct rq *rq) in rq_online_rt() argument
2162 if (rq->rt.overloaded) in rq_online_rt()
2163 rt_set_overload(rq); in rq_online_rt()
2165 __enable_runtime(rq); in rq_online_rt()
2167 cpupri_set(&rq->rd->cpupri, rq->cpu, rq->rt.highest_prio.curr); in rq_online_rt()
2171 static void rq_offline_rt(struct rq *rq) in rq_offline_rt() argument
2173 if (rq->rt.overloaded) in rq_offline_rt()
2174 rt_clear_overload(rq); in rq_offline_rt()
2176 __disable_runtime(rq); in rq_offline_rt()
2178 cpupri_set(&rq->rd->cpupri, rq->cpu, CPUPRI_INVALID); in rq_offline_rt()
2185 static void switched_from_rt(struct rq *rq, struct task_struct *p) in switched_from_rt() argument
2194 if (!task_on_rq_queued(p) || rq->rt.rt_nr_running) in switched_from_rt()
2197 rt_queue_pull_task(rq); in switched_from_rt()
2216 static void switched_to_rt(struct rq *rq, struct task_struct *p) in switched_to_rt() argument
2225 if (task_on_rq_queued(p) && rq->curr != p) { in switched_to_rt()
2227 if (p->nr_cpus_allowed > 1 && rq->rt.overloaded) in switched_to_rt()
2228 rt_queue_push_tasks(rq); in switched_to_rt()
2230 if (p->prio < rq->curr->prio && cpu_online(cpu_of(rq))) in switched_to_rt()
2231 resched_curr(rq); in switched_to_rt()
2240 prio_changed_rt(struct rq *rq, struct task_struct *p, int oldprio) in prio_changed_rt() argument
2245 if (rq->curr == p) { in prio_changed_rt()
2252 rt_queue_pull_task(rq); in prio_changed_rt()
2258 if (p->prio > rq->rt.highest_prio.curr) in prio_changed_rt()
2259 resched_curr(rq); in prio_changed_rt()
2263 resched_curr(rq); in prio_changed_rt()
2271 if (p->prio < rq->curr->prio) in prio_changed_rt()
2272 resched_curr(rq); in prio_changed_rt()
2277 static void watchdog(struct rq *rq, struct task_struct *p) in watchdog() argument
2301 static inline void watchdog(struct rq *rq, struct task_struct *p) { } in watchdog() argument
2312 static void task_tick_rt(struct rq *rq, struct task_struct *p, int queued) in task_tick_rt() argument
2316 update_curr_rt(rq); in task_tick_rt()
2317 update_rt_rq_load_avg(rq_clock_pelt(rq), rq, 1); in task_tick_rt()
2319 watchdog(rq, p); in task_tick_rt()
2339 requeue_task_rt(rq, p, 0); in task_tick_rt()
2340 resched_curr(rq); in task_tick_rt()
2346 static unsigned int get_rr_interval_rt(struct rq *rq, struct task_struct *task) in get_rr_interval_rt() argument