Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ARC: ensure futex ops are atomic in !LLSC config

W/o hardware assisted atomic r-m-w the best we can do is to disable
preemption.

Cc: David Hildenbrand <dahi@linux.vnet.ibm.com>
Cc: Peter Zijlstra (Intel) <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Michel Lespinasse <walken@google.com>
Signed-off-by: Vineet Gupta <vgupta@synopsys.com>

+12
+12
arch/arc/include/asm/futex.h
··· 87 87 if (!access_ok(VERIFY_WRITE, uaddr, sizeof(int))) 88 88 return -EFAULT; 89 89 90 + #ifndef CONFIG_ARC_HAS_LLSC 91 + preempt_disable(); /* to guarantee atomic r-m-w of futex op */ 92 + #endif 90 93 pagefault_disable(); 91 94 92 95 switch (op) { ··· 114 111 } 115 112 116 113 pagefault_enable(); 114 + #ifndef CONFIG_ARC_HAS_LLSC 115 + preempt_enable(); 116 + #endif 117 117 118 118 if (!ret) { 119 119 switch (cmp) { ··· 159 153 if (!access_ok(VERIFY_WRITE, uaddr, sizeof(u32))) 160 154 return -EFAULT; 161 155 156 + #ifndef CONFIG_ARC_HAS_LLSC 157 + preempt_disable(); /* to guarantee atomic r-m-w of futex op */ 158 + #endif 162 159 smp_mb(); 163 160 164 161 __asm__ __volatile__( ··· 191 182 192 183 smp_mb(); 193 184 185 + #ifndef CONFIG_ARC_HAS_LLSC 186 + preempt_enable(); 187 + #endif 194 188 *uval = existval; 195 189 return ret; 196 190 }