Skip to contentSkip to conversation

sched/rt.c remove unnecessary parameter in pick_next_rt_entity

PATCH In review Hui Su 2 participants 2 messages Sep 29, 2020 – Sep 30, 2020 Scheduler

lore
Share & tools
lore

Hui Su

author
#0 lore raw

PATCH 1/1 sched/rt.c remove unnecessary parameter in pick_next_rt_entity

struct rq is not necessary for pick_next_rt_entity(), we can get next sched_rt_entity just from struct rt_rq.

---
 kernel/sched/rt.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)
kernel/sched/rt.c +3 -6
index f215eea6a966..113965e1952c 100644
@@ -1593,11 +1593,9 @@ static inline void set_next_task_rt(struct rq *rq, struct task_struct *p, bool f
 	rt_queue_push_tasks(rq);
 }
 
-static struct sched_rt_entity *pick_next_rt_entity(struct rq *rq,
-						   struct rt_rq *rt_rq)
+static struct sched_rt_entity *pick_next_rt_entity(struct rt_rq *rt_rq)
 {
 	struct rt_prio_array *array = &rt_rq->active;
-	struct sched_rt_entity *next = NULL;
 	struct list_head *queue;
 	int idx;
 
@@ -1605,9 +1603,8 @@ static struct sched_rt_entity *pick_next_rt_entity(struct rq *rq,
 	BUG_ON(idx >= MAX_RT_PRIO);
 
 	queue = array->queue + idx;
-	next = list_entry(queue->next, struct sched_rt_entity, run_list);
 
-	return next;
+	return list_entry(queue->next, struct sched_rt_entity, run_list);
 }
 
 static struct task_struct *_pick_next_task_rt(struct rq *rq)
@@ -1616,7 +1613,7 @@ static struct task_struct *_pick_next_task_rt(struct rq *rq)
 	struct rt_rq *rt_rq  = &rq->rt;
 
 	do {
-		rt_se = pick_next_rt_entity(rq, rt_rq);
+		rt_se = pick_next_rt_entity(rt_rq);
 		BUG_ON(!rt_se);
 		rt_rq = group_rt_rq(rt_se);
 	} while (rt_rq);
Signature · 1 line
2.25.1
reviewer Reviewed-by on v1 1/1
#1 lore raw
Quoted 26 lines · On Wed, 30 Sep 2020 00:56:40 +0800 Hui Su <[email protected]> wrote:

struct rq is not necessary for pick_next_rt_entity(), we can get next sched_rt_entity just from struct rt_rq.

---
 kernel/sched/rt.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)
kernel/sched/rt.c +1 -3
index f215eea6a966..113965e1952c 100644
@@ -1593,11 +1593,9 @@ static inline void set_next_task_rt(struct rq *rq, struct task_struct *p, bool f
 	rt_queue_push_tasks(rq);
 }
 
-static struct sched_rt_entity *pick_next_rt_entity(struct rq *rq,
-						   struct rt_rq *rt_rq)
+static struct sched_rt_entity *pick_next_rt_entity(struct rt_rq *rt_rq)
 {
 	struct rt_prio_array *array = &rt_rq->active;
-	struct sched_rt_entity *next = NULL;
 	struct list_head *queue;
 	int idx;
 

kernel/sched/rt.c static struct sched_rt_entity *pick_next_rt_entity(struct rq *rq, · line 1607

Quoted 7 lines
kernel/sched/rt.c +1 -2
@@ -1605,9 +1603,8 @@ static struct sched_rt_entity *pick_next_rt_entity(struct rq *rq,
 	BUG_ON(idx >= MAX_RT_PRIO);
 
 	queue = array->queue + idx;
-	next = list_entry(queue->next, struct sched_rt_entity, run_list);
 
-	return next;
+	return list_entry(queue->next, struct sched_rt_entity, run_list);

The above code looks to be left over from a time that there was a goto out; with out: being between the next = list_etry() and the return next. This was removed back in 2008 with commit 326587b84078 ("sched:
fix goto retry in pick_next_task_rt()").

The above looks fine to me.

-- Steve

Quoted 12 lines
kernel/sched/rt.c +1 -1
 }
 
 static struct task_struct *_pick_next_task_rt(struct rq *rq)
@@ -1616,7 +1613,7 @@ static struct task_struct *_pick_next_task_rt(struct rq *rq)
 	struct rt_rq *rt_rq  = &rq->rt;
 
 	do {
-		rt_se = pick_next_rt_entity(rq, rt_rq);
+		rt_se = pick_next_rt_entity(rt_rq);
 		BUG_ON(!rt_se);
 		rt_rq = group_rt_rq(rt_se);
 	} while (rt_rq);