* [PATCH] sched/core: Use do-while instead of for loop in set_nr_if_polling
@ 2023-02-28 16:14 Uros Bizjak
2023-04-04 6:04 ` Uros Bizjak
2023-09-15 15:22 ` [tip: sched/core] sched/core: Use do-while instead of for loop in set_nr_if_polling() tip-bot2 for Uros Bizjak
0 siblings, 2 replies; 3+ messages in thread
From: Uros Bizjak @ 2023-02-28 16:14 UTC (permalink / raw)
To: linux-kernel
Cc: Uros Bizjak, Ingo Molnar, Peter Zijlstra, Juri Lelli,
Vincent Guittot, Dietmar Eggemann, Steven Rostedt, Ben Segall,
Mel Gorman, Daniel Bristot de Oliveira, Christian Brauner
Use equivalent do-while loop instead of infinite for loop.
There are no asm code changes.
Signed-off-by: Uros Bizjak <ubizjak@gmail.com>
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: Daniel Bristot de Oliveira <bristot@redhat.com>
Cc: Christian Brauner <brauner@kernel.org>
---
kernel/sched/core.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index af017e038b48..349c018eaf09 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -899,14 +899,13 @@ static bool set_nr_if_polling(struct task_struct *p)
struct thread_info *ti = task_thread_info(p);
typeof(ti->flags) val = READ_ONCE(ti->flags);
- for (;;) {
+ do {
if (!(val & _TIF_POLLING_NRFLAG))
return false;
if (val & _TIF_NEED_RESCHED)
return true;
- if (try_cmpxchg(&ti->flags, &val, val | _TIF_NEED_RESCHED))
- break;
- }
+ } while (!try_cmpxchg(&ti->flags, &val, val | _TIF_NEED_RESCHED));
+
return true;
}
--
2.39.2
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] sched/core: Use do-while instead of for loop in set_nr_if_polling
2023-02-28 16:14 [PATCH] sched/core: Use do-while instead of for loop in set_nr_if_polling Uros Bizjak
@ 2023-04-04 6:04 ` Uros Bizjak
2023-09-15 15:22 ` [tip: sched/core] sched/core: Use do-while instead of for loop in set_nr_if_polling() tip-bot2 for Uros Bizjak
1 sibling, 0 replies; 3+ messages in thread
From: Uros Bizjak @ 2023-04-04 6:04 UTC (permalink / raw)
To: linux-kernel
Cc: Ingo Molnar, Peter Zijlstra, Juri Lelli, Vincent Guittot,
Dietmar Eggemann, Steven Rostedt, Ben Segall, Mel Gorman,
Daniel Bristot de Oliveira, Christian Brauner
I would like to ping for the patch below. The patch normalizes
try_cmpxchg loop to a more readable "while" instead of "for (;;)"
loop, otherwise it is a nop.
https://lore.kernel.org/lkml/20230228161426.4508-1-ubizjak@gmail.com/
Uros.
On Tue, Feb 28, 2023 at 5:14 PM Uros Bizjak <ubizjak@gmail.com> wrote:
>
> Use equivalent do-while loop instead of infinite for loop.
>
> There are no asm code changes.
>
> Signed-off-by: Uros Bizjak <ubizjak@gmail.com>
> 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: Daniel Bristot de Oliveira <bristot@redhat.com>
> Cc: Christian Brauner <brauner@kernel.org>
> ---
> kernel/sched/core.c | 7 +++----
> 1 file changed, 3 insertions(+), 4 deletions(-)
>
> diff --git a/kernel/sched/core.c b/kernel/sched/core.c
> index af017e038b48..349c018eaf09 100644
> --- a/kernel/sched/core.c
> +++ b/kernel/sched/core.c
> @@ -899,14 +899,13 @@ static bool set_nr_if_polling(struct task_struct *p)
> struct thread_info *ti = task_thread_info(p);
> typeof(ti->flags) val = READ_ONCE(ti->flags);
>
> - for (;;) {
> + do {
> if (!(val & _TIF_POLLING_NRFLAG))
> return false;
> if (val & _TIF_NEED_RESCHED)
> return true;
> - if (try_cmpxchg(&ti->flags, &val, val | _TIF_NEED_RESCHED))
> - break;
> - }
> + } while (!try_cmpxchg(&ti->flags, &val, val | _TIF_NEED_RESCHED));
> +
> return true;
> }
>
> --
> 2.39.2
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* [tip: sched/core] sched/core: Use do-while instead of for loop in set_nr_if_polling()
2023-02-28 16:14 [PATCH] sched/core: Use do-while instead of for loop in set_nr_if_polling Uros Bizjak
2023-04-04 6:04 ` Uros Bizjak
@ 2023-09-15 15:22 ` tip-bot2 for Uros Bizjak
1 sibling, 0 replies; 3+ messages in thread
From: tip-bot2 for Uros Bizjak @ 2023-09-15 15:22 UTC (permalink / raw)
To: linux-tip-commits; +Cc: Uros Bizjak, Ingo Molnar, x86, linux-kernel
The following commit has been merged into the sched/core branch of tip:
Commit-ID: 4ff34ad3d39377d9f6953f3606ccf611ce636767
Gitweb: https://git.kernel.org/tip/4ff34ad3d39377d9f6953f3606ccf611ce636767
Author: Uros Bizjak <ubizjak@gmail.com>
AuthorDate: Tue, 28 Feb 2023 17:14:26 +01:00
Committer: Ingo Molnar <mingo@kernel.org>
CommitterDate: Fri, 15 Sep 2023 17:18:02 +02:00
sched/core: Use do-while instead of for loop in set_nr_if_polling()
Use equivalent do-while loop instead of infinite for loop.
There are no asm code changes.
Signed-off-by: Uros Bizjak <ubizjak@gmail.com>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Link: https://lore.kernel.org/r/20230228161426.4508-1-ubizjak@gmail.com
---
kernel/sched/core.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index 76662d8..f39482d 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -919,14 +919,13 @@ static bool set_nr_if_polling(struct task_struct *p)
struct thread_info *ti = task_thread_info(p);
typeof(ti->flags) val = READ_ONCE(ti->flags);
- for (;;) {
+ do {
if (!(val & _TIF_POLLING_NRFLAG))
return false;
if (val & _TIF_NEED_RESCHED)
return true;
- if (try_cmpxchg(&ti->flags, &val, val | _TIF_NEED_RESCHED))
- break;
- }
+ } while (!try_cmpxchg(&ti->flags, &val, val | _TIF_NEED_RESCHED));
+
return true;
}
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-09-15 15:22 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-02-28 16:14 [PATCH] sched/core: Use do-while instead of for loop in set_nr_if_polling Uros Bizjak
2023-04-04 6:04 ` Uros Bizjak
2023-09-15 15:22 ` [tip: sched/core] sched/core: Use do-while instead of for loop in set_nr_if_polling() tip-bot2 for Uros Bizjak
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome