• Home
  • Raw
  • Download

Lines Matching refs:rq

28 static inline struct rq *rq_of_dl_rq(struct dl_rq *dl_rq)  in rq_of_dl_rq()
30 return container_of(dl_rq, struct rq, dl); in rq_of_dl_rq()
36 struct rq *rq = task_rq(p); in dl_rq_of_se() local
38 return &rq->dl; in dl_rq_of_se()
158 struct rq *rq; in dl_change_utilization() local
165 rq = task_rq(p); in dl_change_utilization()
167 sub_running_bw(&p->dl, &rq->dl); in dl_change_utilization()
179 __sub_rq_bw(p->dl.dl_bw, &rq->dl); in dl_change_utilization()
180 __add_rq_bw(new_bw, &rq->dl); in dl_change_utilization()
242 struct rq *rq = rq_of_dl_rq(dl_rq); in task_non_contending() local
265 zerolag_time -= rq_clock(rq); in task_non_contending()
278 sub_rq_bw(&p->dl, &rq->dl); in task_non_contending()
378 static inline int dl_overloaded(struct rq *rq) in dl_overloaded() argument
380 return atomic_read(&rq->rd->dlo_count); in dl_overloaded()
383 static inline void dl_set_overload(struct rq *rq) in dl_set_overload() argument
385 if (!rq->online) in dl_set_overload()
388 cpumask_set_cpu(rq->cpu, rq->rd->dlo_mask); in dl_set_overload()
396 atomic_inc(&rq->rd->dlo_count); in dl_set_overload()
399 static inline void dl_clear_overload(struct rq *rq) in dl_clear_overload() argument
401 if (!rq->online) in dl_clear_overload()
404 atomic_dec(&rq->rd->dlo_count); in dl_clear_overload()
405 cpumask_clear_cpu(rq->cpu, rq->rd->dlo_mask); in dl_clear_overload()
445 static void enqueue_pushable_dl_task(struct rq *rq, struct task_struct *p) in enqueue_pushable_dl_task() argument
447 struct dl_rq *dl_rq = &rq->dl; in enqueue_pushable_dl_task()
475 static void dequeue_pushable_dl_task(struct rq *rq, struct task_struct *p) in dequeue_pushable_dl_task() argument
477 struct dl_rq *dl_rq = &rq->dl; in dequeue_pushable_dl_task()
496 static inline int has_pushable_dl_tasks(struct rq *rq) in has_pushable_dl_tasks() argument
498 return !RB_EMPTY_ROOT(&rq->dl.pushable_dl_tasks_root.rb_root); in has_pushable_dl_tasks()
501 static int push_dl_task(struct rq *rq);
503 static inline bool need_pull_dl_task(struct rq *rq, struct task_struct *prev) in need_pull_dl_task() argument
511 static void push_dl_tasks(struct rq *);
512 static void pull_dl_task(struct rq *);
514 static inline void deadline_queue_push_tasks(struct rq *rq) in deadline_queue_push_tasks() argument
516 if (!has_pushable_dl_tasks(rq)) in deadline_queue_push_tasks()
519 queue_balance_callback(rq, &per_cpu(dl_push_head, rq->cpu), push_dl_tasks); in deadline_queue_push_tasks()
522 static inline void deadline_queue_pull_task(struct rq *rq) in deadline_queue_pull_task() argument
524 queue_balance_callback(rq, &per_cpu(dl_pull_head, rq->cpu), pull_dl_task); in deadline_queue_pull_task()
527 static struct rq *find_lock_later_rq(struct task_struct *task, struct rq *rq);
529 static struct rq *dl_task_offline_migration(struct rq *rq, struct task_struct *p) in dl_task_offline_migration() argument
531 struct rq *later_rq = NULL; in dl_task_offline_migration()
534 later_rq = find_lock_later_rq(p, rq); in dl_task_offline_migration()
558 double_lock_balance(rq, later_rq); in dl_task_offline_migration()
568 sub_running_bw(&p->dl, &rq->dl); in dl_task_offline_migration()
569 sub_rq_bw(&p->dl, &rq->dl); in dl_task_offline_migration()
574 sub_rq_bw(&p->dl, &rq->dl); in dl_task_offline_migration()
583 dl_b = &rq->rd->dl_bw; in dl_task_offline_migration()
585 __dl_sub(dl_b, p->dl.dl_bw, cpumask_weight(rq->rd->span)); in dl_task_offline_migration()
594 double_unlock_balance(later_rq, rq); in dl_task_offline_migration()
602 void enqueue_pushable_dl_task(struct rq *rq, struct task_struct *p) in enqueue_pushable_dl_task() argument
607 void dequeue_pushable_dl_task(struct rq *rq, struct task_struct *p) in dequeue_pushable_dl_task() argument
621 static inline bool need_pull_dl_task(struct rq *rq, struct task_struct *prev) in need_pull_dl_task() argument
626 static inline void pull_dl_task(struct rq *rq) in pull_dl_task() argument
630 static inline void deadline_queue_push_tasks(struct rq *rq) in deadline_queue_push_tasks() argument
634 static inline void deadline_queue_pull_task(struct rq *rq) in deadline_queue_pull_task() argument
639 static void enqueue_task_dl(struct rq *rq, struct task_struct *p, int flags);
640 static void __dequeue_task_dl(struct rq *rq, struct task_struct *p, int flags);
641 static void check_preempt_curr_dl(struct rq *rq, struct task_struct *p, int flags);
658 struct rq *rq = rq_of_dl_rq(dl_rq); in setup_new_dl_entity() local
661 WARN_ON(dl_time_before(rq_clock(rq), dl_se->deadline)); in setup_new_dl_entity()
676 dl_se->deadline = rq_clock(rq) + dl_se->dl_deadline; in setup_new_dl_entity()
702 struct rq *rq = rq_of_dl_rq(dl_rq); in replenish_dl_entity() local
711 dl_se->deadline = rq_clock(rq) + pi_se->dl_deadline; in replenish_dl_entity()
738 if (dl_time_before(dl_se->deadline, rq_clock(rq))) { in replenish_dl_entity()
740 dl_se->deadline = rq_clock(rq) + pi_se->dl_deadline; in replenish_dl_entity()
823 update_dl_revised_wakeup(struct sched_dl_entity *dl_se, struct rq *rq) in update_dl_revised_wakeup() argument
825 u64 laxity = dl_se->deadline - rq_clock(rq); in update_dl_revised_wakeup()
833 WARN_ON(dl_time_before(dl_se->deadline, rq_clock(rq))); in update_dl_revised_wakeup()
888 struct rq *rq = rq_of_dl_rq(dl_rq); in update_dl_entity() local
890 if (dl_time_before(dl_se->deadline, rq_clock(rq)) || in update_dl_entity()
891 dl_entity_overflow(dl_se, pi_se, rq_clock(rq))) { in update_dl_entity()
894 !dl_time_before(dl_se->deadline, rq_clock(rq)) && in update_dl_entity()
896 update_dl_revised_wakeup(dl_se, rq); in update_dl_entity()
900 dl_se->deadline = rq_clock(rq) + pi_se->dl_deadline; in update_dl_entity()
924 struct rq *rq = task_rq(p); in start_dl_timer() local
928 lockdep_assert_held(&rq->lock); in start_dl_timer()
937 delta = ktime_to_ns(now) - rq_clock(rq); in start_dl_timer()
985 struct rq *rq; in dl_task_timer() local
987 rq = task_rq_lock(p, &rf); in dl_task_timer()
1011 update_rq_clock(rq); in dl_task_timer()
1033 if (unlikely(!rq->online)) { in dl_task_timer()
1038 lockdep_unpin_lock(&rq->lock, rf.cookie); in dl_task_timer()
1039 rq = dl_task_offline_migration(rq, p); in dl_task_timer()
1040 rf.cookie = lockdep_pin_lock(&rq->lock); in dl_task_timer()
1041 update_rq_clock(rq); in dl_task_timer()
1051 enqueue_task_dl(rq, p, ENQUEUE_REPLENISH); in dl_task_timer()
1052 if (dl_task(rq->curr)) in dl_task_timer()
1053 check_preempt_curr_dl(rq, p, 0); in dl_task_timer()
1055 resched_curr(rq); in dl_task_timer()
1062 if (has_pushable_dl_tasks(rq)) { in dl_task_timer()
1067 rq_unpin_lock(rq, &rf); in dl_task_timer()
1068 push_dl_task(rq); in dl_task_timer()
1069 rq_repin_lock(rq, &rf); in dl_task_timer()
1074 task_rq_unlock(rq, p, &rf); in dl_task_timer()
1114 struct rq *rq = rq_of_dl_rq(dl_rq_of_se(dl_se)); in dl_check_constrained_dl() local
1116 if (dl_time_before(dl_se->deadline, rq_clock(rq)) && in dl_check_constrained_dl()
1117 dl_time_before(rq_clock(rq), dl_next_period(dl_se))) { in dl_check_constrained_dl()
1153 static u64 grub_reclaim(u64 delta, struct rq *rq, struct sched_dl_entity *dl_se) in grub_reclaim() argument
1155 u64 u_inact = rq->dl.this_bw - rq->dl.running_bw; /* Utot - Uact */ in grub_reclaim()
1157 u64 u_act_min = (dl_se->dl_bw * rq->dl.bw_ratio) >> RATIO_SHIFT; in grub_reclaim()
1167 if (u_inact + rq->dl.extra_bw > BW_UNIT - u_act_min) in grub_reclaim()
1170 u_act = BW_UNIT - u_inact - rq->dl.extra_bw; in grub_reclaim()
1179 static void update_curr_dl(struct rq *rq) in update_curr_dl() argument
1181 struct task_struct *curr = rq->curr; in update_curr_dl()
1184 int cpu = cpu_of(rq); in update_curr_dl()
1198 now = rq_clock_task(rq); in update_curr_dl()
1227 rq, in update_curr_dl()
1248 __dequeue_task_dl(rq, curr, 0); in update_curr_dl()
1250 enqueue_task_dl(rq, curr, ENQUEUE_REPLENISH); in update_curr_dl()
1252 if (!is_leftmost(curr, &rq->dl)) in update_curr_dl()
1253 resched_curr(rq); in update_curr_dl()
1268 struct rt_rq *rt_rq = &rq->rt; in update_curr_dl()
1289 struct rq *rq; in inactive_task_timer() local
1291 rq = task_rq_lock(p, &rf); in inactive_task_timer()
1294 update_rq_clock(rq); in inactive_task_timer()
1315 sub_running_bw(dl_se, &rq->dl); in inactive_task_timer()
1318 task_rq_unlock(rq, p, &rf); in inactive_task_timer()
1336 struct rq *rq = rq_of_dl_rq(dl_rq); in inc_dl_deadline() local
1341 cpudl_set(&rq->rd->cpudl, rq->cpu, deadline); in inc_dl_deadline()
1347 struct rq *rq = rq_of_dl_rq(dl_rq); in dec_dl_deadline() local
1356 cpudl_clear(&rq->rd->cpudl, rq->cpu); in dec_dl_deadline()
1363 cpudl_set(&rq->rd->cpudl, rq->cpu, entry->deadline); in dec_dl_deadline()
1472 static void enqueue_task_dl(struct rq *rq, struct task_struct *p, int flags) in enqueue_task_dl() argument
1533 add_rq_bw(&p->dl, &rq->dl); in enqueue_task_dl()
1534 add_running_bw(&p->dl, &rq->dl); in enqueue_task_dl()
1558 if (!task_current(rq, p) && p->nr_cpus_allowed > 1) in enqueue_task_dl()
1559 enqueue_pushable_dl_task(rq, p); in enqueue_task_dl()
1562 static void __dequeue_task_dl(struct rq *rq, struct task_struct *p, int flags) in __dequeue_task_dl() argument
1565 dequeue_pushable_dl_task(rq, p); in __dequeue_task_dl()
1568 static void dequeue_task_dl(struct rq *rq, struct task_struct *p, int flags) in dequeue_task_dl() argument
1570 update_curr_dl(rq); in dequeue_task_dl()
1571 __dequeue_task_dl(rq, p, flags); in dequeue_task_dl()
1574 sub_running_bw(&p->dl, &rq->dl); in dequeue_task_dl()
1575 sub_rq_bw(&p->dl, &rq->dl); in dequeue_task_dl()
1601 static void yield_task_dl(struct rq *rq) in yield_task_dl() argument
1609 rq->curr->dl.dl_yielded = 1; in yield_task_dl()
1611 update_rq_clock(rq); in yield_task_dl()
1612 update_curr_dl(rq); in yield_task_dl()
1618 rq_clock_skip_update(rq); in yield_task_dl()
1629 struct rq *rq; in select_task_rq_dl() local
1634 rq = cpu_rq(cpu); in select_task_rq_dl()
1637 curr = READ_ONCE(rq->curr); /* unlocked access */ in select_task_rq_dl()
1668 struct rq *rq; in migrate_task_rq_dl() local
1673 rq = task_rq(p); in migrate_task_rq_dl()
1679 raw_spin_lock(&rq->lock); in migrate_task_rq_dl()
1681 update_rq_clock(rq); in migrate_task_rq_dl()
1682 sub_running_bw(&p->dl, &rq->dl); in migrate_task_rq_dl()
1694 sub_rq_bw(&p->dl, &rq->dl); in migrate_task_rq_dl()
1695 raw_spin_unlock(&rq->lock); in migrate_task_rq_dl()
1698 static void check_preempt_equal_dl(struct rq *rq, struct task_struct *p) in check_preempt_equal_dl() argument
1704 if (rq->curr->nr_cpus_allowed == 1 || in check_preempt_equal_dl()
1705 !cpudl_find(&rq->rd->cpudl, rq->curr, NULL)) in check_preempt_equal_dl()
1713 cpudl_find(&rq->rd->cpudl, p, NULL)) in check_preempt_equal_dl()
1716 resched_curr(rq); in check_preempt_equal_dl()
1719 static int balance_dl(struct rq *rq, struct task_struct *p, struct rq_flags *rf) in balance_dl() argument
1721 if (!on_dl_rq(&p->dl) && need_pull_dl_task(rq, p)) { in balance_dl()
1728 rq_unpin_lock(rq, rf); in balance_dl()
1729 pull_dl_task(rq); in balance_dl()
1730 rq_repin_lock(rq, rf); in balance_dl()
1733 return sched_stop_runnable(rq) || sched_dl_runnable(rq); in balance_dl()
1741 static void check_preempt_curr_dl(struct rq *rq, struct task_struct *p, in check_preempt_curr_dl() argument
1744 if (dl_entity_preempt(&p->dl, &rq->curr->dl)) { in check_preempt_curr_dl()
1745 resched_curr(rq); in check_preempt_curr_dl()
1754 if ((p->dl.deadline == rq->curr->dl.deadline) && in check_preempt_curr_dl()
1755 !test_tsk_need_resched(rq->curr)) in check_preempt_curr_dl()
1756 check_preempt_equal_dl(rq, p); in check_preempt_curr_dl()
1761 static void start_hrtick_dl(struct rq *rq, struct task_struct *p) in start_hrtick_dl() argument
1763 hrtick_start(rq, p->dl.runtime); in start_hrtick_dl()
1766 static void start_hrtick_dl(struct rq *rq, struct task_struct *p) in start_hrtick_dl() argument
1771 static void set_next_task_dl(struct rq *rq, struct task_struct *p, bool first) in set_next_task_dl() argument
1773 p->se.exec_start = rq_clock_task(rq); in set_next_task_dl()
1776 dequeue_pushable_dl_task(rq, p); in set_next_task_dl()
1781 if (hrtick_enabled(rq)) in set_next_task_dl()
1782 start_hrtick_dl(rq, p); in set_next_task_dl()
1784 if (rq->curr->sched_class != &dl_sched_class) in set_next_task_dl()
1785 update_dl_rq_load_avg(rq_clock_pelt(rq), rq, 0); in set_next_task_dl()
1787 deadline_queue_push_tasks(rq); in set_next_task_dl()
1801 pick_next_task_dl(struct rq *rq, struct task_struct *prev, struct rq_flags *rf) in pick_next_task_dl() argument
1804 struct dl_rq *dl_rq = &rq->dl; in pick_next_task_dl()
1809 if (!sched_dl_runnable(rq)) in pick_next_task_dl()
1815 set_next_task_dl(rq, p, true); in pick_next_task_dl()
1819 static void put_prev_task_dl(struct rq *rq, struct task_struct *p) in put_prev_task_dl() argument
1821 update_curr_dl(rq); in put_prev_task_dl()
1823 update_dl_rq_load_avg(rq_clock_pelt(rq), rq, 1); in put_prev_task_dl()
1825 enqueue_pushable_dl_task(rq, p); in put_prev_task_dl()
1836 static void task_tick_dl(struct rq *rq, struct task_struct *p, int queued) in task_tick_dl() argument
1838 update_curr_dl(rq); in task_tick_dl()
1840 update_dl_rq_load_avg(rq_clock_pelt(rq), rq, 1); in task_tick_dl()
1846 if (hrtick_enabled(rq) && queued && p->dl.runtime > 0 && in task_tick_dl()
1847 is_leftmost(p, &rq->dl)) in task_tick_dl()
1848 start_hrtick_dl(rq, p); in task_tick_dl()
1864 static int pick_dl_task(struct rq *rq, struct task_struct *p, int cpu) in pick_dl_task() argument
1866 if (!task_running(rq, p) && in pick_dl_task()
1876 static struct task_struct *pick_earliest_pushable_dl_task(struct rq *rq, int cpu) in pick_earliest_pushable_dl_task() argument
1878 struct rb_node *next_node = rq->dl.pushable_dl_tasks_root.rb_leftmost; in pick_earliest_pushable_dl_task()
1881 if (!has_pushable_dl_tasks(rq)) in pick_earliest_pushable_dl_task()
1888 if (pick_dl_task(rq, p, cpu)) in pick_earliest_pushable_dl_task()
1988 static struct rq *find_lock_later_rq(struct task_struct *task, struct rq *rq) in find_lock_later_rq() argument
1990 struct rq *later_rq = NULL; in find_lock_later_rq()
1997 if ((cpu == -1) || (cpu == rq->cpu)) in find_lock_later_rq()
2015 if (double_lock_balance(rq, later_rq)) { in find_lock_later_rq()
2016 if (unlikely(task_rq(task) != rq || in find_lock_later_rq()
2018 task_running(rq, task) || in find_lock_later_rq()
2021 double_unlock_balance(rq, later_rq); in find_lock_later_rq()
2038 double_unlock_balance(rq, later_rq); in find_lock_later_rq()
2045 static struct task_struct *pick_next_pushable_dl_task(struct rq *rq) in pick_next_pushable_dl_task() argument
2049 if (!has_pushable_dl_tasks(rq)) in pick_next_pushable_dl_task()
2052 p = rb_entry(rq->dl.pushable_dl_tasks_root.rb_leftmost, in pick_next_pushable_dl_task()
2055 BUG_ON(rq->cpu != task_cpu(p)); in pick_next_pushable_dl_task()
2056 BUG_ON(task_current(rq, p)); in pick_next_pushable_dl_task()
2070 static int push_dl_task(struct rq *rq) in push_dl_task() argument
2073 struct rq *later_rq; in push_dl_task()
2076 if (!rq->dl.overloaded) in push_dl_task()
2079 next_task = pick_next_pushable_dl_task(rq); in push_dl_task()
2084 if (WARN_ON(next_task == rq->curr)) in push_dl_task()
2092 if (dl_task(rq->curr) && in push_dl_task()
2093 dl_time_before(next_task->dl.deadline, rq->curr->dl.deadline) && in push_dl_task()
2094 rq->curr->nr_cpus_allowed > 1) { in push_dl_task()
2095 resched_curr(rq); in push_dl_task()
2103 later_rq = find_lock_later_rq(next_task, rq); in push_dl_task()
2112 task = pick_next_pushable_dl_task(rq); in push_dl_task()
2130 deactivate_task(rq, next_task, 0); in push_dl_task()
2143 double_unlock_balance(rq, later_rq); in push_dl_task()
2151 static void push_dl_tasks(struct rq *rq) in push_dl_tasks() argument
2154 while (push_dl_task(rq)) in push_dl_tasks()
2158 static void pull_dl_task(struct rq *this_rq) in pull_dl_task()
2163 struct rq *src_rq; in pull_dl_task()
2243 static void task_woken_dl(struct rq *rq, struct task_struct *p) in task_woken_dl() argument
2245 if (!task_running(rq, p) && in task_woken_dl()
2246 !test_tsk_need_resched(rq->curr) && in task_woken_dl()
2248 dl_task(rq->curr) && in task_woken_dl()
2249 (rq->curr->nr_cpus_allowed < 2 || in task_woken_dl()
2250 !dl_entity_preempt(&p->dl, &rq->curr->dl))) { in task_woken_dl()
2251 push_dl_tasks(rq); in task_woken_dl()
2259 struct rq *rq; in set_cpus_allowed_dl() local
2263 rq = task_rq(p); in set_cpus_allowed_dl()
2264 src_rd = rq->rd; in set_cpus_allowed_dl()
2274 src_dl_b = dl_bw_of(cpu_of(rq)); in set_cpus_allowed_dl()
2289 static void rq_online_dl(struct rq *rq) in rq_online_dl() argument
2291 if (rq->dl.overloaded) in rq_online_dl()
2292 dl_set_overload(rq); in rq_online_dl()
2294 cpudl_set_freecpu(&rq->rd->cpudl, rq->cpu); in rq_online_dl()
2295 if (rq->dl.dl_nr_running > 0) in rq_online_dl()
2296 cpudl_set(&rq->rd->cpudl, rq->cpu, rq->dl.earliest_dl.curr); in rq_online_dl()
2300 static void rq_offline_dl(struct rq *rq) in rq_offline_dl() argument
2302 if (rq->dl.overloaded) in rq_offline_dl()
2303 dl_clear_overload(rq); in rq_offline_dl()
2305 cpudl_clear(&rq->rd->cpudl, rq->cpu); in rq_offline_dl()
2306 cpudl_clear_freecpu(&rq->rd->cpudl, rq->cpu); in rq_offline_dl()
2321 struct rq *rq; in dl_add_task_root_domain() local
2324 rq = task_rq_lock(p, &rf); in dl_add_task_root_domain()
2328 dl_b = &rq->rd->dl_bw; in dl_add_task_root_domain()
2331 __dl_add(dl_b, p->dl.dl_bw, cpumask_weight(rq->rd->span)); in dl_add_task_root_domain()
2336 task_rq_unlock(rq, p, &rf); in dl_add_task_root_domain()
2350 static void switched_from_dl(struct rq *rq, struct task_struct *p) in switched_from_dl() argument
2371 sub_running_bw(&p->dl, &rq->dl); in switched_from_dl()
2372 sub_rq_bw(&p->dl, &rq->dl); in switched_from_dl()
2388 if (!task_on_rq_queued(p) || rq->dl.dl_nr_running) in switched_from_dl()
2391 deadline_queue_pull_task(rq); in switched_from_dl()
2398 static void switched_to_dl(struct rq *rq, struct task_struct *p) in switched_to_dl() argument
2405 add_rq_bw(&p->dl, &rq->dl); in switched_to_dl()
2410 if (rq->curr != p) { in switched_to_dl()
2412 if (p->nr_cpus_allowed > 1 && rq->dl.overloaded) in switched_to_dl()
2413 deadline_queue_push_tasks(rq); in switched_to_dl()
2415 if (dl_task(rq->curr)) in switched_to_dl()
2416 check_preempt_curr_dl(rq, p, 0); in switched_to_dl()
2418 resched_curr(rq); in switched_to_dl()
2420 update_dl_rq_load_avg(rq_clock_pelt(rq), rq, 0); in switched_to_dl()
2428 static void prio_changed_dl(struct rq *rq, struct task_struct *p, in prio_changed_dl() argument
2431 if (task_on_rq_queued(p) || rq->curr == p) { in prio_changed_dl()
2439 if (!rq->dl.overloaded) in prio_changed_dl()
2440 deadline_queue_pull_task(rq); in prio_changed_dl()
2447 if (dl_time_before(rq->dl.earliest_dl.curr, p->dl.deadline)) in prio_changed_dl()
2448 resched_curr(rq); in prio_changed_dl()
2455 resched_curr(rq); in prio_changed_dl()