[PATCH] sched/core: Combine separate 'else' and 'if' statements

luoliang@kylinos.cn posted 1 patch 4 days, 9 hours ago
kernel/sched/core.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
[PATCH] sched/core: Combine separate 'else' and 'if' statements
Posted by luoliang@kylinos.cn 4 days, 9 hours ago
From: Liang Luo <luoliang@kylinos.cn>

The kernel coding style recommends using 'else if' instead of
placing 'if' on a separate line after 'else'. This change makes
the code consistent with the rest of the kernel codebase.

Signed-off-by: Liang Luo <luoliang@kylinos.cn>
---
 kernel/sched/core.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index da20fb6ea25a..c2bf0fc6ac97 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -3716,8 +3716,7 @@ ttwu_do_activate(struct rq *rq, struct task_struct *p, int wake_flags,
 		en_flags |= ENQUEUE_RQ_SELECTED;
 	if (wake_flags & WF_MIGRATED)
 		en_flags |= ENQUEUE_MIGRATED;
-	else
-	if (p->in_iowait) {
+	else if (p->in_iowait) {
 		delayacct_blkio_end(p);
 		atomic_dec(&task_rq(p)->nr_iowait);
 	}
--
2.45.0
Re: [PATCH] sched/core: Combine separate 'else' and 'if' statements
Posted by Peter Zijlstra 4 days, 9 hours ago
On Mon, Jun 08, 2026 at 03:18:42PM +0800, luoliang@kylinos.cn wrote:
> From: Liang Luo <luoliang@kylinos.cn>
> 
> The kernel coding style recommends using 'else if' instead of
> placing 'if' on a separate line after 'else'. This change makes
> the code consistent with the rest of the kernel codebase.

Right, this is because the things used to be inside #ifdef CONFIG_SMP.

I did notice it a few times, but I generally don't bother with
trivialities like this until the code needs touching for other reasons.

But I suppose since you took the effort, I might as well apply this. But
please don't go whitespace fixing the scheduler code.

> Signed-off-by: Liang Luo <luoliang@kylinos.cn>
> ---
>  kernel/sched/core.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/kernel/sched/core.c b/kernel/sched/core.c
> index da20fb6ea25a..c2bf0fc6ac97 100644
> --- a/kernel/sched/core.c
> +++ b/kernel/sched/core.c
> @@ -3716,8 +3716,7 @@ ttwu_do_activate(struct rq *rq, struct task_struct *p, int wake_flags,
>  		en_flags |= ENQUEUE_RQ_SELECTED;
>  	if (wake_flags & WF_MIGRATED)
>  		en_flags |= ENQUEUE_MIGRATED;
> -	else
> -	if (p->in_iowait) {
> +	else if (p->in_iowait) {
>  		delayacct_blkio_end(p);
>  		atomic_dec(&task_rq(p)->nr_iowait);
>  	}
> --
> 2.45.0
[tip: sched/core] sched/core: Combine separate 'else' and 'if' statements
Posted by tip-bot2 for Liang Luo 3 days, 8 hours ago
The following commit has been merged into the sched/core branch of tip:

Commit-ID:     76124a050ddbc8b252172205ab04f10a83c03a4d
Gitweb:        https://git.kernel.org/tip/76124a050ddbc8b252172205ab04f10a83c03a4d
Author:        Liang Luo <luoliang@kylinos.cn>
AuthorDate:    Mon, 08 Jun 2026 15:18:42 +08:00
Committer:     Peter Zijlstra <peterz@infradead.org>
CommitterDate: Tue, 09 Jun 2026 10:28:08 +02:00

sched/core: Combine separate 'else' and 'if' statements

The kernel coding style recommends using 'else if' instead of
placing 'if' on a separate line after 'else'. This change makes
the code consistent with the rest of the kernel codebase.

Signed-off-by: Liang Luo <luoliang@kylinos.cn>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Link: https://patch.msgid.link/20260608071842.325159-1-luoliang@kylinos.cn
---
 kernel/sched/core.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index e745c58..2f4530e 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -3816,8 +3816,7 @@ ttwu_do_activate(struct rq *rq, struct task_struct *p, int wake_flags,
 		en_flags |= ENQUEUE_RQ_SELECTED;
 	if (wake_flags & WF_MIGRATED)
 		en_flags |= ENQUEUE_MIGRATED;
-	else
-	if (p->in_iowait) {
+	else if (p->in_iowait) {
 		delayacct_blkio_end(p);
 		atomic_dec(&task_rq(p)->nr_iowait);
 	}