Skip to contentSkip to conversation

sched: deadline: Simplify pick_earliest_pushable_dl_task()

PATCH In review Li kunyu 2 participants 2 messages May 29, 2023 Scheduler

lore
Share & tools
lore

Li kunyu

author
#0 lore raw

PATCH 1/1 sched: deadline: Simplify pick_earliest_pushable_dl_task()

Using the while statement instead of the if and goto statements is more concise and efficient.

---
 kernel/sched/deadline.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
kernel/sched/deadline.c +1 -3
index d823e608c7f0..b94a498f8cd9 100644
@@ -2112,15 +2112,13 @@ static struct task_struct *pick_earliest_pushable_dl_task(struct rq *rq, int cpu
 
 	next_node = rb_first_cached(&rq->dl.pushable_dl_tasks_root);
 
-next_node:
-	if (next_node) {
+	while (next_node) {
 		p = __node_2_pdl(next_node);
 
 		if (pick_dl_task(rq, p, cpu))
 			return p;
 
 		next_node = rb_next(next_node);
-		goto next_node;
 	}
 
 	return NULL;
Signature · 1 line
2.18.2
Reviewed-by on v1 1/1
#1 lore raw
Quoted 4 lines · Li kunyu

Using the while statement instead of the if and goto statements is more concise and efficient.

LGTM, Thanks.

-- Mukesh

Quoted 25 lines
---
  kernel/sched/deadline.c | 4 +---
  1 file changed, 1 insertion(+), 3 deletions(-)
kernel/sched/deadline.c +1 -3
index d823e608c7f0..b94a498f8cd9 100644
@@ -2112,15 +2112,13 @@ static struct task_struct *pick_earliest_pushable_dl_task(struct rq *rq, int cpu
 
  	next_node = rb_first_cached(&rq->dl.pushable_dl_tasks_root);
 
-next_node:
-	if (next_node) {
+	while (next_node) {
  		p = __node_2_pdl(next_node);
 
  		if (pick_dl_task(rq, p, cpu))
  			return p;
 
  		next_node = rb_next(next_node);
-		goto next_node;
  	}
 
  	return NULL;