Skip to content

Commit 388b0e0

Browse files
David HildenbrandIngo Molnar
authored andcommitted
sched/preempt, arm/futex: Disable preemption in UP futex_atomic_op_inuser() explicitly
The !CONFIG_SMP implementation of futex_atomic_op_inuser() seems to rely on disabled preemption to guarantee mutual exclusion. From commit e589ed2 ("[ARM] 5218/1: arm: improved futex support"): "For UP it's enough to disable preemption to ensure mutual exclusion..." From the code itself: "!SMP, we can work around lack of atomic ops by disabling preemption" Let's make this explicit, to prepare for pagefault_disable() not touching preemption anymore. Reviewed-and-tested-by: Thomas Gleixner <tglx@linutronix.de> Signed-off-by: David Hildenbrand <dahi@linux.vnet.ibm.com> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Cc: David.Laight@ACULAB.COM Cc: Linus Torvalds <torvalds@linux-foundation.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: airlied@linux.ie Cc: akpm@linux-foundation.org Cc: benh@kernel.crashing.org Cc: bigeasy@linutronix.de Cc: borntraeger@de.ibm.com Cc: daniel.vetter@intel.com Cc: heiko.carstens@de.ibm.com Cc: herbert@gondor.apana.org.au Cc: hocko@suse.cz Cc: hughd@google.com Cc: mst@redhat.com Cc: paulus@samba.org Cc: ralf@linux-mips.org Cc: schwidefsky@de.ibm.com Cc: yang.shi@windriver.com Link: http://lkml.kernel.org/r/1431359540-32227-12-git-send-email-dahi@linux.vnet.ibm.com Signed-off-by: Ingo Molnar <mingo@kernel.org>
1 parent 39919b0 commit 388b0e0

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

arch/arm/include/asm/futex.h

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,10 @@ futex_atomic_op_inuser (int encoded_op, u32 __user *uaddr)
127127
if (!access_ok(VERIFY_WRITE, uaddr, sizeof(u32)))
128128
return -EFAULT;
129129

130-
pagefault_disable(); /* implies preempt_disable() */
130+
#ifndef CONFIG_SMP
131+
preempt_disable();
132+
#endif
133+
pagefault_disable();
131134

132135
switch (op) {
133136
case FUTEX_OP_SET:
@@ -149,7 +152,10 @@ futex_atomic_op_inuser (int encoded_op, u32 __user *uaddr)
149152
ret = -ENOSYS;
150153
}
151154

152-
pagefault_enable(); /* subsumes preempt_enable() */
155+
pagefault_enable();
156+
#ifndef CONFIG_SMP
157+
preempt_enable();
158+
#endif
153159

154160
if (!ret) {
155161
switch (cmp) {

0 commit comments

Comments
 (0)