Just like init_tg_cfs_entry() does something useful without a scheduling
entity, let it do something useful without a CFS runqueue.

This prepares for the addition of new types of SEs.

Signed-off-by: Jan H. Schönherr <jscho...@amazon.de>
---
 kernel/sched/fair.c | 28 +++++++++++++++-------------
 1 file changed, 15 insertions(+), 13 deletions(-)

diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index 2b3fd7cd9fde..bccd7a66858e 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -9903,21 +9903,23 @@ void init_tg_cfs_entry(struct task_group *tg, struct 
cfs_rq *cfs_rq,
                       struct sched_entity *se, struct rq *rq,
                       struct cfs_rq *parent)
 {
-       cfs_rq->tg = tg;
-       cfs_rq->rq = rq;
-       cfs_rq->my_se = se;
-       init_cfs_rq_runtime(cfs_rq);
-
-       /* se could be NULL for root_task_group */
-       if (!se)
-               return;
+       /* cfs_rq may be NULL for certain types of SE */
+       if (cfs_rq) {
+               cfs_rq->tg = tg;
+               cfs_rq->rq = rq;
+               cfs_rq->my_se = se;
+               init_cfs_rq_runtime(cfs_rq);
+       }
 
-       set_entity_cfs(se, parent);
-       se->my_q = cfs_rq;
+       /* se is NULL for root_task_group */
+       if (se) {
+               set_entity_cfs(se, parent);
+               se->my_q = cfs_rq;
 
-       /* guarantee group entities always have weight */
-       update_load_set(&se->load, NICE_0_LOAD);
-       init_entity_runnable_average(se);
+               /* guarantee group entities always have weight */
+               update_load_set(&se->load, NICE_0_LOAD);
+               init_entity_runnable_average(se);
+       }
 }
 
 static DEFINE_MUTEX(shares_mutex);
-- 
2.9.3.1.gcba166c.dirty

Reply via email to