Skip to contentSkip to conversation

ARC: remove redundant READ_ONCE() in cmpxchg loop

PATCH In review Bang Li 2 participants 2 messages Mar 19, 2022 – Apr 18, 2022 Synopsys ARC architecture

lore
Share & tools
lore

Bang Li

author
#0 lore raw

PATCH 1/1 ARC: remove redundant READ_ONCE() in cmpxchg loop

This patch reverts commit 7082a29c22ac ("ARC: use ACCESS_ONCE in cmpxchg loop").

It is not necessary to use READ_ONCE() because cmpxchg contains barrier. We can get it from commit d57f727264f1 ("ARC: add compiler barrier to LLSC based cmpxchg").

---
 arch/arc/kernel/smp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arc/kernel/smp.c +1 -1
index 78e6d069b1c1..56c23f3e1309 100644
@@ -274,7 +274,7 @@ static void ipi_send_msg_one(int cpu, enum ipi_msg_type msg)
 	 * and read back old value
 	 */
 	do {
-		new = old = READ_ONCE(*ipi_data_ptr);
+		new = old = *ipi_data_ptr;
 		new |= 1U << msg;
 	} while (cmpxchg(ipi_data_ptr, old, new) != old);
 
Signature · 1 line
2.25.1
maintainer
#1 lore raw
Quoted 8 lines · Bang Li

This patch reverts commit 7082a29c22ac ("ARC: use ACCESS_ONCE in cmpxchg loop").

It is not necessary to use READ_ONCE() because cmpxchg contains barrier. We can get it from commit d57f727264f1 ("ARC: add compiler barrier to LLSC based cmpxchg").

Indeed this is not needed. However have you checked the code with and/wo this change to see if it builds the same.

-Vineet

Quoted 9 lines
---
  arch/arc/kernel/smp.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
arch/arc/kernel/smp.c +0 -0
index 78e6d069b1c1..56c23f3e1309 100644

arch/arc/kernel/smp.c static void ipi_send_msg_one(int cpu, enum ipi_msg_type msg) · line 280

Quoted 8 lines
arch/arc/kernel/smp.c +1 -1
@@ -274,7 +274,7 @@ static void ipi_send_msg_one(int cpu, enum ipi_msg_type msg)
  	 * and read back old value
  	 */
  	do {
-		new = old = READ_ONCE(*ipi_data_ptr);
+		new = old = *ipi_data_ptr;
  		new |= 1U << msg;
  	} while (cmpxchg(ipi_data_ptr, old, new) != old);
 

_______________________________________________
linux-snps-arc mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-snps-arc