Skip to contentSkip to conversation

x86: Use ACCESS_ONCE() for atomic_read()

RFC PATCH In review Pranith Kumar 2 participants 5 messages Sep 22, 2014 – Sep 23, 2014

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

RFC PATCH 1/1 x86: Use ACCESS_ONCE() for atomic_read()

Use the much easier to read ACCESS_ONCE() which is basically the same thing as the cast to volatile.

Please note the change in volatile cast: ACCESS_ONCE(v)->counter to ACCESS_ONCE(v->counter).

---
 arch/x86/include/asm/atomic.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/include/asm/atomic.h +1 -1
index fa92e93..dea3434 100644
@@ -24,7 +24,7 @@
  */
 static inline int atomic_read(const atomic_t *v)
 {
-	return (*(volatile int *)&(v)->counter);
+	return ACCESS_ONCE(v->counter);
 }
 
 /**
Signature · 1 line
2.1.0
maintainer
#1 lore raw
Quoted 10 lines · Pranith Kumar

Use the much easier to read ACCESS_ONCE() which is basically the same thing as the cast to volatile.

Please note the change in volatile cast: ACCESS_ONCE(v)->counter to ACCESS_ONCE(v->counter).

---
 arch/x86/include/asm/atomic.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

If you want to do something like so, then be consistent and do them all.

#2 lore raw
Quoted 7 lines · Peter Zijlstra
Quoted 6 lines · Pranith Kumar

Use the much easier to read ACCESS_ONCE() which is basically the same thing as the cast to volatile.

Please note the change in volatile cast: ACCESS_ONCE(v)->counter to ACCESS_ONCE(v->counter).

Quoted 6 lines
Quoted 4 lines
---
 arch/x86/include/asm/atomic.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

If you want to do something like so, then be consistent and do them all.

Sure, I will change this in all architectures and send in an updated patch.

Thanks!

Signature · 1 line
Pranith
#3 lore raw
In reply to Peter Zijlstra
Quoted 7 lines · Peter Zijlstra
Quoted 6 lines · Pranith Kumar

Use the much easier to read ACCESS_ONCE() which is basically the same thing as the cast to volatile.

Please note the change in volatile cast: ACCESS_ONCE(v)->counter to ACCESS_ONCE(v->counter).

Quoted 6 lines
Quoted 4 lines
---
 arch/x86/include/asm/atomic.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

If you want to do something like so, then be consistent and do them all.

Hi Peter,

The changelog across all archs is as follows

18 files changed, 24 insertions(+), 24 deletions(-)

Do you think it is better to send it as one patch or break up into patch for each arch?

Signature · 1 line
Pranith
maintainer
#4 lore raw
Quoted 15 lines · Pranith Kumar
Quoted 7 lines · Peter Zijlstra
Quoted 6 lines · Pranith Kumar

Use the much easier to read ACCESS_ONCE() which is basically the same thing as the cast to volatile.

Please note the change in volatile cast: ACCESS_ONCE(v)->counter to ACCESS_ONCE(v->counter).

Quoted 6 lines
Quoted 4 lines
---
 arch/x86/include/asm/atomic.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

If you want to do something like so, then be consistent and do them all.

Quoted 8 lines

Hi Peter,

The changelog across all archs is as follows

18 files changed, 24 insertions(+), 24 deletions(-)

Do you think it is better to send it as one patch or break up into patch for each arch?

I'd send it as a single patch, its small enough as is, and basically just a 'style' update.