[PATCH 1/7 v3] sched: factorize attach entity

From: Vincent Guittot
Date: Mon Sep 12 2016 - 03:48:34 EST


Factorize post_init_entity_util_avg and part of attach_task_cfs_rq
in one function attach_entity_cfs_rq

Signed-off-by: Vincent Guittot <vincent.guittot@xxxxxxxxxx>
---
kernel/sched/fair.c | 19 +++++++++++--------
1 file changed, 11 insertions(+), 8 deletions(-)

diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index a6820b3..dfd9c0c 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -694,9 +694,7 @@ void init_entity_runnable_average(struct sched_entity *se)
}

static inline u64 cfs_rq_clock_task(struct cfs_rq *cfs_rq);
-static int update_cfs_rq_load_avg(u64 now, struct cfs_rq *cfs_rq, bool update_freq);
-static void update_tg_load_avg(struct cfs_rq *cfs_rq, int force);
-static void attach_entity_load_avg(struct cfs_rq *cfs_rq, struct sched_entity *se);
+static void attach_entity_cfs_rq(struct sched_entity *se);

/*
* With new tasks being created, their initial util_avgs are extrapolated
@@ -761,9 +759,7 @@ void post_init_entity_util_avg(struct sched_entity *se)
}
}

- update_cfs_rq_load_avg(now, cfs_rq, false);
- attach_entity_load_avg(cfs_rq, se);
- update_tg_load_avg(cfs_rq, false);
+ attach_entity_cfs_rq(se);
}

#else /* !CONFIG_SMP */
@@ -8498,9 +8494,8 @@ static void detach_task_cfs_rq(struct task_struct *p)
update_tg_load_avg(cfs_rq, false);
}

-static void attach_task_cfs_rq(struct task_struct *p)
+static void attach_entity_cfs_rq(struct sched_entity *se)
{
- struct sched_entity *se = &p->se;
struct cfs_rq *cfs_rq = cfs_rq_of(se);
u64 now = cfs_rq_clock_task(cfs_rq);

@@ -8516,6 +8511,14 @@ static void attach_task_cfs_rq(struct task_struct *p)
update_cfs_rq_load_avg(now, cfs_rq, false);
attach_entity_load_avg(cfs_rq, se);
update_tg_load_avg(cfs_rq, false);
+}
+
+static void attach_task_cfs_rq(struct task_struct *p)
+{
+ struct sched_entity *se = &p->se;
+ struct cfs_rq *cfs_rq = cfs_rq_of(se);
+
+ attach_entity_cfs_rq(se);

if (!vruntime_normalized(p))
se->vruntime += cfs_rq->min_vruntime;
--
1.9.1