linux-parisc.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] parisc: futex: Use same lock set as lws calls
@ 2011-10-09 20:40 John David Anglin
  2011-10-10 14:30 ` Rolf Eike Beer
  2011-10-17 15:23 ` Domenico Andreoli
  0 siblings, 2 replies; 38+ messages in thread
From: John David Anglin @ 2011-10-09 20:40 UTC (permalink / raw)
  To: linux-parisc; +Cc: jejb, kyle, deller, carlos

In debugging the failure of the glibc tst-cond18 test on parisc, I realized
that futexes need to use the same locks the lws calls.  This fixes all the
pthread 'cond' tests.  Sadly, there are still problems with thread cancellation.

Signed-of-by: John David Anglin <dave.anglin@bell.net>

diff --git a/arch/parisc/include/asm/futex.h b/arch/parisc/include/asm/futex.h
index 2388bdb..a8d0586 100644
--- a/arch/parisc/include/asm/futex.h
+++ b/arch/parisc/include/asm/futex.h
@@ -8,6 +8,29 @@
 #include <asm/atomic.h>
 #include <asm/errno.h>
 
+/* The following has to match the LWS code in syscall.S.  We have
+   sixteen four-word locks. */
+
+static inline void
+_futex_spin_lock_irqsave (u32 __user *uaddr, unsigned long int *flags)
+{
+  extern u32 lws_lock_start[];
+  long index = ((long)uaddr & 0xf0) >> 2;
+  arch_spinlock_t *s = (arch_spinlock_t *)&lws_lock_start[index];
+  local_irq_save(*flags);
+  arch_spin_lock(s);
+}
+
+static inline void
+_futex_spin_unlock_irqrestore (u32 __user *uaddr, unsigned long int *flags)
+{
+  extern u32 lws_lock_start[];
+  long index = ((long)uaddr & 0xf0) >> 2;
+  arch_spinlock_t *s = (arch_spinlock_t *)&lws_lock_start[index];
+  arch_spin_unlock(s);
+  local_irq_restore(*flags);
+}
+
 static inline int
 futex_atomic_op_inuser (int encoded_op, u32 __user *uaddr)
 {
@@ -26,7 +49,7 @@ futex_atomic_op_inuser (int encoded_op, u32 __user *uaddr)
 
 	pagefault_disable();
 
-	_atomic_spin_lock_irqsave(uaddr, flags);
+	_futex_spin_lock_irqsave(uaddr, &flags);
 
 	switch (op) {
 	case FUTEX_OP_SET:
@@ -71,7 +94,7 @@ futex_atomic_op_inuser (int encoded_op, u32 __user *uaddr)
 		ret = -ENOSYS;
 	}
 
-	_atomic_spin_unlock_irqrestore(uaddr, flags);
+	_futex_spin_unlock_irqrestore(uaddr, &flags);
 
 	pagefault_enable();
 
@@ -113,7 +136,7 @@ futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
 	 * address. This should scale to a couple of CPUs.
 	 */
 
-	_atomic_spin_lock_irqsave(uaddr, flags);
+	_futex_spin_lock_irqsave(uaddr, &flags);
 
 	ret = get_user(val, uaddr);
 
@@ -122,7 +145,7 @@ futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
 
 	*uval = val;
 
-	_atomic_spin_unlock_irqrestore(uaddr, flags);
+	_futex_spin_unlock_irqrestore(uaddr, &flags);
 
 	return ret;
 }

Dave
-- 
J. David Anglin                                  dave.anglin@nrc-cnrc.gc.ca
National Research Council of Canada              (613) 990-0752 (FAX: 952-6602)

^ permalink raw reply related	[flat|nested] 38+ messages in thread

end of thread, other threads:[~2011-11-01 19:56 UTC | newest]

Thread overview: 38+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-10-09 20:40 [PATCH] parisc: futex: Use same lock set as lws calls John David Anglin
2011-10-10 14:30 ` Rolf Eike Beer
2011-10-10 20:27   ` John David Anglin
2011-10-10 20:30     ` James Bottomley
2011-10-17 15:23 ` Domenico Andreoli
2011-10-17 15:47   ` Carlos O'Donell
2011-10-17 18:10     ` John David Anglin
2011-10-17 20:55       ` Carlos O'Donell
2011-10-17 21:09         ` John David Anglin
2011-10-17 21:57           ` Domenico Andreoli
2011-10-17 22:28             ` John David Anglin
2011-10-18  9:31               ` Domenico Andreoli
2011-10-18  9:33               ` Domenico Andreoli
2011-10-18 14:20                 ` John David Anglin
2011-10-18  3:01           ` Carlos O'Donell
2011-10-18  3:21             ` Carlos O'Donell
2011-10-18 21:22               ` Carlos O'Donell
2011-10-20 15:35           ` Carlos O'Donell
2011-10-20 17:57             ` Matt Turner
2011-10-20 18:11               ` Carlos O'Donell
2011-10-20 18:16                 ` Matt Turner
2011-10-20  1:47       ` John David Anglin
2011-10-21 14:49         ` Carlos O'Donell
2011-10-21 17:42           ` John David Anglin
2011-10-21 18:11             ` John David Anglin
2011-10-21 18:15               ` Carlos O'Donell
2011-10-30 15:04                 ` John David Anglin
2011-10-30 15:31                   ` Rolf Eike Beer
2011-10-30 16:13                     ` John David Anglin
2011-10-31  0:21                       ` Carlos O'Donell
2011-10-31  1:36                         ` John David Anglin
2011-10-31  9:41                           ` Domenico Andreoli
2011-10-31 12:28                             ` John David Anglin
2011-10-31 23:26                             ` John David Anglin
2011-11-01  9:15                               ` Domenico Andreoli
2011-11-01  2:15                           ` Carlos O'Donell
2011-11-01  9:19                             ` Domenico Andreoli
2011-11-01 19:56                               ` John David Anglin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).