Lines Matching refs:se
345 #define for_each_sched_entity(se) \ argument
346 for (; se; se = se->parent)
448 is_same_group(struct sched_entity *se, struct sched_entity *pse) in is_same_group() argument
450 if (se->cfs_rq == pse->cfs_rq) in is_same_group()
451 return se->cfs_rq; in is_same_group()
456 static inline struct sched_entity *parent_entity(struct sched_entity *se) in parent_entity() argument
458 return se->parent; in parent_entity()
462 find_matching_se(struct sched_entity **se, struct sched_entity **pse) in find_matching_se() argument
474 se_depth = (*se)->depth; in find_matching_se()
479 *se = parent_entity(*se); in find_matching_se()
487 while (!is_same_group(*se, *pse)) { in find_matching_se()
488 *se = parent_entity(*se); in find_matching_se()
503 static int se_is_idle(struct sched_entity *se) in se_is_idle() argument
505 if (entity_is_task(se)) in se_is_idle()
506 return task_has_idle_policy(task_of(se)); in se_is_idle()
507 return cfs_rq_is_idle(group_cfs_rq(se)); in se_is_idle()
512 #define for_each_sched_entity(se) \ argument
513 for (; se; se = NULL)
531 static inline struct sched_entity *parent_entity(struct sched_entity *se) in parent_entity() argument
537 find_matching_se(struct sched_entity **se, struct sched_entity **pse) in find_matching_se() argument
551 static int se_is_idle(struct sched_entity *se) in se_is_idle() argument
607 struct sched_entity *se = __node_2_se(leftmost); in update_min_vruntime() local
610 vruntime = se->vruntime; in update_min_vruntime()
612 vruntime = min_vruntime(vruntime, se->vruntime); in update_min_vruntime()
628 static void __enqueue_entity(struct cfs_rq *cfs_rq, struct sched_entity *se) in __enqueue_entity() argument
630 rb_add_cached(&se->run_node, &cfs_rq->tasks_timeline, __entity_less); in __enqueue_entity()
633 static void __dequeue_entity(struct cfs_rq *cfs_rq, struct sched_entity *se) in __dequeue_entity() argument
635 rb_erase_cached(&se->run_node, &cfs_rq->tasks_timeline); in __dequeue_entity()
648 static struct sched_entity *__pick_next_entity(struct sched_entity *se) in __pick_next_entity() argument
650 struct rb_node *next = rb_next(&se->run_node); in __pick_next_entity()
694 static inline u64 calc_delta_fair(u64 delta, struct sched_entity *se) in calc_delta_fair() argument
696 if (unlikely(se->load.weight != NICE_0_LOAD)) in calc_delta_fair()
697 delta = __calc_delta(delta, NICE_0_LOAD, &se->load); in calc_delta_fair()
726 static u64 sched_slice(struct cfs_rq *cfs_rq, struct sched_entity *se) in sched_slice() argument
729 struct sched_entity *init_se = se; in sched_slice()
736 slice = __sched_period(nr_running + !se->on_rq); in sched_slice()
738 for_each_sched_entity(se) { in sched_slice()
743 qcfs_rq = cfs_rq_of(se); in sched_slice()
746 if (unlikely(!se->on_rq)) { in sched_slice()
749 update_load_add(&lw, se->load.weight); in sched_slice()
752 slice = __calc_delta(slice, se->load.weight, load); in sched_slice()
772 static u64 sched_vslice(struct cfs_rq *cfs_rq, struct sched_entity *se) in sched_vslice() argument
774 return calc_delta_fair(sched_slice(cfs_rq, se), se); in sched_vslice()
785 void init_entity_runnable_average(struct sched_entity *se) in init_entity_runnable_average() argument
787 struct sched_avg *sa = &se->avg; in init_entity_runnable_average()
797 if (entity_is_task(se)) in init_entity_runnable_average()
798 sa->load_avg = scale_load_down(se->load.weight); in init_entity_runnable_average()
831 struct sched_entity *se = &p->se; in post_init_entity_util_avg() local
832 struct cfs_rq *cfs_rq = cfs_rq_of(se); in post_init_entity_util_avg()
833 struct sched_avg *sa = &se->avg; in post_init_entity_util_avg()
848 se->avg.last_update_time = cfs_rq_clock_pelt(cfs_rq); in post_init_entity_util_avg()
854 sa->util_avg = cfs_rq->avg.util_avg * se->load.weight; in post_init_entity_util_avg()
868 void init_entity_runnable_average(struct sched_entity *se) in init_entity_runnable_average() argument
924 update_curr(cfs_rq_of(&rq->curr->se)); in update_curr_fair()
928 update_stats_wait_start_fair(struct cfs_rq *cfs_rq, struct sched_entity *se) in update_stats_wait_start_fair() argument
936 stats = __schedstats_from_se(se); in update_stats_wait_start_fair()
938 if (entity_is_task(se)) in update_stats_wait_start_fair()
939 p = task_of(se); in update_stats_wait_start_fair()
945 update_stats_wait_end_fair(struct cfs_rq *cfs_rq, struct sched_entity *se) in update_stats_wait_end_fair() argument
953 stats = __schedstats_from_se(se); in update_stats_wait_end_fair()
964 if (entity_is_task(se)) in update_stats_wait_end_fair()
965 p = task_of(se); in update_stats_wait_end_fair()
971 update_stats_enqueue_sleeper_fair(struct cfs_rq *cfs_rq, struct sched_entity *se) in update_stats_enqueue_sleeper_fair() argument
979 stats = __schedstats_from_se(se); in update_stats_enqueue_sleeper_fair()
981 if (entity_is_task(se)) in update_stats_enqueue_sleeper_fair()
982 tsk = task_of(se); in update_stats_enqueue_sleeper_fair()
991 update_stats_enqueue_fair(struct cfs_rq *cfs_rq, struct sched_entity *se, int flags) in update_stats_enqueue_fair() argument
1000 if (se != cfs_rq->curr) in update_stats_enqueue_fair()
1001 update_stats_wait_start_fair(cfs_rq, se); in update_stats_enqueue_fair()
1004 update_stats_enqueue_sleeper_fair(cfs_rq, se); in update_stats_enqueue_fair()
1008 update_stats_dequeue_fair(struct cfs_rq *cfs_rq, struct sched_entity *se, int flags) in update_stats_dequeue_fair() argument
1018 if (se != cfs_rq->curr) in update_stats_dequeue_fair()
1019 update_stats_wait_end_fair(cfs_rq, se); in update_stats_dequeue_fair()
1021 if ((flags & DEQUEUE_SLEEP) && entity_is_task(se)) { in update_stats_dequeue_fair()
1022 struct task_struct *tsk = task_of(se); in update_stats_dequeue_fair()
1040 update_stats_curr_start(struct cfs_rq *cfs_rq, struct sched_entity *se) in update_stats_curr_start() argument
1045 se->exec_start = rq_clock_task(rq_of(cfs_rq)); in update_stats_curr_start()
2431 now = p->se.exec_start; in numa_get_avg_runtime()
2432 runtime = p->se.sum_exec_runtime; in numa_get_avg_runtime()
2442 delta = p->se.avg.load_sum; in numa_get_avg_runtime()
2928 u64 runtime = p->se.sum_exec_runtime; in task_numa_work()
3063 if (unlikely(p->se.sum_exec_runtime != runtime)) { in task_numa_work()
3064 u64 diff = p->se.sum_exec_runtime - runtime; in task_numa_work()
3136 now = curr->se.sum_exec_runtime; in task_tick_numa()
3203 account_entity_enqueue(struct cfs_rq *cfs_rq, struct sched_entity *se) in account_entity_enqueue() argument
3205 update_load_add(&cfs_rq->load, se->load.weight); in account_entity_enqueue()
3207 if (entity_is_task(se)) { in account_entity_enqueue()
3210 account_numa_enqueue(rq, task_of(se)); in account_entity_enqueue()
3211 list_add(&se->group_node, &rq->cfs_tasks); in account_entity_enqueue()
3215 if (se_is_idle(se)) in account_entity_enqueue()
3220 account_entity_dequeue(struct cfs_rq *cfs_rq, struct sched_entity *se) in account_entity_dequeue() argument
3222 update_load_sub(&cfs_rq->load, se->load.weight); in account_entity_dequeue()
3224 if (entity_is_task(se)) { in account_entity_dequeue()
3225 account_numa_dequeue(rq_of(cfs_rq), task_of(se)); in account_entity_dequeue()
3226 list_del_init(&se->group_node); in account_entity_dequeue()
3230 if (se_is_idle(se)) in account_entity_dequeue()
3284 enqueue_load_avg(struct cfs_rq *cfs_rq, struct sched_entity *se) in enqueue_load_avg() argument
3286 cfs_rq->avg.load_avg += se->avg.load_avg; in enqueue_load_avg()
3287 cfs_rq->avg.load_sum += se_weight(se) * se->avg.load_sum; in enqueue_load_avg()
3291 dequeue_load_avg(struct cfs_rq *cfs_rq, struct sched_entity *se) in dequeue_load_avg() argument
3293 sub_positive(&cfs_rq->avg.load_avg, se->avg.load_avg); in dequeue_load_avg()
3294 sub_positive(&cfs_rq->avg.load_sum, se_weight(se) * se->avg.load_sum); in dequeue_load_avg()
3301 enqueue_load_avg(struct cfs_rq *cfs_rq, struct sched_entity *se) { } in enqueue_load_avg() argument
3303 dequeue_load_avg(struct cfs_rq *cfs_rq, struct sched_entity *se) { } in dequeue_load_avg() argument
3306 static void reweight_entity(struct cfs_rq *cfs_rq, struct sched_entity *se, in reweight_entity() argument
3309 if (se->on_rq) { in reweight_entity()
3311 if (cfs_rq->curr == se) in reweight_entity()
3313 update_load_sub(&cfs_rq->load, se->load.weight); in reweight_entity()
3315 dequeue_load_avg(cfs_rq, se); in reweight_entity()
3317 update_load_set(&se->load, weight); in reweight_entity()
3321 u32 divider = get_pelt_divider(&se->avg); in reweight_entity()
3323 se->avg.load_avg = div_u64(se_weight(se) * se->avg.load_sum, divider); in reweight_entity()
3327 enqueue_load_avg(cfs_rq, se); in reweight_entity()
3328 if (se->on_rq) in reweight_entity()
3329 update_load_add(&cfs_rq->load, se->load.weight); in reweight_entity()
3335 struct sched_entity *se = &p->se; in reweight_task() local
3336 struct cfs_rq *cfs_rq = cfs_rq_of(se); in reweight_task()
3337 struct load_weight *load = &se->load; in reweight_task()
3340 reweight_entity(cfs_rq, se, weight); in reweight_task()
3460 static void update_cfs_group(struct sched_entity *se) in update_cfs_group() argument
3462 struct cfs_rq *gcfs_rq = group_cfs_rq(se); in update_cfs_group()
3474 if (likely(se->load.weight == shares)) in update_cfs_group()
3480 reweight_entity(cfs_rq_of(se), se, shares); in update_cfs_group()
3484 static inline void update_cfs_group(struct sched_entity *se) in update_cfs_group() argument
3617 void set_task_rq_fair(struct sched_entity *se, in set_task_rq_fair() argument
3633 if (!(se->avg.last_update_time && prev)) in set_task_rq_fair()
3639 __update_load_avg_blocked_se(p_last_update_time, se); in set_task_rq_fair()
3640 se->avg.last_update_time = n_last_update_time; in set_task_rq_fair()
3711 update_tg_cfs_util(struct cfs_rq *cfs_rq, struct sched_entity *se, struct cfs_rq *gcfs_rq) in update_tg_cfs_util() argument
3713 long delta_sum, delta_avg = gcfs_rq->avg.util_avg - se->avg.util_avg; in update_tg_cfs_util()
3728 se->avg.util_avg = gcfs_rq->avg.util_avg; in update_tg_cfs_util()
3729 new_sum = se->avg.util_avg * divider; in update_tg_cfs_util()
3730 delta_sum = (long)new_sum - (long)se->avg.util_sum; in update_tg_cfs_util()
3731 se->avg.util_sum = new_sum; in update_tg_cfs_util()
3743 update_tg_cfs_runnable(struct cfs_rq *cfs_rq, struct sched_entity *se, struct cfs_rq *gcfs_rq) in update_tg_cfs_runnable() argument
3745 long delta_sum, delta_avg = gcfs_rq->avg.runnable_avg - se->avg.runnable_avg; in update_tg_cfs_runnable()
3759 se->avg.runnable_avg = gcfs_rq->avg.runnable_avg; in update_tg_cfs_runnable()
3760 new_sum = se->avg.runnable_avg * divider; in update_tg_cfs_runnable()
3761 delta_sum = (long)new_sum - (long)se->avg.runnable_sum; in update_tg_cfs_runnable()
3762 se->avg.runnable_sum = new_sum; in update_tg_cfs_runnable()
3773 update_tg_cfs_load(struct cfs_rq *cfs_rq, struct sched_entity *se, struct cfs_rq *gcfs_rq) in update_tg_cfs_load() argument
3797 runnable_sum += se->avg.load_sum; in update_tg_cfs_load()
3810 runnable_sum = min(se->avg.load_sum, load_sum); in update_tg_cfs_load()
3819 running_sum = se->avg.util_sum >> SCHED_CAPACITY_SHIFT; in update_tg_cfs_load()
3822 load_sum = se_weight(se) * runnable_sum; in update_tg_cfs_load()
3825 delta_avg = load_avg - se->avg.load_avg; in update_tg_cfs_load()
3829 delta_sum = load_sum - (s64)se_weight(se) * se->avg.load_sum; in update_tg_cfs_load()
3831 se->avg.load_sum = runnable_sum; in update_tg_cfs_load()
3832 se->avg.load_avg = load_avg; in update_tg_cfs_load()
3847 static inline int propagate_entity_load_avg(struct sched_entity *se) in propagate_entity_load_avg() argument
3851 if (entity_is_task(se)) in propagate_entity_load_avg()
3854 gcfs_rq = group_cfs_rq(se); in propagate_entity_load_avg()
3860 cfs_rq = cfs_rq_of(se); in propagate_entity_load_avg()
3864 update_tg_cfs_util(cfs_rq, se, gcfs_rq); in propagate_entity_load_avg()
3865 update_tg_cfs_runnable(cfs_rq, se, gcfs_rq); in propagate_entity_load_avg()
3866 update_tg_cfs_load(cfs_rq, se, gcfs_rq); in propagate_entity_load_avg()
3869 trace_pelt_se_tp(se); in propagate_entity_load_avg()
3878 static inline bool skip_blocked_update(struct sched_entity *se) in skip_blocked_update() argument
3880 struct cfs_rq *gcfs_rq = group_cfs_rq(se); in skip_blocked_update()
3886 if (se->avg.load_avg || se->avg.util_avg) in skip_blocked_update()
3908 static inline int propagate_entity_load_avg(struct sched_entity *se) in propagate_entity_load_avg() argument
3918 static inline void migrate_se_pelt_lag(struct sched_entity *se) in migrate_se_pelt_lag() argument
3925 if (load_avg_is_decayed(&se->avg)) in migrate_se_pelt_lag()
3928 cfs_rq = cfs_rq_of(se); in migrate_se_pelt_lag()
3994 __update_load_avg_blocked_se(now, se); in migrate_se_pelt_lag()
3997 static void migrate_se_pelt_lag(struct sched_entity *se) {} in migrate_se_pelt_lag() argument
4087 static void attach_entity_load_avg(struct cfs_rq *cfs_rq, struct sched_entity *se) in attach_entity_load_avg() argument
4102 se->avg.last_update_time = cfs_rq->avg.last_update_time; in attach_entity_load_avg()
4103 se->avg.period_contrib = cfs_rq->avg.period_contrib; in attach_entity_load_avg()
4111 se->avg.util_sum = se->avg.util_avg * divider; in attach_entity_load_avg()
4113 se->avg.runnable_sum = se->avg.runnable_avg * divider; in attach_entity_load_avg()
4115 se->avg.load_sum = se->avg.load_avg * divider; in attach_entity_load_avg()
4116 if (se_weight(se) < se->avg.load_sum) in attach_entity_load_avg()
4117 se->avg.load_sum = div_u64(se->avg.load_sum, se_weight(se)); in attach_entity_load_avg()
4119 se->avg.load_sum = 1; in attach_entity_load_avg()
4121 enqueue_load_avg(cfs_rq, se); in attach_entity_load_avg()
4122 cfs_rq->avg.util_avg += se->avg.util_avg; in attach_entity_load_avg()
4123 cfs_rq->avg.util_sum += se->avg.util_sum; in attach_entity_load_avg()
4124 cfs_rq->avg.runnable_avg += se->avg.runnable_avg; in attach_entity_load_avg()
4125 cfs_rq->avg.runnable_sum += se->avg.runnable_sum; in attach_entity_load_avg()
4127 add_tg_cfs_propagate(cfs_rq, se->avg.load_sum); in attach_entity_load_avg()
4142 static void detach_entity_load_avg(struct cfs_rq *cfs_rq, struct sched_entity *se) in detach_entity_load_avg() argument
4144 dequeue_load_avg(cfs_rq, se); in detach_entity_load_avg()
4145 sub_positive(&cfs_rq->avg.util_avg, se->avg.util_avg); in detach_entity_load_avg()
4146 sub_positive(&cfs_rq->avg.util_sum, se->avg.util_sum); in detach_entity_load_avg()
4151 sub_positive(&cfs_rq->avg.runnable_avg, se->avg.runnable_avg); in detach_entity_load_avg()
4152 sub_positive(&cfs_rq->avg.runnable_sum, se->avg.runnable_sum); in detach_entity_load_avg()
4157 add_tg_cfs_propagate(cfs_rq, -se->avg.load_sum); in detach_entity_load_avg()
4173 static inline void update_load_avg(struct cfs_rq *cfs_rq, struct sched_entity *se, int flags) in update_load_avg() argument
4182 if (se->avg.last_update_time && !(flags & SKIP_AGE_LOAD)) in update_load_avg()
4183 __update_load_avg_se(now, cfs_rq, se); in update_load_avg()
4186 decayed |= propagate_entity_load_avg(se); in update_load_avg()
4188 if (!se->avg.last_update_time && (flags & DO_ATTACH)) { in update_load_avg()
4197 attach_entity_load_avg(cfs_rq, se); in update_load_avg()
4205 detach_entity_load_avg(cfs_rq, se); in update_load_avg()
4219 static void sync_entity_load_avg(struct sched_entity *se) in sync_entity_load_avg() argument
4221 struct cfs_rq *cfs_rq = cfs_rq_of(se); in sync_entity_load_avg()
4225 __update_load_avg_blocked_se(last_update_time, se); in sync_entity_load_avg()
4232 static void remove_entity_load_avg(struct sched_entity *se) in remove_entity_load_avg() argument
4234 struct cfs_rq *cfs_rq = cfs_rq_of(se); in remove_entity_load_avg()
4243 sync_entity_load_avg(se); in remove_entity_load_avg()
4247 cfs_rq->removed.util_avg += se->avg.util_avg; in remove_entity_load_avg()
4248 cfs_rq->removed.load_avg += se->avg.load_avg; in remove_entity_load_avg()
4249 cfs_rq->removed.runnable_avg += se->avg.runnable_avg; in remove_entity_load_avg()
4267 return READ_ONCE(p->se.avg.util_avg); in task_util()
4272 struct util_est ue = READ_ONCE(p->se.avg.util_est); in _task_util_est()
4366 ue = p->se.avg.util_est; in util_est_update()
4426 WRITE_ONCE(p->se.avg.util_est, ue); in util_est_update()
4428 trace_sched_util_est_se_tp(&p->se); in util_est_update()
4596 static inline void update_load_avg(struct cfs_rq *cfs_rq, struct sched_entity *se, int not_used1) in update_load_avg() argument
4601 static inline void remove_entity_load_avg(struct sched_entity *se) {} in remove_entity_load_avg() argument
4604 attach_entity_load_avg(struct cfs_rq *cfs_rq, struct sched_entity *se) {} in attach_entity_load_avg() argument
4606 detach_entity_load_avg(struct cfs_rq *cfs_rq, struct sched_entity *se) {} in detach_entity_load_avg() argument
4626 static void check_spread(struct cfs_rq *cfs_rq, struct sched_entity *se) in check_spread() argument
4629 s64 d = se->vruntime - cfs_rq->min_vruntime; in check_spread()
4640 place_entity(struct cfs_rq *cfs_rq, struct sched_entity *se, int initial) in place_entity() argument
4651 vruntime += sched_vslice(cfs_rq, se); in place_entity()
4657 if (se_is_idle(se)) in place_entity()
4673 se->vruntime = max_vruntime(se->vruntime, vruntime); in place_entity()
4711 enqueue_entity(struct cfs_rq *cfs_rq, struct sched_entity *se, int flags) in enqueue_entity() argument
4714 bool curr = cfs_rq->curr == se; in enqueue_entity()
4721 se->vruntime += cfs_rq->min_vruntime; in enqueue_entity()
4732 se->vruntime += cfs_rq->min_vruntime; in enqueue_entity()
4743 update_load_avg(cfs_rq, se, UPDATE_TG | DO_ATTACH); in enqueue_entity()
4744 se_update_runnable(se); in enqueue_entity()
4745 update_cfs_group(se); in enqueue_entity()
4746 account_entity_enqueue(cfs_rq, se); in enqueue_entity()
4749 place_entity(cfs_rq, se, 0); in enqueue_entity()
4752 update_stats_enqueue_fair(cfs_rq, se, flags); in enqueue_entity()
4753 check_spread(cfs_rq, se); in enqueue_entity()
4755 __enqueue_entity(cfs_rq, se); in enqueue_entity()
4756 se->on_rq = 1; in enqueue_entity()
4765 static void __clear_buddies_last(struct sched_entity *se) in __clear_buddies_last() argument
4767 for_each_sched_entity(se) { in __clear_buddies_last()
4768 struct cfs_rq *cfs_rq = cfs_rq_of(se); in __clear_buddies_last()
4769 if (cfs_rq->last != se) in __clear_buddies_last()
4776 static void __clear_buddies_next(struct sched_entity *se) in __clear_buddies_next() argument
4778 for_each_sched_entity(se) { in __clear_buddies_next()
4779 struct cfs_rq *cfs_rq = cfs_rq_of(se); in __clear_buddies_next()
4780 if (cfs_rq->next != se) in __clear_buddies_next()
4787 static void __clear_buddies_skip(struct sched_entity *se) in __clear_buddies_skip() argument
4789 for_each_sched_entity(se) { in __clear_buddies_skip()
4790 struct cfs_rq *cfs_rq = cfs_rq_of(se); in __clear_buddies_skip()
4791 if (cfs_rq->skip != se) in __clear_buddies_skip()
4798 static void clear_buddies(struct cfs_rq *cfs_rq, struct sched_entity *se) in clear_buddies() argument
4800 if (cfs_rq->last == se) in clear_buddies()
4801 __clear_buddies_last(se); in clear_buddies()
4803 if (cfs_rq->next == se) in clear_buddies()
4804 __clear_buddies_next(se); in clear_buddies()
4806 if (cfs_rq->skip == se) in clear_buddies()
4807 __clear_buddies_skip(se); in clear_buddies()
4813 dequeue_entity(struct cfs_rq *cfs_rq, struct sched_entity *se, int flags) in dequeue_entity() argument
4817 if (entity_is_task(se) && task_on_rq_migrating(task_of(se))) in dequeue_entity()
4834 update_load_avg(cfs_rq, se, action); in dequeue_entity()
4835 se_update_runnable(se); in dequeue_entity()
4837 update_stats_dequeue_fair(cfs_rq, se, flags); in dequeue_entity()
4839 clear_buddies(cfs_rq, se); in dequeue_entity()
4841 if (se != cfs_rq->curr) in dequeue_entity()
4842 __dequeue_entity(cfs_rq, se); in dequeue_entity()
4843 se->on_rq = 0; in dequeue_entity()
4844 account_entity_dequeue(cfs_rq, se); in dequeue_entity()
4853 se->vruntime -= cfs_rq->min_vruntime; in dequeue_entity()
4858 update_cfs_group(se); in dequeue_entity()
4880 struct sched_entity *se; in check_preempt_tick() local
4903 se = __pick_first_entity(cfs_rq); in check_preempt_tick()
4904 delta = curr->vruntime - se->vruntime; in check_preempt_tick()
4914 set_next_entity(struct cfs_rq *cfs_rq, struct sched_entity *se) in set_next_entity() argument
4916 clear_buddies(cfs_rq, se); in set_next_entity()
4919 if (se->on_rq) { in set_next_entity()
4925 update_stats_wait_end_fair(cfs_rq, se); in set_next_entity()
4926 __dequeue_entity(cfs_rq, se); in set_next_entity()
4927 update_load_avg(cfs_rq, se, UPDATE_TG); in set_next_entity()
4930 update_stats_curr_start(cfs_rq, se); in set_next_entity()
4931 cfs_rq->curr = se; in set_next_entity()
4939 rq_of(cfs_rq)->cfs.load.weight >= 2*se->load.weight) { in set_next_entity()
4942 stats = __schedstats_from_se(se); in set_next_entity()
4945 se->sum_exec_runtime - se->prev_sum_exec_runtime)); in set_next_entity()
4948 se->prev_sum_exec_runtime = se->sum_exec_runtime; in set_next_entity()
4952 wakeup_preempt_entity(struct sched_entity *curr, struct sched_entity *se);
4965 struct sched_entity *se; in pick_next_entity() local
4974 se = left; /* ideally we run the leftmost entity */ in pick_next_entity()
4980 if (cfs_rq->skip && cfs_rq->skip == se) { in pick_next_entity()
4983 if (se == curr) { in pick_next_entity()
4986 second = __pick_next_entity(se); in pick_next_entity()
4992 se = second; in pick_next_entity()
4999 se = cfs_rq->next; in pick_next_entity()
5004 se = cfs_rq->last; in pick_next_entity()
5007 return se; in pick_next_entity()
5282 struct sched_entity *se; in throttle_cfs_rq() local
5306 se = cfs_rq->tg->se[cpu_of(rq_of(cfs_rq))]; in throttle_cfs_rq()
5315 for_each_sched_entity(se) { in throttle_cfs_rq()
5316 struct cfs_rq *qcfs_rq = cfs_rq_of(se); in throttle_cfs_rq()
5318 if (!se->on_rq) in throttle_cfs_rq()
5321 dequeue_entity(qcfs_rq, se, DEQUEUE_SLEEP); in throttle_cfs_rq()
5323 if (cfs_rq_is_idle(group_cfs_rq(se))) in throttle_cfs_rq()
5331 se = parent_entity(se); in throttle_cfs_rq()
5336 for_each_sched_entity(se) { in throttle_cfs_rq()
5337 struct cfs_rq *qcfs_rq = cfs_rq_of(se); in throttle_cfs_rq()
5339 if (!se->on_rq) in throttle_cfs_rq()
5342 update_load_avg(qcfs_rq, se, 0); in throttle_cfs_rq()
5343 se_update_runnable(se); in throttle_cfs_rq()
5345 if (cfs_rq_is_idle(group_cfs_rq(se))) in throttle_cfs_rq()
5369 struct sched_entity *se; in unthrottle_cfs_rq() local
5372 se = cfs_rq->tg->se[cpu_of(rq)]; in unthrottle_cfs_rq()
5393 for_each_sched_entity(se) { in unthrottle_cfs_rq()
5394 if (list_add_leaf_cfs_rq(cfs_rq_of(se))) in unthrottle_cfs_rq()
5402 for_each_sched_entity(se) { in unthrottle_cfs_rq()
5403 struct cfs_rq *qcfs_rq = cfs_rq_of(se); in unthrottle_cfs_rq()
5405 if (se->on_rq) in unthrottle_cfs_rq()
5407 enqueue_entity(qcfs_rq, se, ENQUEUE_WAKEUP); in unthrottle_cfs_rq()
5409 if (cfs_rq_is_idle(group_cfs_rq(se))) in unthrottle_cfs_rq()
5420 for_each_sched_entity(se) { in unthrottle_cfs_rq()
5421 struct cfs_rq *qcfs_rq = cfs_rq_of(se); in unthrottle_cfs_rq()
5423 update_load_avg(qcfs_rq, se, UPDATE_TG); in unthrottle_cfs_rq()
5424 se_update_runnable(se); in unthrottle_cfs_rq()
5426 if (cfs_rq_is_idle(group_cfs_rq(se))) in unthrottle_cfs_rq()
5944 struct sched_entity *se = &p->se; in hrtick_start_fair() local
5945 struct cfs_rq *cfs_rq = cfs_rq_of(se); in hrtick_start_fair()
5950 u64 slice = sched_slice(cfs_rq, se); in hrtick_start_fair()
5951 u64 ran = se->sum_exec_runtime - se->prev_sum_exec_runtime; in hrtick_start_fair()
5975 if (cfs_rq_of(&curr->se)->nr_running < sched_nr_latency) in hrtick_update()
6043 struct sched_entity *se = &p->se; in enqueue_task_fair() local
6063 for_each_sched_entity(se) { in enqueue_task_fair()
6064 if (se->on_rq) in enqueue_task_fair()
6066 cfs_rq = cfs_rq_of(se); in enqueue_task_fair()
6067 enqueue_entity(cfs_rq, se, flags); in enqueue_task_fair()
6082 for_each_sched_entity(se) { in enqueue_task_fair()
6083 cfs_rq = cfs_rq_of(se); in enqueue_task_fair()
6085 update_load_avg(cfs_rq, se, UPDATE_TG); in enqueue_task_fair()
6086 se_update_runnable(se); in enqueue_task_fair()
6087 update_cfs_group(se); in enqueue_task_fair()
6126 static void set_next_buddy(struct sched_entity *se);
6136 struct sched_entity *se = &p->se; in dequeue_task_fair() local
6143 for_each_sched_entity(se) { in dequeue_task_fair()
6144 cfs_rq = cfs_rq_of(se); in dequeue_task_fair()
6145 dequeue_entity(cfs_rq, se, flags); in dequeue_task_fair()
6160 se = parent_entity(se); in dequeue_task_fair()
6165 if (task_sleep && se && !throttled_hierarchy(cfs_rq)) in dequeue_task_fair()
6166 set_next_buddy(se); in dequeue_task_fair()
6172 for_each_sched_entity(se) { in dequeue_task_fair()
6173 cfs_rq = cfs_rq_of(se); in dequeue_task_fair()
6175 update_load_avg(cfs_rq, se, UPDATE_TG); in dequeue_task_fair()
6176 se_update_runnable(se); in dequeue_task_fair()
6177 update_cfs_group(se); in dequeue_task_fair()
6246 if (cpu_of(rq) != task_cpu(p) || !READ_ONCE(p->se.avg.last_update_time)) in cpu_load_without()
6269 if (cpu_of(rq) != task_cpu(p) || !READ_ONCE(p->se.avg.last_update_time)) in cpu_runnable_without()
6276 lsub_positive(&runnable, p->se.avg.runnable_avg); in cpu_runnable_without()
6511 sync_entity_load_avg(&p->se); in find_idlest_cpu()
6841 sync_entity_load_avg(&p->se); in select_idle_sibling()
7011 if (cpu != task_cpu(p) || !READ_ONCE(p->se.avg.last_update_time)) in cpu_util_without()
7209 sync_entity_load_avg(&p->se); in find_energy_efficient_cpu()
7419 struct sched_entity *se = &p->se; in migrate_task_rq_fair() local
7428 struct cfs_rq *cfs_rq = cfs_rq_of(se); in migrate_task_rq_fair()
7430 se->vruntime -= u64_u32_load(cfs_rq->min_vruntime); in migrate_task_rq_fair()
7434 remove_entity_load_avg(se); in migrate_task_rq_fair()
7446 migrate_se_pelt_lag(se); in migrate_task_rq_fair()
7450 se->avg.last_update_time = 0; in migrate_task_rq_fair()
7453 se->exec_start = 0; in migrate_task_rq_fair()
7460 remove_entity_load_avg(&p->se); in task_dead_fair()
7473 static unsigned long wakeup_gran(struct sched_entity *se) in wakeup_gran() argument
7490 return calc_delta_fair(gran, se); in wakeup_gran()
7508 wakeup_preempt_entity(struct sched_entity *curr, struct sched_entity *se) in wakeup_preempt_entity() argument
7510 s64 gran, vdiff = curr->vruntime - se->vruntime; in wakeup_preempt_entity()
7515 gran = wakeup_gran(se); in wakeup_preempt_entity()
7522 static void set_last_buddy(struct sched_entity *se) in set_last_buddy() argument
7524 for_each_sched_entity(se) { in set_last_buddy()
7525 if (SCHED_WARN_ON(!se->on_rq)) in set_last_buddy()
7527 if (se_is_idle(se)) in set_last_buddy()
7529 cfs_rq_of(se)->last = se; in set_last_buddy()
7533 static void set_next_buddy(struct sched_entity *se) in set_next_buddy() argument
7535 for_each_sched_entity(se) { in set_next_buddy()
7536 if (SCHED_WARN_ON(!se->on_rq)) in set_next_buddy()
7538 if (se_is_idle(se)) in set_next_buddy()
7540 cfs_rq_of(se)->next = se; in set_next_buddy()
7544 static void set_skip_buddy(struct sched_entity *se) in set_skip_buddy() argument
7546 for_each_sched_entity(se) in set_skip_buddy()
7547 cfs_rq_of(se)->skip = se; in set_skip_buddy()
7556 struct sched_entity *se = &curr->se, *pse = &p->se; in check_preempt_wakeup() local
7562 if (unlikely(se == pse)) in check_preempt_wakeup()
7604 find_matching_se(&se, &pse); in check_preempt_wakeup()
7607 cse_is_idle = se_is_idle(se); in check_preempt_wakeup()
7619 update_curr(cfs_rq_of(se)); in check_preempt_wakeup()
7620 if (wakeup_preempt_entity(se, pse) == 1) { in check_preempt_wakeup()
7643 if (unlikely(!se->on_rq || curr == rq->idle)) in check_preempt_wakeup()
7646 if (sched_feat(LAST_BUDDY) && scale && entity_is_task(se)) in check_preempt_wakeup()
7647 set_last_buddy(se); in check_preempt_wakeup()
7653 struct sched_entity *se; in pick_task_fair() local
7675 se = pick_next_entity(cfs_rq, curr); in pick_task_fair()
7676 cfs_rq = group_cfs_rq(se); in pick_task_fair()
7679 return task_of(se); in pick_task_fair()
7687 struct sched_entity *se; in pick_next_task_fair() local
7738 se = pick_next_entity(cfs_rq, curr); in pick_next_task_fair()
7739 cfs_rq = group_cfs_rq(se); in pick_next_task_fair()
7742 p = task_of(se); in pick_next_task_fair()
7750 struct sched_entity *pse = &prev->se; in pick_next_task_fair()
7752 while (!(cfs_rq = is_same_group(se, pse))) { in pick_next_task_fair()
7753 int se_depth = se->depth; in pick_next_task_fair()
7761 set_next_entity(cfs_rq_of(se), se); in pick_next_task_fair()
7762 se = parent_entity(se); in pick_next_task_fair()
7767 set_next_entity(cfs_rq, se); in pick_next_task_fair()
7777 se = pick_next_entity(cfs_rq, NULL); in pick_next_task_fair()
7778 set_next_entity(cfs_rq, se); in pick_next_task_fair()
7779 cfs_rq = group_cfs_rq(se); in pick_next_task_fair()
7782 p = task_of(se); in pick_next_task_fair()
7791 list_move(&p->se.group_node, &rq->cfs_tasks); in pick_next_task_fair()
7837 struct sched_entity *se = &prev->se; in put_prev_task_fair() local
7840 for_each_sched_entity(se) { in put_prev_task_fair()
7841 cfs_rq = cfs_rq_of(se); in put_prev_task_fair()
7842 put_prev_entity(cfs_rq, se); in put_prev_task_fair()
7855 struct sched_entity *se = &curr->se; in yield_task_fair() local
7863 clear_buddies(cfs_rq, se); in yield_task_fair()
7879 set_skip_buddy(se); in yield_task_fair()
7884 struct sched_entity *se = &p->se; in yield_to_task_fair() local
7887 if (!se->on_rq || throttled_hierarchy(cfs_rq_of(se))) in yield_to_task_fair()
7891 set_next_buddy(se); in yield_to_task_fair()
8122 (&p->se == cfs_rq_of(&p->se)->next || in task_hot()
8123 &p->se == cfs_rq_of(&p->se)->last)) in task_hot()
8139 delta = rq_clock_task(env->src_rq) - p->se.exec_start; in task_hot()
8320 &env->src_rq->cfs_tasks, se.group_node) { in detach_one_task()
8389 p = list_last_entry(tasks, struct task_struct, se.group_node); in detach_tasks()
8444 list_add(&p->se.group_node, &env->tasks); in detach_tasks()
8467 list_move(&p->se.group_node, tasks); in detach_tasks()
8520 p = list_first_entry(tasks, struct task_struct, se.group_node); in attach_tasks()
8521 list_del_init(&p->se.group_node); in attach_tasks()
8616 struct sched_entity *se; in __update_blocked_fair() local
8629 se = cfs_rq->tg->se[cpu]; in __update_blocked_fair()
8630 if (se && !skip_blocked_update(se)) in __update_blocked_fair()
8631 update_load_avg(cfs_rq_of(se), se, UPDATE_TG); in __update_blocked_fair()
8656 struct sched_entity *se = cfs_rq->tg->se[cpu_of(rq)]; in update_cfs_rq_h_load() local
8664 for_each_sched_entity(se) { in update_cfs_rq_h_load()
8665 cfs_rq = cfs_rq_of(se); in update_cfs_rq_h_load()
8666 WRITE_ONCE(cfs_rq->h_load_next, se); in update_cfs_rq_h_load()
8671 if (!se) { in update_cfs_rq_h_load()
8676 while ((se = READ_ONCE(cfs_rq->h_load_next)) != NULL) { in update_cfs_rq_h_load()
8678 load = div64_ul(load * se->avg.load_avg, in update_cfs_rq_h_load()
8680 cfs_rq = group_cfs_rq(se); in update_cfs_rq_h_load()
8691 return div64_ul(p->se.avg.load_avg * cfs_rq->h_load, in task_h_load()
8709 return p->se.avg.load_avg; in task_h_load()
9388 if (cpu != task_cpu(p) || !READ_ONCE(p->se.avg.last_update_time)) in task_running_on_cpu()
11619 __entity_slice_used(struct sched_entity *se, int min_nr_tasks) in __entity_slice_used() argument
11621 u64 slice = sched_slice(cfs_rq_of(se), se); in __entity_slice_used()
11622 u64 rtime = se->sum_exec_runtime - se->prev_sum_exec_runtime; in __entity_slice_used()
11648 __entity_slice_used(&curr->se, MIN_NR_TASKS_DURING_FORCEIDLE)) in task_tick_core()
11655 static void se_fi_update(struct sched_entity *se, unsigned int fi_seq, bool forceidle) in se_fi_update() argument
11657 for_each_sched_entity(se) { in se_fi_update()
11658 struct cfs_rq *cfs_rq = cfs_rq_of(se); in se_fi_update()
11672 struct sched_entity *se = &p->se; in task_vruntime_update() local
11677 se_fi_update(se, rq->core->core_forceidle_seq, in_fi); in task_vruntime_update()
11683 struct sched_entity *sea = &a->se; in cfs_prio_less()
11684 struct sched_entity *seb = &b->se; in cfs_prio_less()
11741 struct sched_entity *se = &curr->se; in task_tick_fair() local
11743 for_each_sched_entity(se) { in task_tick_fair()
11744 cfs_rq = cfs_rq_of(se); in task_tick_fair()
11745 entity_tick(cfs_rq, se, queued); in task_tick_fair()
11765 struct sched_entity *se = &p->se, *curr; in task_fork_fair() local
11776 se->vruntime = curr->vruntime; in task_fork_fair()
11778 place_entity(cfs_rq, se, 1); in task_fork_fair()
11780 if (sysctl_sched_child_runs_first && curr && entity_before(curr, se)) { in task_fork_fair()
11785 swap(curr->vruntime, se->vruntime); in task_fork_fair()
11789 se->vruntime -= cfs_rq->min_vruntime; in task_fork_fair()
11820 struct sched_entity *se = &p->se; in vruntime_normalized() local
11839 if (!se->sum_exec_runtime || in vruntime_normalized()
11851 static void propagate_entity_cfs_rq(struct sched_entity *se) in propagate_entity_cfs_rq() argument
11853 struct cfs_rq *cfs_rq = cfs_rq_of(se); in propagate_entity_cfs_rq()
11862 se = se->parent; in propagate_entity_cfs_rq()
11864 for_each_sched_entity(se) { in propagate_entity_cfs_rq()
11865 cfs_rq = cfs_rq_of(se); in propagate_entity_cfs_rq()
11867 update_load_avg(cfs_rq, se, UPDATE_TG); in propagate_entity_cfs_rq()
11877 static void propagate_entity_cfs_rq(struct sched_entity *se) { } in propagate_entity_cfs_rq() argument
11880 static void detach_entity_cfs_rq(struct sched_entity *se) in detach_entity_cfs_rq() argument
11882 struct cfs_rq *cfs_rq = cfs_rq_of(se); in detach_entity_cfs_rq()
11891 if (!se->avg.last_update_time) in detach_entity_cfs_rq()
11896 update_load_avg(cfs_rq, se, 0); in detach_entity_cfs_rq()
11897 detach_entity_load_avg(cfs_rq, se); in detach_entity_cfs_rq()
11899 propagate_entity_cfs_rq(se); in detach_entity_cfs_rq()
11902 static void attach_entity_cfs_rq(struct sched_entity *se) in attach_entity_cfs_rq() argument
11904 struct cfs_rq *cfs_rq = cfs_rq_of(se); in attach_entity_cfs_rq()
11907 update_load_avg(cfs_rq, se, sched_feat(ATTACH_AGE_LOAD) ? 0 : SKIP_AGE_LOAD); in attach_entity_cfs_rq()
11908 attach_entity_load_avg(cfs_rq, se); in attach_entity_cfs_rq()
11910 propagate_entity_cfs_rq(se); in attach_entity_cfs_rq()
11915 struct sched_entity *se = &p->se; in detach_task_cfs_rq() local
11916 struct cfs_rq *cfs_rq = cfs_rq_of(se); in detach_task_cfs_rq()
11923 place_entity(cfs_rq, se, 0); in detach_task_cfs_rq()
11924 se->vruntime -= cfs_rq->min_vruntime; in detach_task_cfs_rq()
11927 detach_entity_cfs_rq(se); in detach_task_cfs_rq()
11932 struct sched_entity *se = &p->se; in attach_task_cfs_rq() local
11933 struct cfs_rq *cfs_rq = cfs_rq_of(se); in attach_task_cfs_rq()
11935 attach_entity_cfs_rq(se); in attach_task_cfs_rq()
11938 se->vruntime += cfs_rq->min_vruntime; in attach_task_cfs_rq()
11970 struct sched_entity *se = &p->se; in set_next_task_fair() local
11978 list_move(&se->group_node, &rq->cfs_tasks); in set_next_task_fair()
11982 for_each_sched_entity(se) { in set_next_task_fair()
11983 struct cfs_rq *cfs_rq = cfs_rq_of(se); in set_next_task_fair()
11985 set_next_entity(cfs_rq, se); in set_next_task_fair()
12014 p->se.avg.last_update_time = 0; in task_change_group_fair()
12027 if (tg->se) in free_fair_sched_group()
12028 kfree(tg->se[i]); in free_fair_sched_group()
12032 kfree(tg->se); in free_fair_sched_group()
12037 struct sched_entity *se; in alloc_fair_sched_group() local
12044 tg->se = kcalloc(nr_cpu_ids, sizeof(se), GFP_KERNEL); in alloc_fair_sched_group()
12045 if (!tg->se) in alloc_fair_sched_group()
12058 se = kzalloc_node(sizeof(struct sched_entity_stats), in alloc_fair_sched_group()
12060 if (!se) in alloc_fair_sched_group()
12064 init_tg_cfs_entry(tg, cfs_rq, se, i, parent->se[i]); in alloc_fair_sched_group()
12065 init_entity_runnable_average(se); in alloc_fair_sched_group()
12078 struct sched_entity *se; in online_fair_sched_group() local
12085 se = tg->se[i]; in online_fair_sched_group()
12088 attach_entity_cfs_rq(se); in online_fair_sched_group()
12103 if (tg->se[cpu]) in unregister_fair_sched_group()
12104 remove_entity_load_avg(tg->se[cpu]); in unregister_fair_sched_group()
12122 struct sched_entity *se, int cpu, in init_tg_cfs_entry() argument
12132 tg->se[cpu] = se; in init_tg_cfs_entry()
12135 if (!se) in init_tg_cfs_entry()
12139 se->cfs_rq = &rq->cfs; in init_tg_cfs_entry()
12140 se->depth = 0; in init_tg_cfs_entry()
12142 se->cfs_rq = parent->my_q; in init_tg_cfs_entry()
12143 se->depth = parent->depth + 1; in init_tg_cfs_entry()
12146 se->my_q = cfs_rq; in init_tg_cfs_entry()
12148 update_load_set(&se->load, NICE_0_LOAD); in init_tg_cfs_entry()
12149 se->parent = parent; in init_tg_cfs_entry()
12163 if (!tg->se[0]) in __sched_group_set_shares()
12174 struct sched_entity *se = tg->se[i]; in __sched_group_set_shares() local
12180 for_each_sched_entity(se) { in __sched_group_set_shares()
12181 update_load_avg(cfs_rq_of(se), se, UPDATE_TG); in __sched_group_set_shares()
12182 update_cfs_group(se); in __sched_group_set_shares()
12225 struct sched_entity *se = tg->se[i]; in sched_group_set_idle() local
12237 if (se->on_rq) { in sched_group_set_idle()
12238 parent_cfs_rq = cfs_rq_of(se); in sched_group_set_idle()
12250 for_each_sched_entity(se) { in sched_group_set_idle()
12251 struct cfs_rq *cfs_rq = cfs_rq_of(se); in sched_group_set_idle()
12253 if (!se->on_rq) in sched_group_set_idle()
12295 struct sched_entity *se = &task->se; in get_rr_interval_fair() local
12303 rr_interval = NS_TO_JIFFIES(sched_slice(cfs_rq_of(se), se)); in get_rr_interval_fair()