@@ -450,7 +450,7 @@ static inline int is_leftmost(struct task_struct *p, struct dl_rq *dl_rq)
450450{
451451 struct sched_dl_entity * dl_se = & p -> dl ;
452452
453- return dl_rq -> root . rb_leftmost == & dl_se -> rb_node ;
453+ return rb_first_cached ( & dl_rq -> root ) == & dl_se -> rb_node ;
454454}
455455
456456static void init_dl_rq_bw_ratio (struct dl_rq * dl_rq );
@@ -1433,6 +1433,9 @@ void init_dl_inactive_task_timer(struct sched_dl_entity *dl_se)
14331433 timer -> function = inactive_task_timer ;
14341434}
14351435
1436+ #define __node_2_dle (node ) \
1437+ rb_entry((node), struct sched_dl_entity, rb_node)
1438+
14361439#ifdef CONFIG_SMP
14371440
14381441static void inc_dl_deadline (struct dl_rq * dl_rq , u64 deadline )
@@ -1462,10 +1465,9 @@ static void dec_dl_deadline(struct dl_rq *dl_rq, u64 deadline)
14621465 cpudl_clear (& rq -> rd -> cpudl , rq -> cpu );
14631466 cpupri_set (& rq -> rd -> cpupri , rq -> cpu , rq -> rt .highest_prio .curr );
14641467 } else {
1465- struct rb_node * leftmost = dl_rq -> root . rb_leftmost ;
1466- struct sched_dl_entity * entry ;
1468+ struct rb_node * leftmost = rb_first_cached ( & dl_rq -> root ) ;
1469+ struct sched_dl_entity * entry = __node_2_dle ( leftmost ) ;
14671470
1468- entry = rb_entry (leftmost , struct sched_dl_entity , rb_node );
14691471 dl_rq -> earliest_dl .curr = entry -> deadline ;
14701472 cpudl_set (& rq -> rd -> cpudl , rq -> cpu , entry -> deadline );
14711473 }
@@ -1506,9 +1508,6 @@ void dec_dl_tasks(struct sched_dl_entity *dl_se, struct dl_rq *dl_rq)
15061508 dec_dl_migration (dl_se , dl_rq );
15071509}
15081510
1509- #define __node_2_dle (node ) \
1510- rb_entry((node), struct sched_dl_entity, rb_node)
1511-
15121511static inline bool __dl_less (struct rb_node * a , const struct rb_node * b )
15131512{
15141513 return dl_time_before (__node_2_dle (a )-> deadline , __node_2_dle (b )-> deadline );
@@ -1979,7 +1978,7 @@ static struct sched_dl_entity *pick_next_dl_entity(struct rq *rq,
19791978 if (!left )
19801979 return NULL ;
19811980
1982- return rb_entry (left , struct sched_dl_entity , rb_node );
1981+ return __node_2_dle (left );
19831982}
19841983
19851984static struct task_struct * pick_task_dl (struct rq * rq )
@@ -2074,15 +2073,17 @@ static int pick_dl_task(struct rq *rq, struct task_struct *p, int cpu)
20742073 */
20752074static struct task_struct * pick_earliest_pushable_dl_task (struct rq * rq , int cpu )
20762075{
2077- struct rb_node * next_node = rq -> dl .pushable_dl_tasks_root .rb_leftmost ;
20782076 struct task_struct * p = NULL ;
2077+ struct rb_node * next_node ;
20792078
20802079 if (!has_pushable_dl_tasks (rq ))
20812080 return NULL ;
20822081
2082+ next_node = rb_first_cached (& rq -> dl .pushable_dl_tasks_root );
2083+
20832084next_node :
20842085 if (next_node ) {
2085- p = rb_entry (next_node , struct task_struct , pushable_dl_tasks );
2086+ p = __node_2_pdl (next_node );
20862087
20872088 if (pick_dl_task (rq , p , cpu ))
20882089 return p ;
@@ -2248,8 +2249,7 @@ static struct task_struct *pick_next_pushable_dl_task(struct rq *rq)
22482249 if (!has_pushable_dl_tasks (rq ))
22492250 return NULL ;
22502251
2251- p = rb_entry (rq -> dl .pushable_dl_tasks_root .rb_leftmost ,
2252- struct task_struct , pushable_dl_tasks );
2252+ p = __node_2_pdl (rb_first_cached (& rq -> dl .pushable_dl_tasks_root ));
22532253
22542254 BUG_ON (rq -> cpu != task_cpu (p ));
22552255 BUG_ON (task_current (rq , p ));
0 commit comments