[tip:,sched/core] sched/core: Use do-while instead of for loop in set_nr_if_polling()

Message ID 169479133040.27769.13340324338034270661.tip-bot2@tip-bot2
State New
Headers
Series [tip:,sched/core] sched/core: Use do-while instead of for loop in set_nr_if_polling() |

Commit Message

tip-bot2 for Thomas Gleixner Sept. 15, 2023, 3:22 p.m. UTC
  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(-)
  

Patch

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;
 }