public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] asm-generic: rwsem: ensure sem->cnt is only accessed via atomic_long_*
@ 2014-02-21 17:22 Will Deacon
  2014-02-21 17:22 ` [PATCH 2/2] asm-generic: rwsem: de-PPCify rwsem.h Will Deacon
  2014-02-27  5:28 ` [PATCH 1/2] asm-generic: rwsem: ensure sem->cnt is only accessed via atomic_long_* Davidlohr Bueso
  0 siblings, 2 replies; 8+ messages in thread
From: Will Deacon @ 2014-02-21 17:22 UTC (permalink / raw)
  To: linux-kernel; +Cc: rkuo, arnd, paulus, Will Deacon

The asm-generic rwsem implementation directly acceses sem->cnt when
performing a __down_read_trylock operation. Whilst this is probably safe
on all architectures, we should stick to the atomic_long_* API and use
atomic_long_read instead.

Signed-off-by: Will Deacon <will.deacon@arm.com>
---
 include/asm-generic/rwsem.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/asm-generic/rwsem.h b/include/asm-generic/rwsem.h
index bb1e2cdeb9bf..75af612f54f8 100644
--- a/include/asm-generic/rwsem.h
+++ b/include/asm-generic/rwsem.h
@@ -41,7 +41,7 @@ static inline int __down_read_trylock(struct rw_semaphore *sem)
 {
 	long tmp;
 
-	while ((tmp = sem->count) >= 0) {
+	while ((tmp = atomic_long_read((atomic_long_t *)&sem->count)) >= 0) {
 		if (tmp == cmpxchg(&sem->count, tmp,
 				   tmp + RWSEM_ACTIVE_READ_BIAS)) {
 			return 1;
-- 
1.8.2.2


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

end of thread, other threads:[~2014-02-28 15:41 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-02-21 17:22 [PATCH 1/2] asm-generic: rwsem: ensure sem->cnt is only accessed via atomic_long_* Will Deacon
2014-02-21 17:22 ` [PATCH 2/2] asm-generic: rwsem: de-PPCify rwsem.h Will Deacon
2014-02-26 18:05   ` rkuo
2014-02-27  5:28 ` [PATCH 1/2] asm-generic: rwsem: ensure sem->cnt is only accessed via atomic_long_* Davidlohr Bueso
2014-02-27 18:53   ` Will Deacon
2014-02-28 12:13   ` Will Deacon
2014-02-28 12:50     ` Peter Hurley
2014-02-28 15:41       ` Will Deacon

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox