From fdcc704fd8ca710ef3c90b936c426c9be8290ac3 Mon Sep 17 00:00:00 2001 From: Johnlay Park Date: Mon, 26 Feb 2018 10:32:14 +0900 Subject: [PATCH] [COMMON] sched/rt: Initializing RT Task load Change-Id: Ic59923ac76d690811fda9fc0228a2dea152948c9 Signed-off-by: Johnlay Park --- kernel/sched/core.c | 1 + kernel/sched/rt.c | 25 +++++++++++++++++++++++++ kernel/sched/sched.h | 1 + 3 files changed, 27 insertions(+) diff --git a/kernel/sched/core.c b/kernel/sched/core.c index ab6d57b537b3..847bdfbd65f4 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -2425,6 +2425,7 @@ int sched_fork(unsigned long clone_flags, struct task_struct *p) } init_entity_runnable_average(&p->se); + init_rt_entity_runnable_average(&p->rt); /* * The child is not yet in the pid-hash so no cgroup attach races, diff --git a/kernel/sched/rt.c b/kernel/sched/rt.c index 0ec3a6f29f72..e3d6b2124ecc 100644 --- a/kernel/sched/rt.c +++ b/kernel/sched/rt.c @@ -216,6 +216,7 @@ int alloc_rt_sched_group(struct task_group *tg, struct task_group *parent) init_rt_rq(rt_rq); rt_rq->rt_runtime = tg->rt_bandwidth.rt_runtime; init_tg_rt_entry(tg, rt_rq, rt_se, i, parent->rt_se[i]); + init_rt_entity_runnable_average(rt_se); } return 1; @@ -1651,6 +1652,30 @@ static void check_preempt_equal_prio(struct rq *rq, struct task_struct *p) resched_curr(rq); } +/* Give new sched_entity start runnable values to heavy its load in infant time */ +void init_rt_entity_runnable_average(struct sched_rt_entity *rt_se) +{ + struct sched_avg *sa = &rt_se->avg; + + sa->last_update_time = 0; + + sa->period_contrib = 1023; + + /* + * Tasks are intialized with zero load. + * Load is not actually used by RT, but can be inherited into fair task. + */ + sa->load_avg = 0; + sa->load_sum = 0; + /* + * At this point, util_avg won't be used in select_task_rq_rt anyway + */ + sa->util_avg = 0; + sa->util_sum = 0; + /* when this task enqueue'ed, it will contribute to its cfs_rq's load_avg */ +} +#else +void init_rt_entity_runnable_average(struct sched_rt_entity *rt_se) { } #endif /* CONFIG_SMP */ /* diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h index c9447be011f9..70f3c87f73b8 100644 --- a/kernel/sched/sched.h +++ b/kernel/sched/sched.h @@ -1653,6 +1653,7 @@ extern void init_dl_rq_bw_ratio(struct dl_rq *dl_rq); unsigned long to_ratio(u64 period, u64 runtime); extern void init_entity_runnable_average(struct sched_entity *se); +extern void init_rt_entity_runnable_average(struct sched_rt_entity *rt_se); extern void post_init_entity_util_avg(struct sched_entity *se); #ifdef CONFIG_NO_HZ_FULL -- 2.20.1