Create a single function that initializes a sched_dl_entity. Signed-off-by: Peter Zijlstra (Intel) <pet...@infradead.org> --- kernel/sched/core.c | 5 +---- kernel/sched/deadline.c | 22 +++++++++++++++------- kernel/sched/sched.h | 6 ++---- 3 files changed, 18 insertions(+), 15 deletions(-)
--- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -2581,10 +2581,7 @@ static void __sched_fork(unsigned long c memset(&p->se.statistics, 0, sizeof(p->se.statistics)); #endif - RB_CLEAR_NODE(&p->dl.rb_node); - init_dl_task_timer(&p->dl); - init_dl_inactive_task_timer(&p->dl); - __dl_clear_params(p); + init_dl_entity(&p->dl); INIT_LIST_HEAD(&p->rt.run_list); p->rt.timeout = 0; --- a/kernel/sched/deadline.c +++ b/kernel/sched/deadline.c @@ -180,6 +180,8 @@ void dl_change_utilization(struct task_s __add_rq_bw(new_bw, &rq->dl); } +static void __dl_clear_params(struct sched_dl_entity *dl_se); + /* * The utilization of a task cannot be immediately removed from * the rq active utilization (running_bw) when the task blocks. @@ -278,7 +280,7 @@ static void task_non_contending(struct t sub_rq_bw(&p->dl, &rq->dl); raw_spin_lock(&dl_b->lock); __dl_sub(dl_b, p->dl.dl_bw, dl_bw_cpus(task_cpu(p))); - __dl_clear_params(p); + __dl_clear_params(dl_se); raw_spin_unlock(&dl_b->lock); } @@ -1049,7 +1051,7 @@ static enum hrtimer_restart dl_task_time return HRTIMER_NORESTART; } -void init_dl_task_timer(struct sched_dl_entity *dl_se) +static void init_dl_task_timer(struct sched_dl_entity *dl_se) { struct hrtimer *timer = &dl_se->dl_timer; @@ -1261,7 +1263,7 @@ static enum hrtimer_restart inactive_tas raw_spin_lock(&dl_b->lock); __dl_sub(dl_b, p->dl.dl_bw, dl_bw_cpus(task_cpu(p))); raw_spin_unlock(&dl_b->lock); - __dl_clear_params(p); + __dl_clear_params(dl_se); goto unlock; } @@ -1277,7 +1279,7 @@ static enum hrtimer_restart inactive_tas return HRTIMER_NORESTART; } -void init_dl_inactive_task_timer(struct sched_dl_entity *dl_se) +static void init_dl_inactive_task_timer(struct sched_dl_entity *dl_se) { struct hrtimer *timer = &dl_se->inactive_timer; @@ -2633,10 +2635,8 @@ bool __checkparam_dl(const struct sched_ /* * This function clears the sched_dl_entity static params. */ -void __dl_clear_params(struct task_struct *p) +static void __dl_clear_params(struct sched_dl_entity *dl_se) { - struct sched_dl_entity *dl_se = &p->dl; - dl_se->dl_runtime = 0; dl_se->dl_deadline = 0; dl_se->dl_period = 0; @@ -2650,6 +2650,14 @@ void __dl_clear_params(struct task_struc dl_se->dl_overrun = 0; } +void init_dl_entity(struct sched_dl_entity *dl_se) +{ + RB_CLEAR_NODE(&dl_se->rb_node); + init_dl_task_timer(dl_se); + init_dl_inactive_task_timer(dl_se); + __dl_clear_params(dl_se); +} + bool dl_param_changed(struct task_struct *p, const struct sched_attr *attr) { struct sched_dl_entity *dl_se = &p->dl; --- a/kernel/sched/sched.h +++ b/kernel/sched/sched.h @@ -239,8 +239,6 @@ struct rt_bandwidth { unsigned int rt_period_active; }; -void __dl_clear_params(struct task_struct *p); - /* * To keep the bandwidth of -deadline tasks and groups under control * we need some place where: @@ -1844,10 +1842,10 @@ extern void init_rt_bandwidth(struct rt_ extern struct dl_bandwidth def_dl_bandwidth; extern void init_dl_bandwidth(struct dl_bandwidth *dl_b, u64 period, u64 runtime); -extern void init_dl_task_timer(struct sched_dl_entity *dl_se); -extern void init_dl_inactive_task_timer(struct sched_dl_entity *dl_se); extern void init_dl_rq_bw_ratio(struct dl_rq *dl_rq); +extern void init_dl_entity(struct sched_dl_entity *dl_se); + #define BW_SHIFT 20 #define BW_UNIT (1 << BW_SHIFT) #define RATIO_SHIFT 8