Skip to content

Commit 7e99271

Browse files
danglin44hdeller
authored andcommitted
parisc: Don't disable interrupts in cmpxchg and futex operations
I no longer think interrupts can be disabled in the futex and cmpxchg operations because of COW breaks. This not ideal but I suspect it's the best we can do. For the cmpxchg operations in syscall.S, we rely on the code to not schedule off the gateway page. For the futex, I added code to disable preemption. So far, I haven't seen the warnings with the attached change but the change is only lightly tested. Signed-off-by: Dave Anglin <dave.anglin@bell.net> Signed-off-by: Helge Deller <deller@gmx.de>
1 parent 014966d commit 7e99271

2 files changed

Lines changed: 11 additions & 23 deletions

File tree

arch/parisc/include/asm/futex.h

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,35 +11,34 @@
1111
sixteen four-word locks. */
1212

1313
static inline void
14-
_futex_spin_lock_irqsave(u32 __user *uaddr, unsigned long int *flags)
14+
_futex_spin_lock(u32 __user *uaddr)
1515
{
1616
extern u32 lws_lock_start[];
1717
long index = ((long)uaddr & 0x3f8) >> 1;
1818
arch_spinlock_t *s = (arch_spinlock_t *)&lws_lock_start[index];
19-
local_irq_save(*flags);
19+
preempt_disable();
2020
arch_spin_lock(s);
2121
}
2222

2323
static inline void
24-
_futex_spin_unlock_irqrestore(u32 __user *uaddr, unsigned long int *flags)
24+
_futex_spin_unlock(u32 __user *uaddr)
2525
{
2626
extern u32 lws_lock_start[];
2727
long index = ((long)uaddr & 0x3f8) >> 1;
2828
arch_spinlock_t *s = (arch_spinlock_t *)&lws_lock_start[index];
2929
arch_spin_unlock(s);
30-
local_irq_restore(*flags);
30+
preempt_enable();
3131
}
3232

3333
static inline int
3434
arch_futex_atomic_op_inuser(int op, int oparg, int *oval, u32 __user *uaddr)
3535
{
36-
unsigned long int flags;
3736
int oldval, ret;
3837
u32 tmp;
3938

40-
_futex_spin_lock_irqsave(uaddr, &flags);
41-
4239
ret = -EFAULT;
40+
41+
_futex_spin_lock(uaddr);
4342
if (unlikely(get_user(oldval, uaddr) != 0))
4443
goto out_pagefault_enable;
4544

@@ -70,7 +69,7 @@ arch_futex_atomic_op_inuser(int op, int oparg, int *oval, u32 __user *uaddr)
7069
ret = -EFAULT;
7170

7271
out_pagefault_enable:
73-
_futex_spin_unlock_irqrestore(uaddr, &flags);
72+
_futex_spin_unlock(uaddr);
7473

7574
if (!ret)
7675
*oval = oldval;
@@ -83,7 +82,6 @@ futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
8382
u32 oldval, u32 newval)
8483
{
8584
u32 val;
86-
unsigned long flags;
8785

8886
/* futex.c wants to do a cmpxchg_inatomic on kernel NULL, which is
8987
* our gateway page, and causes no end of trouble...
@@ -100,19 +98,19 @@ futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
10098
* address. This should scale to a couple of CPUs.
10199
*/
102100

103-
_futex_spin_lock_irqsave(uaddr, &flags);
101+
_futex_spin_lock(uaddr);
104102
if (unlikely(get_user(val, uaddr) != 0)) {
105-
_futex_spin_unlock_irqrestore(uaddr, &flags);
103+
_futex_spin_unlock(uaddr);
106104
return -EFAULT;
107105
}
108106

109107
if (val == oldval && unlikely(put_user(newval, uaddr) != 0)) {
110-
_futex_spin_unlock_irqrestore(uaddr, &flags);
108+
_futex_spin_unlock(uaddr);
111109
return -EFAULT;
112110
}
113111

114112
*uval = val;
115-
_futex_spin_unlock_irqrestore(uaddr, &flags);
113+
_futex_spin_unlock(uaddr);
116114

117115
return 0;
118116
}

arch/parisc/kernel/syscall.S

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -597,13 +597,11 @@ cas_nocontend:
597597
# endif
598598
/* ENABLE_LWS_DEBUG */
599599

600-
rsm PSW_SM_I, %r0 /* Disable interrupts */
601600
/* COW breaks can cause contention on UP systems */
602601
LDCW 0(%sr2,%r20), %r28 /* Try to acquire the lock */
603602
cmpb,<>,n %r0, %r28, cas_action /* Did we get it? */
604603
cas_wouldblock:
605604
ldo 2(%r0), %r28 /* 2nd case */
606-
ssm PSW_SM_I, %r0
607605
b lws_exit /* Contended... */
608606
ldo -EAGAIN(%r0), %r21 /* Spin in userspace */
609607

@@ -639,8 +637,6 @@ cas_action:
639637
/* Clear thread register indicator */
640638
stw %r0, 4(%sr2,%r20)
641639
#endif
642-
/* Enable interrupts */
643-
ssm PSW_SM_I, %r0
644640
/* Return to userspace, set no error */
645641
b lws_exit
646642
copy %r0, %r21
@@ -652,7 +648,6 @@ cas_action:
652648
#if ENABLE_LWS_DEBUG
653649
stw %r0, 4(%sr2,%r20)
654650
#endif
655-
ssm PSW_SM_I, %r0
656651
b lws_exit
657652
ldo -EFAULT(%r0),%r21 /* set errno */
658653
nop
@@ -764,13 +759,11 @@ cas2_lock_start:
764759
shlw %r20, 4, %r20
765760
add %r20, %r28, %r20
766761

767-
rsm PSW_SM_I, %r0 /* Disable interrupts */
768762
/* COW breaks can cause contention on UP systems */
769763
LDCW 0(%sr2,%r20), %r28 /* Try to acquire the lock */
770764
cmpb,<>,n %r0, %r28, cas2_action /* Did we get it? */
771765
cas2_wouldblock:
772766
ldo 2(%r0), %r28 /* 2nd case */
773-
ssm PSW_SM_I, %r0
774767
b lws_exit /* Contended... */
775768
ldo -EAGAIN(%r0), %r21 /* Spin in userspace */
776769

@@ -850,8 +843,6 @@ cas2_action:
850843
cas2_end:
851844
/* Free lock */
852845
stw,ma %r20, 0(%sr2,%r20)
853-
/* Enable interrupts */
854-
ssm PSW_SM_I, %r0
855846
/* Return to userspace, set no error */
856847
b lws_exit
857848
copy %r0, %r21
@@ -860,7 +851,6 @@ cas2_end:
860851
/* Error occurred on load or store */
861852
/* Free lock */
862853
stw,ma %r20, 0(%sr2,%r20)
863-
ssm PSW_SM_I, %r0
864854
ldo 1(%r0),%r28
865855
b lws_exit
866856
ldo -EFAULT(%r0),%r21 /* set errno */

0 commit comments

Comments
 (0)