sched: deadline: Simplify pick_earliest_pushable_dl_task()

Message ID 20230530181145.2880-1-kunyu@nfschina.com
State New
Headers
Series sched: deadline: Simplify pick_earliest_pushable_dl_task() |

Commit Message

Li kunyu May 30, 2023, 6:11 p.m. UTC
  Using the while statement instead of the if and goto statements is more
concise and efficient.

Signed-off-by: Li kunyu <kunyu@nfschina.com>
---
 kernel/sched/deadline.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
  

Comments

Mukesh Ojha May 29, 2023, 6:29 a.m. UTC | #1
On 5/30/2023 11:41 PM, Li kunyu wrote:
> Using the while statement instead of the if and goto statements is more
> concise and efficient.
> 
> Signed-off-by: Li kunyu <kunyu@nfschina.com>

LGTM, Thanks.
Reviewed-by: Mukesh Ojha <quic_mojha@quicinc.com>

-- Mukesh

> ---
>   kernel/sched/deadline.c | 4 +---
>   1 file changed, 1 insertion(+), 3 deletions(-)
> 
> diff --git a/kernel/sched/deadline.c b/kernel/sched/deadline.c
> index d823e608c7f0..b94a498f8cd9 100644
> --- a/kernel/sched/deadline.c
> +++ b/kernel/sched/deadline.c
> @@ -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;
  

Patch

diff --git a/kernel/sched/deadline.c b/kernel/sched/deadline.c
index d823e608c7f0..b94a498f8cd9 100644
--- a/kernel/sched/deadline.c
+++ b/kernel/sched/deadline.c
@@ -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;