mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 1/1] sched: Deduplicate code with do-while
@ 2019-06-11 12:29 Pavel Begunkov (Silence)
  2019-06-17 15:00 ` Peter Zijlstra
  2019-06-25  8:24 ` [tip:sched/core] sched/wait: " tip-bot for Pavel Begunkov
  0 siblings, 2 replies; 3+ messages in thread
From: Pavel Begunkov (Silence) @ 2019-06-11 12:29 UTC (permalink / raw)
  To: Ingo Molnar, Peter Zijlstra, linux-kernel; +Cc: Pavel Begunkov

From: Pavel Begunkov <asml.silence@gmail.com>

Statements in the loop's body and before it are identical.
Use do-while to not repeat it.

Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
---
 kernel/sched/wait.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/kernel/sched/wait.c b/kernel/sched/wait.c
index fa0f9adfb752..c1e566a114ca 100644
--- a/kernel/sched/wait.c
+++ b/kernel/sched/wait.c
@@ -118,16 +118,12 @@ static void __wake_up_common_lock(struct wait_queue_head *wq_head, unsigned int
 	bookmark.func = NULL;
 	INIT_LIST_HEAD(&bookmark.entry);
 
-	spin_lock_irqsave(&wq_head->lock, flags);
-	nr_exclusive = __wake_up_common(wq_head, mode, nr_exclusive, wake_flags, key, &bookmark);
-	spin_unlock_irqrestore(&wq_head->lock, flags);
-
-	while (bookmark.flags & WQ_FLAG_BOOKMARK) {
+	do {
 		spin_lock_irqsave(&wq_head->lock, flags);
 		nr_exclusive = __wake_up_common(wq_head, mode, nr_exclusive,
 						wake_flags, key, &bookmark);
 		spin_unlock_irqrestore(&wq_head->lock, flags);
-	}
+	} while (bookmark.flags & WQ_FLAG_BOOKMARK);
 }
 
 /**
-- 
2.22.0


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH 1/1] sched: Deduplicate code with do-while
  2019-06-11 12:29 [PATCH 1/1] sched: Deduplicate code with do-while Pavel Begunkov (Silence)
@ 2019-06-17 15:00 ` Peter Zijlstra
  2019-06-25  8:24 ` [tip:sched/core] sched/wait: " tip-bot for Pavel Begunkov
  1 sibling, 0 replies; 3+ messages in thread
From: Peter Zijlstra @ 2019-06-17 15:00 UTC (permalink / raw)
  To: Pavel Begunkov (Silence); +Cc: Ingo Molnar, linux-kernel

On Tue, Jun 11, 2019 at 03:29:07PM +0300, Pavel Begunkov (Silence) wrote:
> From: Pavel Begunkov <asml.silence@gmail.com>
> 
> Statements in the loop's body and before it are identical.
> Use do-while to not repeat it.
> 

Thanks!

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [tip:sched/core] sched/wait: Deduplicate code with do-while
  2019-06-11 12:29 [PATCH 1/1] sched: Deduplicate code with do-while Pavel Begunkov (Silence)
  2019-06-17 15:00 ` Peter Zijlstra
@ 2019-06-25  8:24 ` tip-bot for Pavel Begunkov
  1 sibling, 0 replies; 3+ messages in thread
From: tip-bot for Pavel Begunkov @ 2019-06-25  8:24 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: torvalds, peterz, tglx, hpa, linux-kernel, mingo, asml.silence

Commit-ID:  016190a4b5824df2d5bb97951a04dd3629973671
Gitweb:     https://git.kernel.org/tip/016190a4b5824df2d5bb97951a04dd3629973671
Author:     Pavel Begunkov <asml.silence@gmail.com>
AuthorDate: Tue, 11 Jun 2019 15:29:07 +0300
Committer:  Ingo Molnar <mingo@kernel.org>
CommitDate: Mon, 24 Jun 2019 19:23:40 +0200

sched/wait: Deduplicate code with do-while

Statements in the loop's body and before it are identical.
Use do-while to not repeat it.

Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Link: https://lkml.kernel.org/r/43ffea6ee2152b90dedf962eac851609e4197218.1560256112.git.asml.silence@gmail.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
 kernel/sched/wait.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/kernel/sched/wait.c b/kernel/sched/wait.c
index fa0f9adfb752..c1e566a114ca 100644
--- a/kernel/sched/wait.c
+++ b/kernel/sched/wait.c
@@ -118,16 +118,12 @@ static void __wake_up_common_lock(struct wait_queue_head *wq_head, unsigned int
 	bookmark.func = NULL;
 	INIT_LIST_HEAD(&bookmark.entry);
 
-	spin_lock_irqsave(&wq_head->lock, flags);
-	nr_exclusive = __wake_up_common(wq_head, mode, nr_exclusive, wake_flags, key, &bookmark);
-	spin_unlock_irqrestore(&wq_head->lock, flags);
-
-	while (bookmark.flags & WQ_FLAG_BOOKMARK) {
+	do {
 		spin_lock_irqsave(&wq_head->lock, flags);
 		nr_exclusive = __wake_up_common(wq_head, mode, nr_exclusive,
 						wake_flags, key, &bookmark);
 		spin_unlock_irqrestore(&wq_head->lock, flags);
-	}
+	} while (bookmark.flags & WQ_FLAG_BOOKMARK);
 }
 
 /**

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-06-25  8:24 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-06-11 12:29 [PATCH 1/1] sched: Deduplicate code with do-while Pavel Begunkov (Silence)
2019-06-17 15:00 ` Peter Zijlstra
2019-06-25  8:24 ` [tip:sched/core] sched/wait: " tip-bot for Pavel Begunkov

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