@@ -322,31 +322,20 @@ static inline void list_del_leaf_cfs_rq(struct cfs_rq *cfs_rq)
322322 list_for_each_entry_rcu(cfs_rq, &rq->leaf_cfs_rq_list, leaf_cfs_rq_list)
323323
324324/* Do the two (enqueued) entities belong to the same group ? */
325- static inline int
325+ static inline struct cfs_rq *
326326is_same_group (struct sched_entity * se , struct sched_entity * pse )
327327{
328328 if (se -> cfs_rq == pse -> cfs_rq )
329- return 1 ;
329+ return se -> cfs_rq ;
330330
331- return 0 ;
331+ return NULL ;
332332}
333333
334334static inline struct sched_entity * parent_entity (struct sched_entity * se )
335335{
336336 return se -> parent ;
337337}
338338
339- /* return depth at which a sched entity is present in the hierarchy */
340- static inline int depth_se (struct sched_entity * se )
341- {
342- int depth = 0 ;
343-
344- for_each_sched_entity (se )
345- depth ++ ;
346-
347- return depth ;
348- }
349-
350339static void
351340find_matching_se (struct sched_entity * * se , struct sched_entity * * pse )
352341{
@@ -360,8 +349,8 @@ find_matching_se(struct sched_entity **se, struct sched_entity **pse)
360349 */
361350
362351 /* First walk up until both entities are at same depth */
363- se_depth = depth_se (* se );
364- pse_depth = depth_se (* pse );
352+ se_depth = (* se )-> depth ;
353+ pse_depth = (* pse )-> depth ;
365354
366355 while (se_depth > pse_depth ) {
367356 se_depth -- ;
@@ -426,10 +415,10 @@ static inline void list_del_leaf_cfs_rq(struct cfs_rq *cfs_rq)
426415#define for_each_leaf_cfs_rq (rq , cfs_rq ) \
427416 for (cfs_rq = &rq->cfs; cfs_rq; cfs_rq = NULL)
428417
429- static inline int
418+ static inline struct cfs_rq *
430419is_same_group (struct sched_entity * se , struct sched_entity * pse )
431420{
432- return 1 ;
421+ return cfs_rq_of ( se ); /* always the same rq */
433422}
434423
435424static inline struct sched_entity * parent_entity (struct sched_entity * se )
@@ -7262,7 +7251,9 @@ void init_cfs_rq(struct cfs_rq *cfs_rq)
72627251#ifdef CONFIG_FAIR_GROUP_SCHED
72637252static void task_move_group_fair (struct task_struct * p , int on_rq )
72647253{
7254+ struct sched_entity * se = & p -> se ;
72657255 struct cfs_rq * cfs_rq ;
7256+
72667257 /*
72677258 * If the task was not on the rq at the time of this cgroup movement
72687259 * it must have been asleep, sleeping tasks keep their ->vruntime
@@ -7288,23 +7279,24 @@ static void task_move_group_fair(struct task_struct *p, int on_rq)
72887279 * To prevent boost or penalty in the new cfs_rq caused by delta
72897280 * min_vruntime between the two cfs_rqs, we skip vruntime adjustment.
72907281 */
7291- if (!on_rq && (!p -> se . sum_exec_runtime || p -> state == TASK_WAKING ))
7282+ if (!on_rq && (!se -> sum_exec_runtime || p -> state == TASK_WAKING ))
72927283 on_rq = 1 ;
72937284
72947285 if (!on_rq )
7295- p -> se . vruntime -= cfs_rq_of (& p -> se )-> min_vruntime ;
7286+ se -> vruntime -= cfs_rq_of (se )-> min_vruntime ;
72967287 set_task_rq (p , task_cpu (p ));
7288+ se -> depth = se -> parent ? se -> parent -> depth + 1 : 0 ;
72977289 if (!on_rq ) {
7298- cfs_rq = cfs_rq_of (& p -> se );
7299- p -> se . vruntime += cfs_rq -> min_vruntime ;
7290+ cfs_rq = cfs_rq_of (se );
7291+ se -> vruntime += cfs_rq -> min_vruntime ;
73007292#ifdef CONFIG_SMP
73017293 /*
73027294 * migrate_task_rq_fair() will have removed our previous
73037295 * contribution, but we must synchronize for ongoing future
73047296 * decay.
73057297 */
7306- p -> se . avg .decay_count = atomic64_read (& cfs_rq -> decay_counter );
7307- cfs_rq -> blocked_load_avg += p -> se . avg .load_avg_contrib ;
7298+ se -> avg .decay_count = atomic64_read (& cfs_rq -> decay_counter );
7299+ cfs_rq -> blocked_load_avg += se -> avg .load_avg_contrib ;
73087300#endif
73097301 }
73107302}
@@ -7400,10 +7392,13 @@ void init_tg_cfs_entry(struct task_group *tg, struct cfs_rq *cfs_rq,
74007392 if (!se )
74017393 return ;
74027394
7403- if (!parent )
7395+ if (!parent ) {
74047396 se -> cfs_rq = & rq -> cfs ;
7405- else
7397+ se -> depth = 0 ;
7398+ } else {
74067399 se -> cfs_rq = parent -> my_q ;
7400+ se -> depth = parent -> depth + 1 ;
7401+ }
74077402
74087403 se -> my_q = cfs_rq ;
74097404 /* guarantee group entities always have weight */
0 commit comments