sched/core: Use do-while instead of for loop in set_nr_if_polling()
authorUros Bizjak <ubizjak@gmail.com>
Tue, 28 Feb 2023 16:14:26 +0000 (17:14 +0100)
committerIngo Molnar <mingo@kernel.org>
Fri, 15 Sep 2023 15:18:02 +0000 (17:18 +0200)
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

index 76662d8..f39482d 100644 (file)
@@ -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;
 }