Lines Matching full:se

311 static inline u64 calc_delta_fair(u64 delta, struct sched_entity *se)  in calc_delta_fair()  argument
313 if (unlikely(se->load.weight != NICE_0_LOAD)) in calc_delta_fair()
314 delta = __calc_delta(delta, NICE_0_LOAD, &se->load); in calc_delta_fair()
328 #define for_each_sched_entity(se) \ argument
329 for (; se; se = se->parent)
431 is_same_group(struct sched_entity *se, struct sched_entity *pse) in is_same_group() argument
433 if (se->cfs_rq == pse->cfs_rq) in is_same_group()
434 return se->cfs_rq; in is_same_group()
439 static inline struct sched_entity *parent_entity(const struct sched_entity *se) in parent_entity() argument
441 return se->parent; in parent_entity()
445 find_matching_se(struct sched_entity **se, struct sched_entity **pse) in find_matching_se() argument
457 se_depth = (*se)->depth; in find_matching_se()
462 *se = parent_entity(*se); in find_matching_se()
470 while (!is_same_group(*se, *pse)) { in find_matching_se()
471 *se = parent_entity(*se); in find_matching_se()
486 static int se_is_idle(struct sched_entity *se) in se_is_idle() argument
488 if (entity_is_task(se)) in se_is_idle()
489 return task_has_idle_policy(task_of(se)); in se_is_idle()
490 return cfs_rq_is_idle(group_cfs_rq(se)); in se_is_idle()
495 #define for_each_sched_entity(se) \ argument
496 for (; se; se = NULL)
514 static inline struct sched_entity *parent_entity(struct sched_entity *se) in parent_entity() argument
520 find_matching_se(struct sched_entity **se, struct sched_entity **pse) in find_matching_se() argument
534 static int se_is_idle(struct sched_entity *se) in se_is_idle() argument
536 return task_has_idle_policy(task_of(se)); in se_is_idle()
572 static inline s64 entity_key(struct cfs_rq *cfs_rq, struct sched_entity *se) in entity_key() argument
574 return (s64)(se->vruntime - cfs_rq->min_vruntime); in entity_key()
599 * se->vruntime):
639 avg_vruntime_add(struct cfs_rq *cfs_rq, struct sched_entity *se) in avg_vruntime_add() argument
641 unsigned long weight = scale_load_down(se->load.weight); in avg_vruntime_add()
642 s64 key = entity_key(cfs_rq, se); in avg_vruntime_add()
649 avg_vruntime_sub(struct cfs_rq *cfs_rq, struct sched_entity *se) in avg_vruntime_sub() argument
651 unsigned long weight = scale_load_down(se->load.weight); in avg_vruntime_sub()
652 s64 key = entity_key(cfs_rq, se); in avg_vruntime_sub()
710 static s64 entity_lag(u64 avruntime, struct sched_entity *se) in entity_lag() argument
714 vlag = avruntime - se->vruntime; in entity_lag()
715 limit = calc_delta_fair(max_t(u64, 2*se->slice, TICK_NSEC), se); in entity_lag()
720 static void update_entity_lag(struct cfs_rq *cfs_rq, struct sched_entity *se) in update_entity_lag() argument
722 SCHED_WARN_ON(!se->on_rq); in update_entity_lag()
724 se->vlag = entity_lag(avg_vruntime(cfs_rq), se); in update_entity_lag()
741 * Note: using 'avg_vruntime() > se->vruntime' is inacurate due
744 int entity_eligible(struct cfs_rq *cfs_rq, struct sched_entity *se) in entity_eligible() argument
757 return avg >= entity_key(cfs_rq, se) * load; in entity_eligible()
776 struct sched_entity *se = __pick_first_entity(cfs_rq); in update_min_vruntime() local
788 if (se) { in update_min_vruntime()
790 vruntime = se->vruntime; in update_min_vruntime()
792 vruntime = min_vruntime(vruntime, se->vruntime); in update_min_vruntime()
807 static inline void __update_min_deadline(struct sched_entity *se, struct rb_node *node) in __update_min_deadline() argument
811 if (deadline_gt(min_deadline, se, rse)) in __update_min_deadline()
812 se->min_deadline = rse->min_deadline; in __update_min_deadline()
817 * se->min_deadline = min(se->deadline, left->min_deadline, right->min_deadline)
819 static inline bool min_deadline_update(struct sched_entity *se, bool exit) in min_deadline_update() argument
821 u64 old_min_deadline = se->min_deadline; in min_deadline_update()
822 struct rb_node *node = &se->run_node; in min_deadline_update()
824 se->min_deadline = se->deadline; in min_deadline_update()
825 __update_min_deadline(se, node->rb_right); in min_deadline_update()
826 __update_min_deadline(se, node->rb_left); in min_deadline_update()
828 return se->min_deadline == old_min_deadline; in min_deadline_update()
837 static void __enqueue_entity(struct cfs_rq *cfs_rq, struct sched_entity *se) in __enqueue_entity() argument
839 avg_vruntime_add(cfs_rq, se); in __enqueue_entity()
840 se->min_deadline = se->deadline; in __enqueue_entity()
841 rb_add_augmented_cached(&se->run_node, &cfs_rq->tasks_timeline, in __enqueue_entity()
845 static void __dequeue_entity(struct cfs_rq *cfs_rq, struct sched_entity *se) in __dequeue_entity() argument
847 rb_erase_augmented_cached(&se->run_node, &cfs_rq->tasks_timeline, in __dequeue_entity()
849 avg_vruntime_sub(cfs_rq, se); in __dequeue_entity()
877 * se->min_deadline = min(se->deadline, se->{left,right}->min_deadline)
900 struct sched_entity *se = __node_2_se(node); in __pick_eevdf() local
905 if (!entity_eligible(cfs_rq, se)) { in __pick_eevdf()
913 if (!best || deadline_gt(deadline, best, se)) in __pick_eevdf()
914 best = se; in __pick_eevdf()
917 * Every se in a left branch is eligible, keep track of the in __pick_eevdf()
931 if (left->min_deadline == se->min_deadline) in __pick_eevdf()
936 if (se->deadline == se->min_deadline) in __pick_eevdf()
956 struct sched_entity *se = __node_2_se(node); in __pick_eevdf() local
959 if (se->deadline == se->min_deadline) in __pick_eevdf()
960 return se; in __pick_eevdf()
964 __node_2_se(node->rb_left)->min_deadline == se->min_deadline) { in __pick_eevdf()
977 struct sched_entity *se = __pick_eevdf(cfs_rq); in pick_eevdf() local
979 if (!se) { in pick_eevdf()
987 return se; in pick_eevdf()
1019 static void clear_buddies(struct cfs_rq *cfs_rq, struct sched_entity *se);
1025 static void update_deadline(struct cfs_rq *cfs_rq, struct sched_entity *se) in update_deadline() argument
1027 if ((s64)(se->vruntime - se->deadline) < 0) in update_deadline()
1035 se->slice = sysctl_sched_base_slice; in update_deadline()
1040 se->deadline = se->vruntime + calc_delta_fair(se->slice, se); in update_deadline()
1047 clear_buddies(cfs_rq, se); in update_deadline()
1059 void init_entity_runnable_average(struct sched_entity *se) in init_entity_runnable_average() argument
1061 struct sched_avg *sa = &se->avg; in init_entity_runnable_average()
1071 if (entity_is_task(se)) in init_entity_runnable_average()
1072 sa->load_avg = scale_load_down(se->load.weight); in init_entity_runnable_average()
1081 * util_avg = cfs_rq->util_avg / (cfs_rq->load_avg + 1) * se.load.weight
1105 struct sched_entity *se = &p->se; in post_init_entity_util_avg() local
1106 struct cfs_rq *cfs_rq = cfs_rq_of(se); in post_init_entity_util_avg()
1107 struct sched_avg *sa = &se->avg; in post_init_entity_util_avg()
1116 attach_entity_load_avg(cfs_rq, se); in post_init_entity_util_avg()
1122 se->avg.last_update_time = cfs_rq_clock_pelt(cfs_rq); in post_init_entity_util_avg()
1128 sa->util_avg = cfs_rq->avg.util_avg * se->load.weight; in post_init_entity_util_avg()
1142 void init_entity_runnable_average(struct sched_entity *se) in init_entity_runnable_average() argument
1191 delta_exec = update_curr_se(rq, &curr->se); in update_curr_common()
1225 update_curr(cfs_rq_of(&rq->curr->se)); in update_curr_fair()
1229 update_stats_wait_start_fair(struct cfs_rq *cfs_rq, struct sched_entity *se) in update_stats_wait_start_fair() argument
1237 stats = __schedstats_from_se(se); in update_stats_wait_start_fair()
1239 if (entity_is_task(se)) in update_stats_wait_start_fair()
1240 p = task_of(se); in update_stats_wait_start_fair()
1246 update_stats_wait_end_fair(struct cfs_rq *cfs_rq, struct sched_entity *se) in update_stats_wait_end_fair() argument
1254 stats = __schedstats_from_se(se); in update_stats_wait_end_fair()
1257 * When the sched_schedstat changes from 0 to 1, some sched se in update_stats_wait_end_fair()
1258 * maybe already in the runqueue, the se->statistics.wait_start in update_stats_wait_end_fair()
1265 if (entity_is_task(se)) in update_stats_wait_end_fair()
1266 p = task_of(se); in update_stats_wait_end_fair()
1272 update_stats_enqueue_sleeper_fair(struct cfs_rq *cfs_rq, struct sched_entity *se) in update_stats_enqueue_sleeper_fair() argument
1280 stats = __schedstats_from_se(se); in update_stats_enqueue_sleeper_fair()
1282 if (entity_is_task(se)) in update_stats_enqueue_sleeper_fair()
1283 tsk = task_of(se); in update_stats_enqueue_sleeper_fair()
1292 update_stats_enqueue_fair(struct cfs_rq *cfs_rq, struct sched_entity *se, int flags) in update_stats_enqueue_fair() argument
1301 if (se != cfs_rq->curr) in update_stats_enqueue_fair()
1302 update_stats_wait_start_fair(cfs_rq, se); in update_stats_enqueue_fair()
1305 update_stats_enqueue_sleeper_fair(cfs_rq, se); in update_stats_enqueue_fair()
1309 update_stats_dequeue_fair(struct cfs_rq *cfs_rq, struct sched_entity *se, int flags) in update_stats_dequeue_fair() argument
1319 if (se != cfs_rq->curr) in update_stats_dequeue_fair()
1320 update_stats_wait_end_fair(cfs_rq, se); in update_stats_dequeue_fair()
1322 if ((flags & DEQUEUE_SLEEP) && entity_is_task(se)) { in update_stats_dequeue_fair()
1323 struct task_struct *tsk = task_of(se); in update_stats_dequeue_fair()
1341 update_stats_curr_start(struct cfs_rq *cfs_rq, struct sched_entity *se) in update_stats_curr_start() argument
1346 se->exec_start = rq_clock_task(rq_of(cfs_rq)); in update_stats_curr_start()
2729 now = p->se.exec_start; in numa_get_avg_runtime()
2730 runtime = p->se.sum_exec_runtime; in numa_get_avg_runtime()
2740 delta = p->se.avg.load_sum; in numa_get_avg_runtime()
3265 u64 runtime = p->se.sum_exec_runtime; in task_numa_work()
3502 if (unlikely(p->se.sum_exec_runtime != runtime)) { in task_numa_work()
3503 u64 diff = p->se.sum_exec_runtime - runtime; in task_numa_work()
3575 now = curr->se.sum_exec_runtime; in task_tick_numa()
3642 account_entity_enqueue(struct cfs_rq *cfs_rq, struct sched_entity *se) in account_entity_enqueue() argument
3644 update_load_add(&cfs_rq->load, se->load.weight); in account_entity_enqueue()
3646 if (entity_is_task(se)) { in account_entity_enqueue()
3649 account_numa_enqueue(rq, task_of(se)); in account_entity_enqueue()
3650 list_add(&se->group_node, &rq->cfs_tasks); in account_entity_enqueue()
3654 if (se_is_idle(se)) in account_entity_enqueue()
3659 account_entity_dequeue(struct cfs_rq *cfs_rq, struct sched_entity *se) in account_entity_dequeue() argument
3661 update_load_sub(&cfs_rq->load, se->load.weight); in account_entity_dequeue()
3663 if (entity_is_task(se)) { in account_entity_dequeue()
3664 account_numa_dequeue(rq_of(cfs_rq), task_of(se)); in account_entity_dequeue()
3665 list_del_init(&se->group_node); in account_entity_dequeue()
3669 if (se_is_idle(se)) in account_entity_dequeue()
3723 enqueue_load_avg(struct cfs_rq *cfs_rq, struct sched_entity *se) in enqueue_load_avg() argument
3725 cfs_rq->avg.load_avg += se->avg.load_avg; in enqueue_load_avg()
3726 cfs_rq->avg.load_sum += se_weight(se) * se->avg.load_sum; in enqueue_load_avg()
3730 dequeue_load_avg(struct cfs_rq *cfs_rq, struct sched_entity *se) in dequeue_load_avg() argument
3732 sub_positive(&cfs_rq->avg.load_avg, se->avg.load_avg); in dequeue_load_avg()
3733 sub_positive(&cfs_rq->avg.load_sum, se_weight(se) * se->avg.load_sum); in dequeue_load_avg()
3740 enqueue_load_avg(struct cfs_rq *cfs_rq, struct sched_entity *se) { } in enqueue_load_avg() argument
3742 dequeue_load_avg(struct cfs_rq *cfs_rq, struct sched_entity *se) { } in dequeue_load_avg() argument
3745 static void reweight_eevdf(struct sched_entity *se, u64 avruntime, in reweight_eevdf() argument
3748 unsigned long old_weight = se->load.weight; in reweight_eevdf()
3828 if (avruntime != se->vruntime) { in reweight_eevdf()
3829 vlag = entity_lag(avruntime, se); in reweight_eevdf()
3831 se->vruntime = avruntime - vlag; in reweight_eevdf()
3846 vslice = (s64)(se->deadline - avruntime); in reweight_eevdf()
3848 se->deadline = avruntime + vslice; in reweight_eevdf()
3851 static void reweight_entity(struct cfs_rq *cfs_rq, struct sched_entity *se, in reweight_entity() argument
3854 bool curr = cfs_rq->curr == se; in reweight_entity()
3857 if (se->on_rq) { in reweight_entity()
3862 __dequeue_entity(cfs_rq, se); in reweight_entity()
3863 update_load_sub(&cfs_rq->load, se->load.weight); in reweight_entity()
3865 dequeue_load_avg(cfs_rq, se); in reweight_entity()
3867 if (se->on_rq) { in reweight_entity()
3868 reweight_eevdf(se, avruntime, weight); in reweight_entity()
3871 * Because we keep se->vlag = V - v_i, while: lag_i = w_i*(V - v_i), in reweight_entity()
3872 * we need to scale se->vlag when w_i changes. in reweight_entity()
3874 se->vlag = div_s64(se->vlag * se->load.weight, weight); in reweight_entity()
3877 update_load_set(&se->load, weight); in reweight_entity()
3881 u32 divider = get_pelt_divider(&se->avg); in reweight_entity()
3883 se->avg.load_avg = div_u64(se_weight(se) * se->avg.load_sum, divider); in reweight_entity()
3887 enqueue_load_avg(cfs_rq, se); in reweight_entity()
3888 if (se->on_rq) { in reweight_entity()
3889 update_load_add(&cfs_rq->load, se->load.weight); in reweight_entity()
3891 __enqueue_entity(cfs_rq, se); in reweight_entity()
3906 struct sched_entity *se = &p->se; in reweight_task() local
3907 struct cfs_rq *cfs_rq = cfs_rq_of(se); in reweight_task()
3908 struct load_weight *load = &se->load; in reweight_task()
3910 reweight_entity(cfs_rq, se, lw->weight); in reweight_task()
4030 static void update_cfs_group(struct sched_entity *se) in update_cfs_group() argument
4032 struct cfs_rq *gcfs_rq = group_cfs_rq(se); in update_cfs_group()
4046 if (unlikely(se->load.weight != shares)) in update_cfs_group()
4047 reweight_entity(cfs_rq_of(se), se, shares); in update_cfs_group()
4051 static inline void update_cfs_group(struct sched_entity *se) in update_cfs_group() argument
4184 void set_task_rq_fair(struct sched_entity *se, in set_task_rq_fair() argument
4200 if (!(se->avg.last_update_time && prev)) in set_task_rq_fair()
4206 __update_load_avg_blocked_se(p_last_update_time, se); in set_task_rq_fair()
4207 se->avg.last_update_time = n_last_update_time; in set_task_rq_fair()
4278 update_tg_cfs_util(struct cfs_rq *cfs_rq, struct sched_entity *se, struct cfs_rq *gcfs_rq) in update_tg_cfs_util() argument
4280 long delta_sum, delta_avg = gcfs_rq->avg.util_avg - se->avg.util_avg; in update_tg_cfs_util()
4288 * cfs_rq->avg.period_contrib can be used for both cfs_rq and se. in update_tg_cfs_util()
4295 se->avg.util_avg = gcfs_rq->avg.util_avg; in update_tg_cfs_util()
4296 new_sum = se->avg.util_avg * divider; in update_tg_cfs_util()
4297 delta_sum = (long)new_sum - (long)se->avg.util_sum; in update_tg_cfs_util()
4298 se->avg.util_sum = new_sum; in update_tg_cfs_util()
4310 update_tg_cfs_runnable(struct cfs_rq *cfs_rq, struct sched_entity *se, struct cfs_rq *gcfs_rq) in update_tg_cfs_runnable() argument
4312 long delta_sum, delta_avg = gcfs_rq->avg.runnable_avg - se->avg.runnable_avg; in update_tg_cfs_runnable()
4320 * cfs_rq->avg.period_contrib can be used for both cfs_rq and se. in update_tg_cfs_runnable()
4326 se->avg.runnable_avg = gcfs_rq->avg.runnable_avg; in update_tg_cfs_runnable()
4327 new_sum = se->avg.runnable_avg * divider; in update_tg_cfs_runnable()
4328 delta_sum = (long)new_sum - (long)se->avg.runnable_sum; in update_tg_cfs_runnable()
4329 se->avg.runnable_sum = new_sum; in update_tg_cfs_runnable()
4340 update_tg_cfs_load(struct cfs_rq *cfs_rq, struct sched_entity *se, struct cfs_rq *gcfs_rq) in update_tg_cfs_load() argument
4354 * cfs_rq->avg.period_contrib can be used for both cfs_rq and se. in update_tg_cfs_load()
4364 runnable_sum += se->avg.load_sum; in update_tg_cfs_load()
4376 /* But make sure to not inflate se's runnable */ in update_tg_cfs_load()
4377 runnable_sum = min(se->avg.load_sum, load_sum); in update_tg_cfs_load()
4386 running_sum = se->avg.util_sum >> SCHED_CAPACITY_SHIFT; in update_tg_cfs_load()
4389 load_sum = se_weight(se) * runnable_sum; in update_tg_cfs_load()
4392 delta_avg = load_avg - se->avg.load_avg; in update_tg_cfs_load()
4396 delta_sum = load_sum - (s64)se_weight(se) * se->avg.load_sum; in update_tg_cfs_load()
4398 se->avg.load_sum = runnable_sum; in update_tg_cfs_load()
4399 se->avg.load_avg = load_avg; in update_tg_cfs_load()
4414 static inline int propagate_entity_load_avg(struct sched_entity *se) in propagate_entity_load_avg() argument
4418 if (entity_is_task(se)) in propagate_entity_load_avg()
4421 gcfs_rq = group_cfs_rq(se); in propagate_entity_load_avg()
4427 cfs_rq = cfs_rq_of(se); in propagate_entity_load_avg()
4431 update_tg_cfs_util(cfs_rq, se, gcfs_rq); in propagate_entity_load_avg()
4432 update_tg_cfs_runnable(cfs_rq, se, gcfs_rq); in propagate_entity_load_avg()
4433 update_tg_cfs_load(cfs_rq, se, gcfs_rq); in propagate_entity_load_avg()
4436 trace_pelt_se_tp(se); in propagate_entity_load_avg()
4445 static inline bool skip_blocked_update(struct sched_entity *se) in skip_blocked_update() argument
4447 struct cfs_rq *gcfs_rq = group_cfs_rq(se); in skip_blocked_update()
4453 if (se->avg.load_avg || se->avg.util_avg) in skip_blocked_update()
4475 static inline int propagate_entity_load_avg(struct sched_entity *se) in propagate_entity_load_avg() argument
4485 static inline void migrate_se_pelt_lag(struct sched_entity *se) in migrate_se_pelt_lag() argument
4492 if (load_avg_is_decayed(&se->avg)) in migrate_se_pelt_lag()
4495 cfs_rq = cfs_rq_of(se); in migrate_se_pelt_lag()
4561 __update_load_avg_blocked_se(now, se); in migrate_se_pelt_lag()
4564 static void migrate_se_pelt_lag(struct sched_entity *se) {} in migrate_se_pelt_lag() argument
4610 * Because of rounding, se->util_sum might ends up being +1 more than in update_cfs_rq_load_avg()
4649 * @se: sched_entity to attach
4654 static void attach_entity_load_avg(struct cfs_rq *cfs_rq, struct sched_entity *se) in attach_entity_load_avg() argument
4657 * cfs_rq->avg.period_contrib can be used for both cfs_rq and se. in attach_entity_load_avg()
4663 * When we attach the @se to the @cfs_rq, we must align the decay in attach_entity_load_avg()
4669 se->avg.last_update_time = cfs_rq->avg.last_update_time; in attach_entity_load_avg()
4670 se->avg.period_contrib = cfs_rq->avg.period_contrib; in attach_entity_load_avg()
4678 se->avg.util_sum = se->avg.util_avg * divider; in attach_entity_load_avg()
4680 se->avg.runnable_sum = se->avg.runnable_avg * divider; in attach_entity_load_avg()
4682 se->avg.load_sum = se->avg.load_avg * divider; in attach_entity_load_avg()
4683 if (se_weight(se) < se->avg.load_sum) in attach_entity_load_avg()
4684 se->avg.load_sum = div_u64(se->avg.load_sum, se_weight(se)); in attach_entity_load_avg()
4686 se->avg.load_sum = 1; in attach_entity_load_avg()
4688 enqueue_load_avg(cfs_rq, se); in attach_entity_load_avg()
4689 cfs_rq->avg.util_avg += se->avg.util_avg; in attach_entity_load_avg()
4690 cfs_rq->avg.util_sum += se->avg.util_sum; in attach_entity_load_avg()
4691 cfs_rq->avg.runnable_avg += se->avg.runnable_avg; in attach_entity_load_avg()
4692 cfs_rq->avg.runnable_sum += se->avg.runnable_sum; in attach_entity_load_avg()
4694 add_tg_cfs_propagate(cfs_rq, se->avg.load_sum); in attach_entity_load_avg()
4704 * @se: sched_entity to detach
4709 static void detach_entity_load_avg(struct cfs_rq *cfs_rq, struct sched_entity *se) in detach_entity_load_avg() argument
4711 dequeue_load_avg(cfs_rq, se); in detach_entity_load_avg()
4712 sub_positive(&cfs_rq->avg.util_avg, se->avg.util_avg); in detach_entity_load_avg()
4713 sub_positive(&cfs_rq->avg.util_sum, se->avg.util_sum); in detach_entity_load_avg()
4718 sub_positive(&cfs_rq->avg.runnable_avg, se->avg.runnable_avg); in detach_entity_load_avg()
4719 sub_positive(&cfs_rq->avg.runnable_sum, se->avg.runnable_sum); in detach_entity_load_avg()
4724 add_tg_cfs_propagate(cfs_rq, -se->avg.load_sum); in detach_entity_load_avg()
4740 static inline void update_load_avg(struct cfs_rq *cfs_rq, struct sched_entity *se, int flags) in update_load_avg() argument
4749 if (se->avg.last_update_time && !(flags & SKIP_AGE_LOAD)) in update_load_avg()
4750 __update_load_avg_se(now, cfs_rq, se); in update_load_avg()
4753 decayed |= propagate_entity_load_avg(se); in update_load_avg()
4755 if (!se->avg.last_update_time && (flags & DO_ATTACH)) { in update_load_avg()
4764 attach_entity_load_avg(cfs_rq, se); in update_load_avg()
4772 detach_entity_load_avg(cfs_rq, se); in update_load_avg()
4786 static void sync_entity_load_avg(struct sched_entity *se) in sync_entity_load_avg() argument
4788 struct cfs_rq *cfs_rq = cfs_rq_of(se); in sync_entity_load_avg()
4792 __update_load_avg_blocked_se(last_update_time, se); in sync_entity_load_avg()
4799 static void remove_entity_load_avg(struct sched_entity *se) in remove_entity_load_avg() argument
4801 struct cfs_rq *cfs_rq = cfs_rq_of(se); in remove_entity_load_avg()
4810 sync_entity_load_avg(se); in remove_entity_load_avg()
4814 cfs_rq->removed.util_avg += se->avg.util_avg; in remove_entity_load_avg()
4815 cfs_rq->removed.load_avg += se->avg.load_avg; in remove_entity_load_avg()
4816 cfs_rq->removed.runnable_avg += se->avg.runnable_avg; in remove_entity_load_avg()
4834 return READ_ONCE(p->se.avg.util_avg); in task_util()
4839 struct util_est ue = READ_ONCE(p->se.avg.util_est); in _task_util_est()
4917 ue = p->se.avg.util_est; in util_est_update()
4977 WRITE_ONCE(p->se.avg.util_est, ue); in util_est_update()
4979 trace_sched_util_est_se_tp(&p->se); in util_est_update()
5147 static inline void update_load_avg(struct cfs_rq *cfs_rq, struct sched_entity *se, int not_used1) in update_load_avg() argument
5152 static inline void remove_entity_load_avg(struct sched_entity *se) {} in remove_entity_load_avg() argument
5155 attach_entity_load_avg(struct cfs_rq *cfs_rq, struct sched_entity *se) {} in attach_entity_load_avg() argument
5157 detach_entity_load_avg(struct cfs_rq *cfs_rq, struct sched_entity *se) {} in detach_entity_load_avg() argument
5178 place_entity(struct cfs_rq *cfs_rq, struct sched_entity *se, int flags) in place_entity() argument
5183 se->slice = sysctl_sched_base_slice; in place_entity()
5184 vslice = calc_delta_fair(se->slice, se); in place_entity()
5198 lag = se->vlag; in place_entity()
5256 lag *= load + scale_load_down(se->load.weight); in place_entity()
5262 se->vruntime = vruntime - lag; in place_entity()
5275 se->deadline = se->vruntime + vslice; in place_entity()
5284 enqueue_entity(struct cfs_rq *cfs_rq, struct sched_entity *se, int flags) in enqueue_entity() argument
5286 bool curr = cfs_rq->curr == se; in enqueue_entity()
5293 place_entity(cfs_rq, se, flags); in enqueue_entity()
5306 update_load_avg(cfs_rq, se, UPDATE_TG | DO_ATTACH); in enqueue_entity()
5307 se_update_runnable(se); in enqueue_entity()
5313 update_cfs_group(se); in enqueue_entity()
5320 place_entity(cfs_rq, se, flags); in enqueue_entity()
5322 account_entity_enqueue(cfs_rq, se); in enqueue_entity()
5326 se->exec_start = 0; in enqueue_entity()
5329 update_stats_enqueue_fair(cfs_rq, se, flags); in enqueue_entity()
5331 __enqueue_entity(cfs_rq, se); in enqueue_entity()
5332 se->on_rq = 1; in enqueue_entity()
5351 static void __clear_buddies_next(struct sched_entity *se) in __clear_buddies_next() argument
5353 for_each_sched_entity(se) { in __clear_buddies_next()
5354 struct cfs_rq *cfs_rq = cfs_rq_of(se); in __clear_buddies_next()
5355 if (cfs_rq->next != se) in __clear_buddies_next()
5362 static void clear_buddies(struct cfs_rq *cfs_rq, struct sched_entity *se) in clear_buddies() argument
5364 if (cfs_rq->next == se) in clear_buddies()
5365 __clear_buddies_next(se); in clear_buddies()
5371 dequeue_entity(struct cfs_rq *cfs_rq, struct sched_entity *se, int flags) in dequeue_entity() argument
5375 if (entity_is_task(se) && task_on_rq_migrating(task_of(se))) in dequeue_entity()
5392 update_load_avg(cfs_rq, se, action); in dequeue_entity()
5393 se_update_runnable(se); in dequeue_entity()
5395 update_stats_dequeue_fair(cfs_rq, se, flags); in dequeue_entity()
5397 clear_buddies(cfs_rq, se); in dequeue_entity()
5399 update_entity_lag(cfs_rq, se); in dequeue_entity()
5400 if (se != cfs_rq->curr) in dequeue_entity()
5401 __dequeue_entity(cfs_rq, se); in dequeue_entity()
5402 se->on_rq = 0; in dequeue_entity()
5403 account_entity_dequeue(cfs_rq, se); in dequeue_entity()
5408 update_cfs_group(se); in dequeue_entity()
5411 * Now advance min_vruntime if @se was the entity holding it back, in dequeue_entity()
5424 set_next_entity(struct cfs_rq *cfs_rq, struct sched_entity *se) in set_next_entity() argument
5426 clear_buddies(cfs_rq, se); in set_next_entity()
5429 if (se->on_rq) { in set_next_entity()
5435 update_stats_wait_end_fair(cfs_rq, se); in set_next_entity()
5436 __dequeue_entity(cfs_rq, se); in set_next_entity()
5437 update_load_avg(cfs_rq, se, UPDATE_TG); in set_next_entity()
5442 se->vlag = se->deadline; in set_next_entity()
5445 update_stats_curr_start(cfs_rq, se); in set_next_entity()
5446 cfs_rq->curr = se; in set_next_entity()
5454 rq_of(cfs_rq)->cfs.load.weight >= 2*se->load.weight) { in set_next_entity()
5457 stats = __schedstats_from_se(se); in set_next_entity()
5460 se->sum_exec_runtime - se->prev_sum_exec_runtime)); in set_next_entity()
5463 se->prev_sum_exec_runtime = se->sum_exec_runtime; in set_next_entity()
5768 struct sched_entity *se; in throttle_cfs_rq() local
5792 se = cfs_rq->tg->se[cpu_of(rq_of(cfs_rq))]; in throttle_cfs_rq()
5801 for_each_sched_entity(se) { in throttle_cfs_rq()
5802 struct cfs_rq *qcfs_rq = cfs_rq_of(se); in throttle_cfs_rq()
5804 if (!se->on_rq) in throttle_cfs_rq()
5807 dequeue_entity(qcfs_rq, se, DEQUEUE_SLEEP); in throttle_cfs_rq()
5809 if (cfs_rq_is_idle(group_cfs_rq(se))) in throttle_cfs_rq()
5817 se = parent_entity(se); in throttle_cfs_rq()
5822 for_each_sched_entity(se) { in throttle_cfs_rq()
5823 struct cfs_rq *qcfs_rq = cfs_rq_of(se); in throttle_cfs_rq()
5825 if (!se->on_rq) in throttle_cfs_rq()
5828 update_load_avg(qcfs_rq, se, 0); in throttle_cfs_rq()
5829 se_update_runnable(se); in throttle_cfs_rq()
5831 if (cfs_rq_is_idle(group_cfs_rq(se))) in throttle_cfs_rq()
5838 /* At this point se is NULL and we are at root level*/ in throttle_cfs_rq()
5857 struct sched_entity *se; in unthrottle_cfs_rq() local
5860 se = cfs_rq->tg->se[cpu_of(rq)]; in unthrottle_cfs_rq()
5884 for_each_sched_entity(se) { in unthrottle_cfs_rq()
5885 if (list_add_leaf_cfs_rq(cfs_rq_of(se))) in unthrottle_cfs_rq()
5893 for_each_sched_entity(se) { in unthrottle_cfs_rq()
5894 struct cfs_rq *qcfs_rq = cfs_rq_of(se); in unthrottle_cfs_rq()
5896 if (se->on_rq) in unthrottle_cfs_rq()
5898 enqueue_entity(qcfs_rq, se, ENQUEUE_WAKEUP); in unthrottle_cfs_rq()
5900 if (cfs_rq_is_idle(group_cfs_rq(se))) in unthrottle_cfs_rq()
5911 for_each_sched_entity(se) { in unthrottle_cfs_rq()
5912 struct cfs_rq *qcfs_rq = cfs_rq_of(se); in unthrottle_cfs_rq()
5914 update_load_avg(qcfs_rq, se, UPDATE_TG); in unthrottle_cfs_rq()
5915 se_update_runnable(se); in unthrottle_cfs_rq()
5917 if (cfs_rq_is_idle(group_cfs_rq(se))) in unthrottle_cfs_rq()
5928 /* At this point se is NULL and we are at root level*/ in unthrottle_cfs_rq()
6630 struct sched_entity *se = &p->se; in hrtick_start_fair() local
6635 u64 ran = se->sum_exec_runtime - se->prev_sum_exec_runtime; in hrtick_start_fair()
6636 u64 slice = se->slice; in hrtick_start_fair()
6737 struct sched_entity *se = &p->se; in enqueue_task_fair() local
6757 for_each_sched_entity(se) { in enqueue_task_fair()
6758 if (se->on_rq) in enqueue_task_fair()
6760 cfs_rq = cfs_rq_of(se); in enqueue_task_fair()
6761 enqueue_entity(cfs_rq, se, flags); in enqueue_task_fair()
6776 for_each_sched_entity(se) { in enqueue_task_fair()
6777 cfs_rq = cfs_rq_of(se); in enqueue_task_fair()
6779 update_load_avg(cfs_rq, se, UPDATE_TG); in enqueue_task_fair()
6780 se_update_runnable(se); in enqueue_task_fair()
6781 update_cfs_group(se); in enqueue_task_fair()
6794 /* At this point se is NULL and we are at root level*/ in enqueue_task_fair()
6820 static void set_next_buddy(struct sched_entity *se);
6830 struct sched_entity *se = &p->se; in dequeue_task_fair() local
6837 for_each_sched_entity(se) { in dequeue_task_fair()
6838 cfs_rq = cfs_rq_of(se); in dequeue_task_fair()
6839 dequeue_entity(cfs_rq, se, flags); in dequeue_task_fair()
6854 se = parent_entity(se); in dequeue_task_fair()
6859 if (task_sleep && se && !throttled_hierarchy(cfs_rq)) in dequeue_task_fair()
6860 set_next_buddy(se); in dequeue_task_fair()
6866 for_each_sched_entity(se) { in dequeue_task_fair()
6867 cfs_rq = cfs_rq_of(se); in dequeue_task_fair()
6869 update_load_avg(cfs_rq, se, UPDATE_TG); in dequeue_task_fair()
6870 se_update_runnable(se); in dequeue_task_fair()
6871 update_cfs_group(se); in dequeue_task_fair()
6885 /* At this point se is NULL and we are at root level*/ in dequeue_task_fair()
6941 if (cpu_of(rq) != task_cpu(p) || !READ_ONCE(p->se.avg.last_update_time)) in cpu_load_without()
6964 if (cpu_of(rq) != task_cpu(p) || !READ_ONCE(p->se.avg.last_update_time)) in cpu_runnable_without()
6971 lsub_positive(&runnable, p->se.avg.runnable_avg); in cpu_runnable_without()
7206 sync_entity_load_avg(&p->se); in find_idlest_cpu()
7563 sync_entity_load_avg(&p->se); in select_idle_sibling()
7787 if (cpu != task_cpu(p) || !READ_ONCE(p->se.avg.last_update_time)) in cpu_util_without()
7988 sync_entity_load_avg(&p->se); in find_energy_efficient_cpu()
8231 struct sched_entity *se = &p->se; in migrate_task_rq_fair() local
8234 remove_entity_load_avg(se); in migrate_task_rq_fair()
8246 migrate_se_pelt_lag(se); in migrate_task_rq_fair()
8250 se->avg.last_update_time = 0; in migrate_task_rq_fair()
8257 remove_entity_load_avg(&p->se); in task_dead_fair()
8270 static void set_next_buddy(struct sched_entity *se) in set_next_buddy() argument
8272 for_each_sched_entity(se) { in set_next_buddy()
8273 if (SCHED_WARN_ON(!se->on_rq)) in set_next_buddy()
8275 if (se_is_idle(se)) in set_next_buddy()
8277 cfs_rq_of(se)->next = se; in set_next_buddy()
8287 struct sched_entity *se = &curr->se, *pse = &p->se; in check_preempt_wakeup_fair() local
8292 if (unlikely(se == pse)) in check_preempt_wakeup_fair()
8325 find_matching_se(&se, &pse); in check_preempt_wakeup_fair()
8328 cse_is_idle = se_is_idle(se); in check_preempt_wakeup_fair()
8346 cfs_rq = cfs_rq_of(se); in check_preempt_wakeup_fair()
8349 * XXX pick_eevdf(cfs_rq) != se ? in check_preempt_wakeup_fair()
8363 struct sched_entity *se; in pick_task_fair() local
8385 se = pick_next_entity(cfs_rq, curr); in pick_task_fair()
8386 cfs_rq = group_cfs_rq(se); in pick_task_fair()
8389 return task_of(se); in pick_task_fair()
8397 struct sched_entity *se; in pick_next_task_fair() local
8448 se = pick_next_entity(cfs_rq, curr); in pick_next_task_fair()
8449 cfs_rq = group_cfs_rq(se); in pick_next_task_fair()
8452 p = task_of(se); in pick_next_task_fair()
8460 struct sched_entity *pse = &prev->se; in pick_next_task_fair()
8462 while (!(cfs_rq = is_same_group(se, pse))) { in pick_next_task_fair()
8463 int se_depth = se->depth; in pick_next_task_fair()
8471 set_next_entity(cfs_rq_of(se), se); in pick_next_task_fair()
8472 se = parent_entity(se); in pick_next_task_fair()
8477 set_next_entity(cfs_rq, se); in pick_next_task_fair()
8487 se = pick_next_entity(cfs_rq, NULL); in pick_next_task_fair()
8488 set_next_entity(cfs_rq, se); in pick_next_task_fair()
8489 cfs_rq = group_cfs_rq(se); in pick_next_task_fair()
8492 p = task_of(se); in pick_next_task_fair()
8501 list_move(&p->se.group_node, &rq->cfs_tasks); in pick_next_task_fair()
8548 struct sched_entity *se = &prev->se; in put_prev_task_fair() local
8551 for_each_sched_entity(se) { in put_prev_task_fair()
8552 cfs_rq = cfs_rq_of(se); in put_prev_task_fair()
8553 put_prev_entity(cfs_rq, se); in put_prev_task_fair()
8564 struct sched_entity *se = &curr->se; in yield_task_fair() local
8572 clear_buddies(cfs_rq, se); in yield_task_fair()
8586 se->deadline += calc_delta_fair(se->slice, se); in yield_task_fair()
8591 struct sched_entity *se = &p->se; in yield_to_task_fair() local
8594 if (!se->on_rq || throttled_hierarchy(cfs_rq_of(se))) in yield_to_task_fair()
8598 set_next_buddy(se); in yield_to_task_fair()
8834 (&p->se == cfs_rq_of(&p->se)->next)) in task_hot()
8850 delta = rq_clock_task(env->src_rq) - p->se.exec_start; in task_hot()
9031 &env->src_rq->cfs_tasks, se.group_node) { in detach_one_task()
9096 p = list_last_entry(tasks, struct task_struct, se.group_node); in detach_tasks()
9151 list_add(&p->se.group_node, &env->tasks); in detach_tasks()
9174 list_move(&p->se.group_node, tasks); in detach_tasks()
9227 p = list_first_entry(tasks, struct task_struct, se.group_node); in attach_tasks()
9228 list_del_init(&p->se.group_node); in attach_tasks()
9323 struct sched_entity *se; in __update_blocked_fair() local
9336 se = cfs_rq->tg->se[cpu]; in __update_blocked_fair()
9337 if (se && !skip_blocked_update(se)) in __update_blocked_fair()
9338 update_load_avg(cfs_rq_of(se), se, UPDATE_TG); in __update_blocked_fair()
9363 struct sched_entity *se = cfs_rq->tg->se[cpu_of(rq)]; in update_cfs_rq_h_load() local
9371 for_each_sched_entity(se) { in update_cfs_rq_h_load()
9372 cfs_rq = cfs_rq_of(se); in update_cfs_rq_h_load()
9373 WRITE_ONCE(cfs_rq->h_load_next, se); in update_cfs_rq_h_load()
9378 if (!se) { in update_cfs_rq_h_load()
9383 while ((se = READ_ONCE(cfs_rq->h_load_next)) != NULL) { in update_cfs_rq_h_load()
9385 load = div64_ul(load * se->avg.load_avg, in update_cfs_rq_h_load()
9387 cfs_rq = group_cfs_rq(se); in update_cfs_rq_h_load()
9398 return div64_ul(p->se.avg.load_avg * cfs_rq->h_load, in task_h_load()
9416 return p->se.avg.load_avg; in task_h_load()
10168 if (cpu != task_cpu(p) || !READ_ONCE(p->se.avg.last_update_time)) in task_running_on_cpu()
12473 __entity_slice_used(struct sched_entity *se, int min_nr_tasks) in __entity_slice_used() argument
12475 u64 rtime = se->sum_exec_runtime - se->prev_sum_exec_runtime; in __entity_slice_used()
12476 u64 slice = se->slice; in __entity_slice_used()
12502 __entity_slice_used(&curr->se, MIN_NR_TASKS_DURING_FORCEIDLE)) in task_tick_core()
12509 static void se_fi_update(const struct sched_entity *se, unsigned int fi_seq, in se_fi_update() argument
12512 for_each_sched_entity(se) { in se_fi_update()
12513 struct cfs_rq *cfs_rq = cfs_rq_of(se); in se_fi_update()
12527 struct sched_entity *se = &p->se; in task_vruntime_update() local
12532 se_fi_update(se, rq->core->core_forceidle_seq, in_fi); in task_vruntime_update()
12539 const struct sched_entity *sea = &a->se; in cfs_prio_less()
12540 const struct sched_entity *seb = &b->se; in cfs_prio_less()
12549 * Find an se in the hierarchy for tasks a and b, such that the se's in cfs_prio_less()
12573 * Find delta after normalizing se's vruntime with its cfs_rq's in cfs_prio_less()
12609 struct sched_entity *se = &curr->se; in task_tick_fair() local
12611 for_each_sched_entity(se) { in task_tick_fair()
12612 cfs_rq = cfs_rq_of(se); in task_tick_fair()
12613 entity_tick(cfs_rq, se, queued); in task_tick_fair()
12632 struct sched_entity *se = &p->se, *curr; in task_fork_fair() local
12644 place_entity(cfs_rq, se, ENQUEUE_INITIAL); in task_fork_fair()
12678 static void propagate_entity_cfs_rq(struct sched_entity *se) in propagate_entity_cfs_rq() argument
12680 struct cfs_rq *cfs_rq = cfs_rq_of(se); in propagate_entity_cfs_rq()
12689 se = se->parent; in propagate_entity_cfs_rq()
12691 for_each_sched_entity(se) { in propagate_entity_cfs_rq()
12692 cfs_rq = cfs_rq_of(se); in propagate_entity_cfs_rq()
12694 update_load_avg(cfs_rq, se, UPDATE_TG); in propagate_entity_cfs_rq()
12704 static void propagate_entity_cfs_rq(struct sched_entity *se) { } in propagate_entity_cfs_rq() argument
12707 static void detach_entity_cfs_rq(struct sched_entity *se) in detach_entity_cfs_rq() argument
12709 struct cfs_rq *cfs_rq = cfs_rq_of(se); in detach_entity_cfs_rq()
12718 if (!se->avg.last_update_time) in detach_entity_cfs_rq()
12723 update_load_avg(cfs_rq, se, 0); in detach_entity_cfs_rq()
12724 detach_entity_load_avg(cfs_rq, se); in detach_entity_cfs_rq()
12726 propagate_entity_cfs_rq(se); in detach_entity_cfs_rq()
12729 static void attach_entity_cfs_rq(struct sched_entity *se) in attach_entity_cfs_rq() argument
12731 struct cfs_rq *cfs_rq = cfs_rq_of(se); in attach_entity_cfs_rq()
12734 update_load_avg(cfs_rq, se, sched_feat(ATTACH_AGE_LOAD) ? 0 : SKIP_AGE_LOAD); in attach_entity_cfs_rq()
12735 attach_entity_load_avg(cfs_rq, se); in attach_entity_cfs_rq()
12737 propagate_entity_cfs_rq(se); in attach_entity_cfs_rq()
12742 struct sched_entity *se = &p->se; in detach_task_cfs_rq() local
12744 detach_entity_cfs_rq(se); in detach_task_cfs_rq()
12749 struct sched_entity *se = &p->se; in attach_task_cfs_rq() local
12751 attach_entity_cfs_rq(se); in attach_task_cfs_rq()
12783 struct sched_entity *se = &p->se; in set_next_task_fair() local
12791 list_move(&se->group_node, &rq->cfs_tasks); in set_next_task_fair()
12795 for_each_sched_entity(se) { in set_next_task_fair()
12796 struct cfs_rq *cfs_rq = cfs_rq_of(se); in set_next_task_fair()
12798 set_next_entity(cfs_rq, se); in set_next_task_fair()
12826 /* Tell se's cfs_rq has been changed -- migrated */ in task_change_group_fair()
12827 p->se.avg.last_update_time = 0; in task_change_group_fair()
12840 if (tg->se) in free_fair_sched_group()
12841 kfree(tg->se[i]); in free_fair_sched_group()
12845 kfree(tg->se); in free_fair_sched_group()
12850 struct sched_entity *se; in alloc_fair_sched_group() local
12857 tg->se = kcalloc(nr_cpu_ids, sizeof(se), GFP_KERNEL); in alloc_fair_sched_group()
12858 if (!tg->se) in alloc_fair_sched_group()
12871 se = kzalloc_node(sizeof(struct sched_entity_stats), in alloc_fair_sched_group()
12873 if (!se) in alloc_fair_sched_group()
12877 init_tg_cfs_entry(tg, cfs_rq, se, i, parent->se[i]); in alloc_fair_sched_group()
12878 init_entity_runnable_average(se); in alloc_fair_sched_group()
12891 struct sched_entity *se; in online_fair_sched_group() local
12898 se = tg->se[i]; in online_fair_sched_group()
12901 attach_entity_cfs_rq(se); in online_fair_sched_group()
12916 if (tg->se[cpu]) in unregister_fair_sched_group()
12917 remove_entity_load_avg(tg->se[cpu]); in unregister_fair_sched_group()
12935 struct sched_entity *se, int cpu, in init_tg_cfs_entry() argument
12945 tg->se[cpu] = se; in init_tg_cfs_entry()
12947 /* se could be NULL for root_task_group */ in init_tg_cfs_entry()
12948 if (!se) in init_tg_cfs_entry()
12952 se->cfs_rq = &rq->cfs; in init_tg_cfs_entry()
12953 se->depth = 0; in init_tg_cfs_entry()
12955 se->cfs_rq = parent->my_q; in init_tg_cfs_entry()
12956 se->depth = parent->depth + 1; in init_tg_cfs_entry()
12959 se->my_q = cfs_rq; in init_tg_cfs_entry()
12961 update_load_set(&se->load, NICE_0_LOAD); in init_tg_cfs_entry()
12962 se->parent = parent; in init_tg_cfs_entry()
12976 if (!tg->se[0]) in __sched_group_set_shares()
12987 struct sched_entity *se = tg->se[i]; in __sched_group_set_shares() local
12993 for_each_sched_entity(se) { in __sched_group_set_shares()
12994 update_load_avg(cfs_rq_of(se), se, UPDATE_TG); in __sched_group_set_shares()
12995 update_cfs_group(se); in __sched_group_set_shares()
13038 struct sched_entity *se = tg->se[i]; in sched_group_set_idle() local
13050 if (se->on_rq) { in sched_group_set_idle()
13051 parent_cfs_rq = cfs_rq_of(se); in sched_group_set_idle()
13063 for_each_sched_entity(se) { in sched_group_set_idle()
13064 struct cfs_rq *cfs_rq = cfs_rq_of(se); in sched_group_set_idle()
13066 if (!se->on_rq) in sched_group_set_idle()
13108 struct sched_entity *se = &task->se; in get_rr_interval_fair() local
13116 rr_interval = NS_TO_JIFFIES(se->slice); in get_rr_interval_fair()