* [RFC][PATCH] sched: deadline: Remove unnecessary goto label in pick_earliest_pushable_dl_task
@ 2024-12-05 21:16 John Stultz
2024-12-05 21:23 ` Christophe JAILLET
2024-12-05 23:59 ` [PATCH v2] sched: deadline: Cleanup " John Stultz
0 siblings, 2 replies; 9+ messages in thread
From: John Stultz @ 2024-12-05 21:16 UTC (permalink / raw)
To: LKML
Cc: John Stultz, Ingo Molnar, Peter Zijlstra, Juri Lelli,
Vincent Guittot, Dietmar Eggemann, Steven Rostedt, Ben Segall,
Mel Gorman, Valentin Schneider, Wanpeng Li, Todd Kjos,
kernel-team
Commit 8b5e770ed7c0 ("sched/deadline: Optimize pull_dl_task()")
added an odd goto label that seems to be unnecssary, given its
called unconditionally from the bottom of a while loop and the
label is at the top.
Thus, clean it up and remove the label/goto.
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Juri Lelli <juri.lelli@redhat.com>
Cc: Vincent Guittot <vincent.guittot@linaro.org>
Cc: Dietmar Eggemann <dietmar.eggemann@arm.com>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Ben Segall <bsegall@google.com>
Cc: Mel Gorman <mgorman@suse.de>
Cc: Valentin Schneider <vschneid@redhat.com>
Cc: Wanpeng Li <wanpeng.li@linux.intel.com>
Cc: Todd Kjos <tkjos@google.com>
Cc: kernel-team@android.com
Fixes: 8b5e770ed7c0 ("sched/deadline: Optimize pull_dl_task()")
Reported-by: Todd Kjos <tkjos@google.com>
Signed-off-by: John Stultz <jstultz@google.com>
---
kernel/sched/deadline.c | 3 ---
1 file changed, 3 deletions(-)
diff --git a/kernel/sched/deadline.c b/kernel/sched/deadline.c
index d9d5a702f1a61..566a05efa4e57 100644
--- a/kernel/sched/deadline.c
+++ b/kernel/sched/deadline.c
@@ -2501,8 +2501,6 @@ static struct task_struct *pick_earliest_pushable_dl_task(struct rq *rq, int cpu
return NULL;
next_node = rb_first_cached(&rq->dl.pushable_dl_tasks_root);
-
-next_node:
if (next_node) {
p = __node_2_pdl(next_node);
@@ -2510,7 +2508,6 @@ static struct task_struct *pick_earliest_pushable_dl_task(struct rq *rq, int cpu
return p;
next_node = rb_next(next_node);
- goto next_node;
}
return NULL;
--
2.47.0.338.g60cca15819-goog
^ permalink raw reply related [flat|nested] 9+ messages in thread* Re: [RFC][PATCH] sched: deadline: Remove unnecessary goto label in pick_earliest_pushable_dl_task 2024-12-05 21:16 [RFC][PATCH] sched: deadline: Remove unnecessary goto label in pick_earliest_pushable_dl_task John Stultz @ 2024-12-05 21:23 ` Christophe JAILLET 2024-12-05 21:23 ` Christophe JAILLET 2024-12-05 21:47 ` John Stultz 2024-12-05 23:59 ` [PATCH v2] sched: deadline: Cleanup " John Stultz 1 sibling, 2 replies; 9+ messages in thread From: Christophe JAILLET @ 2024-12-05 21:23 UTC (permalink / raw) To: linux-kernel Cc: Ingo Molnar, Peter Zijlstra, Juri Lelli, Vincent Guittot, Dietmar Eggemann, Steven Rostedt, Ben Segall, Mel Gorman, Valentin Schneider, Wanpeng Li, Todd Kjos, kernel-team Le 05/12/2024 à 22:16, John Stultz a écrit : > Commit 8b5e770ed7c0 ("sched/deadline: Optimize pull_dl_task()") > added an odd goto label that seems to be unnecssary, given its s/unnecssary/unnecessary/ > called unconditionally from the bottom of a while loop and the > label is at the top. Except that it is not a while loop, but only an if. Maybe, changing this if into a while would save a few lines of code and be more readable as-well. CJ > > Thus, clean it up and remove the label/goto. > > Cc: Ingo Molnar <mingo@redhat.com> > Cc: Peter Zijlstra <peterz@infradead.org> > Cc: Juri Lelli <juri.lelli@redhat.com> > Cc: Vincent Guittot <vincent.guittot@linaro.org> > Cc: Dietmar Eggemann <dietmar.eggemann@arm.com> > Cc: Steven Rostedt <rostedt@goodmis.org> > Cc: Ben Segall <bsegall@google.com> > Cc: Mel Gorman <mgorman@suse.de> > Cc: Valentin Schneider <vschneid@redhat.com> > Cc: Wanpeng Li <wanpeng.li@linux.intel.com> > Cc: Todd Kjos <tkjos@google.com> > Cc: kernel-team@android.com > Fixes: 8b5e770ed7c0 ("sched/deadline: Optimize pull_dl_task()") > Reported-by: Todd Kjos <tkjos@google.com> > Signed-off-by: John Stultz <jstultz@google.com> > --- > kernel/sched/deadline.c | 3 --- > 1 file changed, 3 deletions(-) > > diff --git a/kernel/sched/deadline.c b/kernel/sched/deadline.c > index d9d5a702f1a61..566a05efa4e57 100644 > --- a/kernel/sched/deadline.c > +++ b/kernel/sched/deadline.c > @@ -2501,8 +2501,6 @@ static struct task_struct *pick_earliest_pushable_dl_task(struct rq *rq, int cpu > return NULL; > > next_node = rb_first_cached(&rq->dl.pushable_dl_tasks_root); > - > -next_node: > if (next_node) { > p = __node_2_pdl(next_node); > > @@ -2510,7 +2508,6 @@ static struct task_struct *pick_earliest_pushable_dl_task(struct rq *rq, int cpu > return p; > > next_node = rb_next(next_node); > - goto next_node; > } > > return NULL; ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [RFC][PATCH] sched: deadline: Remove unnecessary goto label in pick_earliest_pushable_dl_task 2024-12-05 21:23 ` Christophe JAILLET @ 2024-12-05 21:23 ` Christophe JAILLET 2024-12-05 21:47 ` John Stultz 1 sibling, 0 replies; 9+ messages in thread From: Christophe JAILLET @ 2024-12-05 21:23 UTC (permalink / raw) To: John Stultz, LKML Cc: Ingo Molnar, Peter Zijlstra, Juri Lelli, Vincent Guittot, Dietmar Eggemann, Steven Rostedt, Ben Segall, Mel Gorman, Valentin Schneider, Wanpeng Li, Todd Kjos, kernel-team Le 05/12/2024 à 22:16, John Stultz a écrit : > Commit 8b5e770ed7c0 ("sched/deadline: Optimize pull_dl_task()") > added an odd goto label that seems to be unnecssary, given its s/unnecssary/unnecessary/ > called unconditionally from the bottom of a while loop and the > label is at the top. Except that it is not a while loop, but only an if. Maybe, changing this if into a while would save a few lines of code and be more readable as-well. CJ > > Thus, clean it up and remove the label/goto. > > Cc: Ingo Molnar <mingo@redhat.com> > Cc: Peter Zijlstra <peterz@infradead.org> > Cc: Juri Lelli <juri.lelli@redhat.com> > Cc: Vincent Guittot <vincent.guittot@linaro.org> > Cc: Dietmar Eggemann <dietmar.eggemann@arm.com> > Cc: Steven Rostedt <rostedt@goodmis.org> > Cc: Ben Segall <bsegall@google.com> > Cc: Mel Gorman <mgorman@suse.de> > Cc: Valentin Schneider <vschneid@redhat.com> > Cc: Wanpeng Li <wanpeng.li@linux.intel.com> > Cc: Todd Kjos <tkjos@google.com> > Cc: kernel-team@android.com > Fixes: 8b5e770ed7c0 ("sched/deadline: Optimize pull_dl_task()") > Reported-by: Todd Kjos <tkjos@google.com> > Signed-off-by: John Stultz <jstultz@google.com> > --- > kernel/sched/deadline.c | 3 --- > 1 file changed, 3 deletions(-) > > diff --git a/kernel/sched/deadline.c b/kernel/sched/deadline.c > index d9d5a702f1a61..566a05efa4e57 100644 > --- a/kernel/sched/deadline.c > +++ b/kernel/sched/deadline.c > @@ -2501,8 +2501,6 @@ static struct task_struct *pick_earliest_pushable_dl_task(struct rq *rq, int cpu > return NULL; > > next_node = rb_first_cached(&rq->dl.pushable_dl_tasks_root); > - > -next_node: > if (next_node) { > p = __node_2_pdl(next_node); > > @@ -2510,7 +2508,6 @@ static struct task_struct *pick_earliest_pushable_dl_task(struct rq *rq, int cpu > return p; > > next_node = rb_next(next_node); > - goto next_node; > } > > return NULL; ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [RFC][PATCH] sched: deadline: Remove unnecessary goto label in pick_earliest_pushable_dl_task 2024-12-05 21:23 ` Christophe JAILLET 2024-12-05 21:23 ` Christophe JAILLET @ 2024-12-05 21:47 ` John Stultz 1 sibling, 0 replies; 9+ messages in thread From: John Stultz @ 2024-12-05 21:47 UTC (permalink / raw) To: Christophe JAILLET Cc: LKML, Ingo Molnar, Peter Zijlstra, Juri Lelli, Vincent Guittot, Dietmar Eggemann, Steven Rostedt, Ben Segall, Mel Gorman, Valentin Schneider, Wanpeng Li, Todd Kjos, kernel-team On Thu, Dec 5, 2024 at 1:23 PM Christophe JAILLET <christophe.jaillet@wanadoo.fr> wrote: > > Le 05/12/2024 à 22:16, John Stultz a écrit : > > Commit 8b5e770ed7c0 ("sched/deadline: Optimize pull_dl_task()") > > added an odd goto label that seems to be unnecssary, given its > > s/unnecssary/unnecessary/ > > > called unconditionally from the bottom of a while loop and the > > label is at the top. > > Except that it is not a while loop, but only an if. Ah! Apologies. I need to get my eyes checked. :P Thank you for catching me there. > Maybe, changing this if into a while would save a few lines of code and > be more readable as-well. Yeah, Todd pointed out the unconventional usage, but my brain mis-read the code as being a while(). I'll resend with that change. thanks -john ^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH v2] sched: deadline: Cleanup goto label in pick_earliest_pushable_dl_task 2024-12-05 21:16 [RFC][PATCH] sched: deadline: Remove unnecessary goto label in pick_earliest_pushable_dl_task John Stultz 2024-12-05 21:23 ` Christophe JAILLET @ 2024-12-05 23:59 ` John Stultz 2024-12-06 8:14 ` K Prateek Nayak ` (3 more replies) 1 sibling, 4 replies; 9+ messages in thread From: John Stultz @ 2024-12-05 23:59 UTC (permalink / raw) To: LKML Cc: John Stultz, Ingo Molnar, Peter Zijlstra, Juri Lelli, Vincent Guittot, Dietmar Eggemann, Steven Rostedt, Ben Segall, Mel Gorman, Valentin Schneider, Wanpeng Li, Christophe JAILLET, Todd Kjos, kernel-team Commit 8b5e770ed7c0 ("sched/deadline: Optimize pull_dl_task()") added a goto label seems would be better written as a while loop. So replace the goto with a while loop, to make it easier to read. Cc: Ingo Molnar <mingo@redhat.com> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Juri Lelli <juri.lelli@redhat.com> Cc: Vincent Guittot <vincent.guittot@linaro.org> Cc: Dietmar Eggemann <dietmar.eggemann@arm.com> Cc: Steven Rostedt <rostedt@goodmis.org> Cc: Ben Segall <bsegall@google.com> Cc: Mel Gorman <mgorman@suse.de> Cc: Valentin Schneider <vschneid@redhat.com> Cc: Wanpeng Li <wanpeng.li@linux.intel.com> Cc: Christophe JAILLET <christophe.jaillet@wanadoo.fr> Cc: Todd Kjos <tkjos@google.com> Cc: kernel-team@android.com Reported-by: Todd Kjos <tkjos@google.com> Signed-off-by: John Stultz <jstultz@google.com> --- v2: * Corrects my misreading of the code (as pointed out by Christophe JAILLET) as already having a while loop, and switches the if to a while. --- kernel/sched/deadline.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/kernel/sched/deadline.c b/kernel/sched/deadline.c index d9d5a702f1a61..b2cc71984176a 100644 --- a/kernel/sched/deadline.c +++ b/kernel/sched/deadline.c @@ -2501,16 +2501,13 @@ static struct task_struct *pick_earliest_pushable_dl_task(struct rq *rq, int cpu return NULL; 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 (task_is_pushable(rq, p, cpu)) return p; next_node = rb_next(next_node); - goto next_node; } return NULL; -- 2.47.0.338.g60cca15819-goog ^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH v2] sched: deadline: Cleanup goto label in pick_earliest_pushable_dl_task 2024-12-05 23:59 ` [PATCH v2] sched: deadline: Cleanup " John Stultz @ 2024-12-06 8:14 ` K Prateek Nayak 2024-12-09 11:44 ` Juri Lelli ` (2 subsequent siblings) 3 siblings, 0 replies; 9+ messages in thread From: K Prateek Nayak @ 2024-12-06 8:14 UTC (permalink / raw) To: John Stultz Cc: Ingo Molnar, Peter Zijlstra, Juri Lelli, Vincent Guittot, Dietmar Eggemann, Steven Rostedt, Ben Segall, Mel Gorman, Valentin Schneider, Wanpeng Li, Christophe JAILLET, Todd Kjos, kernel-team, LKML Hello John, On 12/6/2024 5:29 AM, John Stultz wrote: > Commit 8b5e770ed7c0 ("sched/deadline: Optimize pull_dl_task()") > added a goto label seems would be better written as a while > loop. > > So replace the goto with a while loop, to make it easier to read. > > Cc: Ingo Molnar <mingo@redhat.com> > Cc: Peter Zijlstra <peterz@infradead.org> > Cc: Juri Lelli <juri.lelli@redhat.com> > Cc: Vincent Guittot <vincent.guittot@linaro.org> > Cc: Dietmar Eggemann <dietmar.eggemann@arm.com> > Cc: Steven Rostedt <rostedt@goodmis.org> > Cc: Ben Segall <bsegall@google.com> > Cc: Mel Gorman <mgorman@suse.de> > Cc: Valentin Schneider <vschneid@redhat.com> > Cc: Wanpeng Li <wanpeng.li@linux.intel.com> > Cc: Christophe JAILLET <christophe.jaillet@wanadoo.fr> > Cc: Todd Kjos <tkjos@google.com> > Cc: kernel-team@android.com > Reported-by: Todd Kjos <tkjos@google.com> > Signed-off-by: John Stultz <jstultz@google.com> Gave it a spin on my box. Feel free to add: Reviewed-and-tested-by: K Prateek Nayak <kprateek.nayak@amd.com> -- Thanks and Regards, Prateek > --- > v2: > * Corrects my misreading of the code (as pointed out by Christophe > JAILLET) as already having a while loop, and switches the if to > a while. > --- > kernel/sched/deadline.c | 5 +---- > 1 file changed, 1 insertion(+), 4 deletions(-) > > diff --git a/kernel/sched/deadline.c b/kernel/sched/deadline.c > index d9d5a702f1a61..b2cc71984176a 100644 > --- a/kernel/sched/deadline.c > +++ b/kernel/sched/deadline.c > @@ -2501,16 +2501,13 @@ static struct task_struct *pick_earliest_pushable_dl_task(struct rq *rq, int cpu > return NULL; > > 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 (task_is_pushable(rq, p, cpu)) > return p; > > next_node = rb_next(next_node); > - goto next_node; > } > > return NULL; ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v2] sched: deadline: Cleanup goto label in pick_earliest_pushable_dl_task 2024-12-05 23:59 ` [PATCH v2] sched: deadline: Cleanup " John Stultz 2024-12-06 8:14 ` K Prateek Nayak @ 2024-12-09 11:44 ` Juri Lelli 2024-12-09 12:01 ` Peter Zijlstra 2024-12-13 12:05 ` [tip: sched/core] " tip-bot2 for John Stultz 3 siblings, 0 replies; 9+ messages in thread From: Juri Lelli @ 2024-12-09 11:44 UTC (permalink / raw) To: John Stultz Cc: LKML, Ingo Molnar, Peter Zijlstra, Vincent Guittot, Dietmar Eggemann, Steven Rostedt, Ben Segall, Mel Gorman, Valentin Schneider, Wanpeng Li, Christophe JAILLET, Todd Kjos, kernel-team Hi John, On 05/12/24 15:59, John Stultz wrote: > Commit 8b5e770ed7c0 ("sched/deadline: Optimize pull_dl_task()") > added a goto label seems would be better written as a while > loop. > > So replace the goto with a while loop, to make it easier to read. > > Cc: Ingo Molnar <mingo@redhat.com> > Cc: Peter Zijlstra <peterz@infradead.org> > Cc: Juri Lelli <juri.lelli@redhat.com> > Cc: Vincent Guittot <vincent.guittot@linaro.org> > Cc: Dietmar Eggemann <dietmar.eggemann@arm.com> > Cc: Steven Rostedt <rostedt@goodmis.org> > Cc: Ben Segall <bsegall@google.com> > Cc: Mel Gorman <mgorman@suse.de> > Cc: Valentin Schneider <vschneid@redhat.com> > Cc: Wanpeng Li <wanpeng.li@linux.intel.com> > Cc: Christophe JAILLET <christophe.jaillet@wanadoo.fr> > Cc: Todd Kjos <tkjos@google.com> > Cc: kernel-team@android.com > Reported-by: Todd Kjos <tkjos@google.com> > Signed-off-by: John Stultz <jstultz@google.com> Acked-by: Juri Lelli <juri.lelli@redhat.com> Thanks! Juri ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v2] sched: deadline: Cleanup goto label in pick_earliest_pushable_dl_task 2024-12-05 23:59 ` [PATCH v2] sched: deadline: Cleanup " John Stultz 2024-12-06 8:14 ` K Prateek Nayak 2024-12-09 11:44 ` Juri Lelli @ 2024-12-09 12:01 ` Peter Zijlstra 2024-12-13 12:05 ` [tip: sched/core] " tip-bot2 for John Stultz 3 siblings, 0 replies; 9+ messages in thread From: Peter Zijlstra @ 2024-12-09 12:01 UTC (permalink / raw) To: John Stultz Cc: LKML, Ingo Molnar, Juri Lelli, Vincent Guittot, Dietmar Eggemann, Steven Rostedt, Ben Segall, Mel Gorman, Valentin Schneider, Wanpeng Li, Christophe JAILLET, Todd Kjos, kernel-team On Thu, Dec 05, 2024 at 03:59:35PM -0800, John Stultz wrote: > Commit 8b5e770ed7c0 ("sched/deadline: Optimize pull_dl_task()") > added a goto label seems would be better written as a while > loop. > > So replace the goto with a while loop, to make it easier to read. > Thanks! ^ permalink raw reply [flat|nested] 9+ messages in thread
* [tip: sched/core] sched: deadline: Cleanup goto label in pick_earliest_pushable_dl_task 2024-12-05 23:59 ` [PATCH v2] sched: deadline: Cleanup " John Stultz ` (2 preceding siblings ...) 2024-12-09 12:01 ` Peter Zijlstra @ 2024-12-13 12:05 ` tip-bot2 for John Stultz 3 siblings, 0 replies; 9+ messages in thread From: tip-bot2 for John Stultz @ 2024-12-13 12:05 UTC (permalink / raw) To: linux-tip-commits Cc: Todd Kjos, John Stultz, Peter Zijlstra (Intel), Juri Lelli, x86, linux-kernel The following commit has been merged into the sched/core branch of tip: Commit-ID: 7675361ff9a1d9038025c05267600d0c762c0236 Gitweb: https://git.kernel.org/tip/7675361ff9a1d9038025c05267600d0c762c0236 Author: John Stultz <jstultz@google.com> AuthorDate: Thu, 05 Dec 2024 15:59:35 -08:00 Committer: Peter Zijlstra <peterz@infradead.org> CommitterDate: Tue, 10 Dec 2024 15:07:06 +01:00 sched: deadline: Cleanup goto label in pick_earliest_pushable_dl_task Commit 8b5e770ed7c0 ("sched/deadline: Optimize pull_dl_task()") added a goto label seems would be better written as a while loop. So replace the goto with a while loop, to make it easier to read. Reported-by: Todd Kjos <tkjos@google.com> Signed-off-by: John Stultz <jstultz@google.com> Reviewed-and-tested-by: K Prateek Nayak <kprateek.nayak@amd.com> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Acked-by: Juri Lelli <juri.lelli@redhat.com> Link: https://lore.kernel.org/r/20241206000009.1226085-1-jstultz@google.com --- kernel/sched/deadline.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/kernel/sched/deadline.c b/kernel/sched/deadline.c index 33b4646..643d101 100644 --- a/kernel/sched/deadline.c +++ b/kernel/sched/deadline.c @@ -2516,16 +2516,13 @@ static struct task_struct *pick_earliest_pushable_dl_task(struct rq *rq, int cpu return NULL; 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 (task_is_pushable(rq, p, cpu)) return p; next_node = rb_next(next_node); - goto next_node; } return NULL; ^ permalink raw reply related [flat|nested] 9+ messages in thread
end of thread, other threads:[~2024-12-13 12:06 UTC | newest] Thread overview: 9+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2024-12-05 21:16 [RFC][PATCH] sched: deadline: Remove unnecessary goto label in pick_earliest_pushable_dl_task John Stultz 2024-12-05 21:23 ` Christophe JAILLET 2024-12-05 21:23 ` Christophe JAILLET 2024-12-05 21:47 ` John Stultz 2024-12-05 23:59 ` [PATCH v2] sched: deadline: Cleanup " John Stultz 2024-12-06 8:14 ` K Prateek Nayak 2024-12-09 11:44 ` Juri Lelli 2024-12-09 12:01 ` Peter Zijlstra 2024-12-13 12:05 ` [tip: sched/core] " tip-bot2 for John Stultz
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox