All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] seqlock: Use while instead of if+goto in __read_seqcount_begin
@ 2020-04-09 13:45 Muchun Song
  2020-04-10 11:56 ` Will Deacon
  0 siblings, 1 reply; 9+ messages in thread
From: Muchun Song @ 2020-04-09 13:45 UTC (permalink / raw)
  To: peterz, mingo, will, mingo; +Cc: linux-kernel, Muchun Song

The creators of the C language gave us the while keyword. Let's use
that instead of synthesizing it from if+goto.

Signed-off-by: Muchun Song <songmuchun@bytedance.com>
---
 include/linux/seqlock.h | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/include/linux/seqlock.h b/include/linux/seqlock.h
index 8b97204f35a77..7bdea019814ce 100644
--- a/include/linux/seqlock.h
+++ b/include/linux/seqlock.h
@@ -125,12 +125,8 @@ static inline unsigned __read_seqcount_begin(const seqcount_t *s)
 {
 	unsigned ret;
 
-repeat:
-	ret = READ_ONCE(s->sequence);
-	if (unlikely(ret & 1)) {
+	while (unlikely((ret = READ_ONCE(s->sequence)) & 1))
 		cpu_relax();
-		goto repeat;
-	}
 	kcsan_atomic_next(KCSAN_SEQLOCK_REGION_MAX);
 	return ret;
 }
-- 
2.11.0


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

end of thread, other threads:[~2020-04-15 12:29 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-09 13:45 [PATCH] seqlock: Use while instead of if+goto in __read_seqcount_begin Muchun Song
2020-04-10 11:56 ` Will Deacon
2020-04-14  8:58   ` [External] " Muchun Song
2020-04-14 11:05   ` Peter Zijlstra
2020-04-14 12:01     ` [External] " Muchun Song
2020-04-15 11:41       ` Peter Zijlstra
2020-04-14 13:48     ` Will Deacon
2020-04-15 11:44       ` Peter Zijlstra
2020-04-15  9:37     ` David Laight

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.