s390: Use generic lowlevellock-futex.h.
diff mbox

Message ID 1418857172.20194.24.camel@triegel.csb
State New
Headers show

Commit Message

Torvald Riegel Dec. 17, 2014, 10:59 p.m. UTC
This untested patch removes the custom futex operations in s390
lowlevellock.h, and instead uses the generic ones from
lowlevellock-futex.h.  They seem to be equivalent.
It also removes the definition of SYS_futex because it doesn't seem to
be used anywhere else.

It would be even nicer if we could remove the custom lowlevellock.h
altogether.  However, current s390 has custom asm for the lock fast
paths, so this needs a closer review than I can do.  Could you check
whether that would be possible?

Alternatively, I'd at least like to use generic futex operations.  Could
you please review and test?  Thanks!


2014-12-17  Torvald Riegel  <triegel@redhat.com>

	* sysdeps/unix/sysv/linux/s390/lowlevellock.h: Include
	<lowlevellock-futex.h> and remove macros and functions that are now
	defined there.
	(SYS_futex): Remove.

Comments

Torvald Riegel Jan. 7, 2015, 3:44 p.m. UTC | #1
Ping.

On Wed, 2014-12-17 at 23:59 +0100, Torvald Riegel wrote:
> This untested patch removes the custom futex operations in s390
> lowlevellock.h, and instead uses the generic ones from
> lowlevellock-futex.h.  They seem to be equivalent.
> It also removes the definition of SYS_futex because it doesn't seem to
> be used anywhere else.
> 
> It would be even nicer if we could remove the custom lowlevellock.h
> altogether.  However, current s390 has custom asm for the lock fast
> paths, so this needs a closer review than I can do.  Could you check
> whether that would be possible?
> 
> Alternatively, I'd at least like to use generic futex operations.  Could
> you please review and test?  Thanks!
> 
> 
> 2014-12-17  Torvald Riegel  <triegel@redhat.com>
> 
> 	* sysdeps/unix/sysv/linux/s390/lowlevellock.h: Include
> 	<lowlevellock-futex.h> and remove macros and functions that are now
> 	defined there.
> 	(SYS_futex): Remove.
>

Patch
diff mbox

commit 977d7402ba3fa0992c3a96ae6a629a0c564df891
Author: Torvald Riegel <triegel@redhat.com>
Date:   Wed Dec 17 22:24:51 2014 +0100

    s390: Use generic lowlevellock-futex.h.

diff --git a/sysdeps/unix/sysv/linux/s390/lowlevellock.h b/sysdeps/unix/sysv/linux/s390/lowlevellock.h
index 14fb4a8..f4dbd86 100644
--- a/sysdeps/unix/sysv/linux/s390/lowlevellock.h
+++ b/sysdeps/unix/sysv/linux/s390/lowlevellock.h
@@ -24,140 +24,8 @@ 
 #include <bits/pthreadtypes.h>
 #include <atomic.h>
 #include <kernel-features.h>
+#include <lowlevellock-futex.h>
 
-#define SYS_futex		238
-#define FUTEX_WAIT		0
-#define FUTEX_WAKE		1
-#define FUTEX_REQUEUE		3
-#define FUTEX_CMP_REQUEUE	4
-#define FUTEX_WAKE_OP		5
-#define FUTEX_OP_CLEAR_WAKE_IF_GT_ONE	((4 << 24) | 1)
-#define FUTEX_LOCK_PI		6
-#define FUTEX_UNLOCK_PI		7
-#define FUTEX_TRYLOCK_PI	8
-#define FUTEX_WAIT_BITSET	9
-#define FUTEX_WAKE_BITSET	10
-#define FUTEX_WAIT_REQUEUE_PI   11
-#define FUTEX_CMP_REQUEUE_PI    12
-#define FUTEX_PRIVATE_FLAG	128
-#define FUTEX_CLOCK_REALTIME	256
-
-#define FUTEX_BITSET_MATCH_ANY	0xffffffff
-
-/* Values for 'private' parameter of locking macros.  Yes, the
-   definition seems to be backwards.  But it is not.  The bit will be
-   reversed before passing to the system call.  */
-#define LLL_PRIVATE	0
-#define LLL_SHARED	FUTEX_PRIVATE_FLAG
-
-
-#if IS_IN (libc) || IS_IN (rtld)
-/* In libc.so or ld.so all futexes are private.  */
-# ifdef __ASSUME_PRIVATE_FUTEX
-#  define __lll_private_flag(fl, private) \
-  ((fl) | FUTEX_PRIVATE_FLAG)
-# else
-#  define __lll_private_flag(fl, private) \
-  ((fl) | THREAD_GETMEM (THREAD_SELF, header.private_futex))
-# endif
-#else
-# ifdef __ASSUME_PRIVATE_FUTEX
-#  define __lll_private_flag(fl, private) \
-  (((fl) | FUTEX_PRIVATE_FLAG) ^ (private))
-# else
-#  define __lll_private_flag(fl, private) \
-  (__builtin_constant_p (private)					      \
-   ? ((private) == 0							      \
-      ? ((fl) | THREAD_GETMEM (THREAD_SELF, header.private_futex))	      \
-      : (fl))								      \
-   : ((fl) | (((private) ^ FUTEX_PRIVATE_FLAG)				      \
-	      & THREAD_GETMEM (THREAD_SELF, header.private_futex))))
-# endif
-#endif
-
-#define lll_futex_wait(futex, val, private) \
-  lll_futex_timed_wait (futex, val, NULL, private)
-
-#define lll_futex_timed_wait(futexp, val, timespec, private) \
-  ({									      \
-    INTERNAL_SYSCALL_DECL (__err);					      \
-									      \
-    INTERNAL_SYSCALL (futex, __err, 4, (futexp),		      \
-			      __lll_private_flag (FUTEX_WAIT, private),	      \
-			      (val), (timespec));			      \
-  })
-
-#define lll_futex_timed_wait_bitset(futexp, val, timespec, clockbit, private) \
-  ({									      \
-    INTERNAL_SYSCALL_DECL (__err);					      \
-    int __op = FUTEX_WAIT_BITSET | clockbit;				      \
-									      \
-    INTERNAL_SYSCALL (futex, __err, 6, (futexp),		      \
-			      __lll_private_flag (__op, private),	      \
-			      (val), (timespec), NULL /* Unused.  */, 	      \
-			      FUTEX_BITSET_MATCH_ANY);			      \
-  })
-
-#define lll_futex_wake(futexp, nr, private) \
-  ({									      \
-    INTERNAL_SYSCALL_DECL (__err);					      \
-									      \
-    INTERNAL_SYSCALL (futex, __err, 4, (futexp),		      \
-			      __lll_private_flag (FUTEX_WAKE, private),	      \
-			      (nr), 0);					      \
-  })
-
-
-/* Returns non-zero if error happened, zero if success.  */
-#define lll_futex_requeue(futexp, nr_wake, nr_move, mutex, val, private) \
-  ({									      \
-    INTERNAL_SYSCALL_DECL (__err);					      \
-    long int __ret;							      \
-									      \
-    __ret = INTERNAL_SYSCALL (futex, __err, 6, (futexp),		      \
-			      __lll_private_flag (FUTEX_CMP_REQUEUE, private),\
-			      (nr_wake), (nr_move), (mutex), (val));	      \
-    INTERNAL_SYSCALL_ERROR_P (__ret, __err);				      \
-  })
-
-/* Returns non-zero if error happened, zero if success.  */
-#define lll_futex_wake_unlock(futexp, nr_wake, nr_wake2, futexp2, private) \
-  ({									      \
-    INTERNAL_SYSCALL_DECL (__err);					      \
-    long int __ret;							      \
-									      \
-    __ret = INTERNAL_SYSCALL (futex, __err, 6, (futexp),		      \
-			      __lll_private_flag (FUTEX_WAKE_OP, private),    \
-			      (nr_wake), (nr_wake2), (futexp2),		      \
-			      FUTEX_OP_CLEAR_WAKE_IF_GT_ONE);		      \
-    INTERNAL_SYSCALL_ERROR_P (__ret, __err);				      \
-  })
-
-/* Priority Inheritance support.  */
-#define lll_futex_wait_requeue_pi(futexp, val, mutex, private) \
-  lll_futex_timed_wait_requeue_pi (futexp, val, NULL, 0, mutex, private)
-
-#define lll_futex_timed_wait_requeue_pi(futexp, val, timespec, clockbit,      \
-					mutex, private)			      \
-  ({									      \
-    INTERNAL_SYSCALL_DECL (__err);					      \
-    int __op = FUTEX_WAIT_REQUEUE_PI | clockbit;			      \
-									      \
-    INTERNAL_SYSCALL (futex, __err, 5, (futexp),			      \
-		      __lll_private_flag (__op, private),		      \
-		      (val), (timespec), mutex); 			      \
-  })
-
-#define lll_futex_cmp_requeue_pi(futexp, nr_wake, nr_move, mutex, val, priv)  \
-  ({									      \
-    INTERNAL_SYSCALL_DECL (__err);					      \
-    long int __ret;							      \
-									      \
-    __ret = INTERNAL_SYSCALL (futex, __err, 6, (futexp),		      \
-			      __lll_private_flag (FUTEX_CMP_REQUEUE_PI, priv),\
-			      (nr_wake), (nr_move), (mutex), (val));	      \
-    INTERNAL_SYSCALL_ERROR_P (__ret, __err);				      \
-  })
 
 #define lll_compare_and_swap(futex, oldval, newval, operation) \
   do {									      \