[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20200409134558.90863-1-songmuchun@bytedance.com>
Date: Thu, 9 Apr 2020 21:45:58 +0800
From: Muchun Song <songmuchun@...edance.com>
To: peterz@...radead.org, mingo@...hat.com, will@...nel.org,
mingo@...nel.org
Cc: linux-kernel@...r.kernel.org,
Muchun Song <songmuchun@...edance.com>
Subject: [PATCH] seqlock: Use while instead of if+goto in __read_seqcount_begin
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@...edance.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
Powered by blists - more mailing lists