@@ -450,7 +450,7 @@ static inline int is_leftmost(struct task_struct *p, struct dl_rq *dl_rq)
450
450
{
451
451
struct sched_dl_entity * dl_se = & p -> dl ;
452
452
453
- return dl_rq -> root . rb_leftmost == & dl_se -> rb_node ;
453
+ return rb_first_cached ( & dl_rq -> root ) == & dl_se -> rb_node ;
454
454
}
455
455
456
456
static 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)
1433
1433
timer -> function = inactive_task_timer ;
1434
1434
}
1435
1435
1436
+ #define __node_2_dle (node ) \
1437
+ rb_entry((node), struct sched_dl_entity, rb_node)
1438
+
1436
1439
#ifdef CONFIG_SMP
1437
1440
1438
1441
static 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)
1462
1465
cpudl_clear (& rq -> rd -> cpudl , rq -> cpu );
1463
1466
cpupri_set (& rq -> rd -> cpupri , rq -> cpu , rq -> rt .highest_prio .curr );
1464
1467
} 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 ) ;
1467
1470
1468
- entry = rb_entry (leftmost , struct sched_dl_entity , rb_node );
1469
1471
dl_rq -> earliest_dl .curr = entry -> deadline ;
1470
1472
cpudl_set (& rq -> rd -> cpudl , rq -> cpu , entry -> deadline );
1471
1473
}
@@ -1506,9 +1508,6 @@ void dec_dl_tasks(struct sched_dl_entity *dl_se, struct dl_rq *dl_rq)
1506
1508
dec_dl_migration (dl_se , dl_rq );
1507
1509
}
1508
1510
1509
- #define __node_2_dle (node ) \
1510
- rb_entry((node), struct sched_dl_entity, rb_node)
1511
-
1512
1511
static inline bool __dl_less (struct rb_node * a , const struct rb_node * b )
1513
1512
{
1514
1513
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,
1979
1978
if (!left )
1980
1979
return NULL ;
1981
1980
1982
- return rb_entry (left , struct sched_dl_entity , rb_node );
1981
+ return __node_2_dle (left );
1983
1982
}
1984
1983
1985
1984
static 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)
2074
2073
*/
2075
2074
static struct task_struct * pick_earliest_pushable_dl_task (struct rq * rq , int cpu )
2076
2075
{
2077
- struct rb_node * next_node = rq -> dl .pushable_dl_tasks_root .rb_leftmost ;
2078
2076
struct task_struct * p = NULL ;
2077
+ struct rb_node * next_node ;
2079
2078
2080
2079
if (!has_pushable_dl_tasks (rq ))
2081
2080
return NULL ;
2082
2081
2082
+ next_node = rb_first_cached (& rq -> dl .pushable_dl_tasks_root );
2083
+
2083
2084
next_node :
2084
2085
if (next_node ) {
2085
- p = rb_entry (next_node , struct task_struct , pushable_dl_tasks );
2086
+ p = __node_2_pdl (next_node );
2086
2087
2087
2088
if (pick_dl_task (rq , p , cpu ))
2088
2089
return p ;
@@ -2248,8 +2249,7 @@ static struct task_struct *pick_next_pushable_dl_task(struct rq *rq)
2248
2249
if (!has_pushable_dl_tasks (rq ))
2249
2250
return NULL ;
2250
2251
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 ));
2253
2253
2254
2254
BUG_ON (rq -> cpu != task_cpu (p ));
2255
2255
BUG_ON (task_current (rq , p ));
0 commit comments