2024-01-15 05:02:43

by Liu Song

[permalink] [raw]
Subject: [PATCH] sched/eevdf: using leftmost improves the readability of the code

Using 'leftmost' enhances code readability, without involving any logical
changes.

Signed-off-by: Liu Song <[email protected]>
---
kernel/sched/fair.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index f2bb83675e4a..4247584258ae 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -848,12 +848,12 @@ struct sched_entity *__pick_root_entity(struct cfs_rq *cfs_rq)

struct sched_entity *__pick_first_entity(struct cfs_rq *cfs_rq)
{
- struct rb_node *left = rb_first_cached(&cfs_rq->tasks_timeline);
+ struct rb_node *leftmost = rb_first_cached(&cfs_rq->tasks_timeline);

- if (!left)
+ if (!leftmost)
return NULL;

- return __node_2_se(left);
+ return __node_2_se(leftmost);
}

/*
--
2.19.1.6.gb485710b



2024-01-15 07:41:49

by Mike Galbraith

[permalink] [raw]
Subject: Re: [PATCH] sched/eevdf: using leftmost improves the readability of the code

On Mon, 2024-01-15 at 12:46 +0800, Liu Song wrote:
> Using 'leftmost' enhances code readability..

Not even a little bit, it's already blatantly obvious at a glance.

> Signed-off-by: Liu Song <[email protected]>
> ---
>  kernel/sched/fair.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
> index f2bb83675e4a..4247584258ae 100644
> --- a/kernel/sched/fair.c
> +++ b/kernel/sched/fair.c
> @@ -848,12 +848,12 @@ struct sched_entity *__pick_root_entity(struct cfs_rq *cfs_rq)
>  
>  struct sched_entity *__pick_first_entity(struct cfs_rq *cfs_rq)
>  {
> -       struct rb_node *left = rb_first_cached(&cfs_rq->tasks_timeline);
> +       struct rb_node *leftmost = rb_first_cached(&cfs_rq->tasks_timeline);
>  
> -       if (!left)
> +       if (!leftmost)
>                 return NULL;
>  
> -       return __node_2_se(left);
> +       return __node_2_se(leftmost);
>  }
>  
>  /*