From: Stefan Liebler <stli@linux.vnet.ibm.com>
To: libc-alpha@sourceware.org
Cc: Stefan Liebler <stli@linux.vnet.ibm.com>
Subject: [PATCH 2/2] S390: Use generic spinlock code.
Date: Fri, 16 Dec 2016 16:32:00 -0000 [thread overview]
Message-ID: <1481905917-15654-2-git-send-email-stli@linux.vnet.ibm.com> (raw)
In-Reply-To: <1481905917-15654-1-git-send-email-stli@linux.vnet.ibm.com>
This patch removes the s390 specific implementation of spinlock code
and is now using the generic one.
For pthread_spin_trylock an explicit load and test before executing
compare and swap instruction is done as it is an interlock update even
if the lock is already acquired.
ChangeLog:
* sysdeps/s390/nptl/pthread_spin_init.c: Delete File.
* sysdeps/s390/nptl/pthread_spin_unlock.c: Likewise.
* sysdeps/s390/nptl/pthread_spin_lock.c:
(SPIN_LOCK_READS_BETWEEN_CMPXCHG): New define.
Use generic spinlock code.
* sysdeps/s390/nptl/pthread_spin_trylock.c:
(SPIN_TRYLOCK_USE_CMPXCHG_INSTEAD_OF_XCHG): New define.
Use generic spinlock code.
---
sysdeps/s390/nptl/pthread_spin_init.c | 19 -------------------
sysdeps/s390/nptl/pthread_spin_lock.c | 18 +++++-------------
sysdeps/s390/nptl/pthread_spin_trylock.c | 18 +++++-------------
sysdeps/s390/nptl/pthread_spin_unlock.c | 32 --------------------------------
4 files changed, 10 insertions(+), 77 deletions(-)
delete mode 100644 sysdeps/s390/nptl/pthread_spin_init.c
delete mode 100644 sysdeps/s390/nptl/pthread_spin_unlock.c
diff --git a/sysdeps/s390/nptl/pthread_spin_init.c b/sysdeps/s390/nptl/pthread_spin_init.c
deleted file mode 100644
index 7d3568f..0000000
--- a/sysdeps/s390/nptl/pthread_spin_init.c
+++ /dev/null
@@ -1,19 +0,0 @@
-/* Copyright (C) 2003-2016 Free Software Foundation, Inc.
- This file is part of the GNU C Library.
- Contributed by Martin Schwidefsky <schwidefsky@de.ibm.com>, 2003.
-
- The GNU C Library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- The GNU C Library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with the GNU C Library; if not, see
- <http://www.gnu.org/licenses/>. */
-
-/* Not needed. pthread_spin_init is an alias for pthread_spin_unlock. */
diff --git a/sysdeps/s390/nptl/pthread_spin_lock.c b/sysdeps/s390/nptl/pthread_spin_lock.c
index def6a24..d99cd81 100644
--- a/sysdeps/s390/nptl/pthread_spin_lock.c
+++ b/sysdeps/s390/nptl/pthread_spin_lock.c
@@ -16,17 +16,9 @@
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */
-#include "pthreadP.h"
+#define SPIN_LOCK_READS_BETWEEN_CMPXCHG 1000
-int
-pthread_spin_lock (pthread_spinlock_t *lock)
-{
- int oldval;
-
- __asm__ __volatile__ ("0: lhi %0,0\n"
- " cs %0,%2,%1\n"
- " jl 0b"
- : "=&d" (oldval), "=Q" (*lock)
- : "d" (1), "m" (*lock) : "cc" );
- return 0;
-}
+/* We can't use the normal "#include <nptl/pthread_spin_lock.c>" because
+ it will resolve to this very file. Using "sysdeps/.." as reference to the
+ top level directory does the job. */
+#include <sysdeps/../nptl/pthread_spin_lock.c>
diff --git a/sysdeps/s390/nptl/pthread_spin_trylock.c b/sysdeps/s390/nptl/pthread_spin_trylock.c
index 4c00e08..d7a2089 100644
--- a/sysdeps/s390/nptl/pthread_spin_trylock.c
+++ b/sysdeps/s390/nptl/pthread_spin_trylock.c
@@ -16,17 +16,9 @@
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */
-#include <errno.h>
-#include "pthreadP.h"
+#define SPIN_TRYLOCK_USE_CMPXCHG_INSTEAD_OF_XCHG 1
-int
-pthread_spin_trylock (pthread_spinlock_t *lock)
-{
- int old;
-
- __asm__ __volatile__ ("cs %0,%3,%1"
- : "=d" (old), "=Q" (*lock)
- : "0" (0), "d" (1), "m" (*lock) : "cc" );
-
- return old != 0 ? EBUSY : 0;
-}
+/* We can't use the normal "#include <nptl/pthread_spin_trylock.c>" because
+ it will resolve to this very file. Using "sysdeps/.." as reference to the
+ top level directory does the job. */
+#include <sysdeps/../nptl/pthread_spin_trylock.c>
diff --git a/sysdeps/s390/nptl/pthread_spin_unlock.c b/sysdeps/s390/nptl/pthread_spin_unlock.c
deleted file mode 100644
index 0dcc2d0..0000000
--- a/sysdeps/s390/nptl/pthread_spin_unlock.c
+++ /dev/null
@@ -1,32 +0,0 @@
-/* Copyright (C) 2003-2016 Free Software Foundation, Inc.
- This file is part of the GNU C Library.
- Contributed by Martin Schwidefsky <schwidefsky@de.ibm.com>, 2003.
-
- The GNU C Library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- The GNU C Library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with the GNU C Library; if not, see
- <http://www.gnu.org/licenses/>. */
-
-/* Ugly hack to avoid the declaration of pthread_spin_init. */
-#define pthread_spin_init pthread_spin_init_XXX
-#include "pthreadP.h"
-#undef pthread_spin_init
-
-int
-pthread_spin_unlock (pthread_spinlock_t *lock)
-{
- __asm__ __volatile__ (" xc %O0(4,%R0),%0\n"
- " bcr 15,0"
- : "=Q" (*lock) : "m" (*lock) : "cc" );
- return 0;
-}
-strong_alias (pthread_spin_unlock, pthread_spin_init)
--
2.3.0
next prev parent reply other threads:[~2016-12-16 16:32 UTC|newest]
Thread overview: 63+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-12-16 16:32 [PATCH 1/2] Optimize generic spinlock code and use C11 like atomic macros Stefan Liebler
2016-12-16 16:32 ` Stefan Liebler [this message]
2017-02-08 14:49 ` [PATCH 2/2] S390: Use generic spinlock code Stefan Liebler
2017-02-13 20:39 ` Torvald Riegel
2017-02-15 16:26 ` Stefan Liebler
2017-02-18 17:05 ` Torvald Riegel
2017-03-14 15:55 ` Stefan Liebler
2017-03-21 15:43 ` Stefan Liebler
2017-04-06 12:27 ` Torvald Riegel
2016-12-19 12:14 ` [PATCH 1/2] Optimize generic spinlock code and use C11 like atomic macros Szabolcs Nagy
2017-02-08 14:49 ` Stefan Liebler
2017-02-13 20:29 ` Torvald Riegel
2017-02-15 9:36 ` Stefan Liebler
2017-02-18 16:57 ` Torvald Riegel
2017-02-19 9:20 ` Florian Weimer
2017-02-20 13:11 ` Torvald Riegel
2017-02-26 7:55 ` Florian Weimer
2017-02-26 20:06 ` Torvald Riegel
2017-02-26 20:29 ` Florian Weimer
2017-02-26 20:35 ` Torvald Riegel
2017-02-27 17:57 ` Szabolcs Nagy
2017-02-28 7:15 ` Torvald Riegel
2017-03-14 15:55 ` Stefan Liebler
2017-02-20 12:15 ` Stefan Liebler
2017-02-20 13:51 ` Torvald Riegel
2017-03-14 15:55 ` Stefan Liebler
2017-03-21 15:43 ` Stefan Liebler
2017-03-22 12:56 ` Szabolcs Nagy
2017-03-23 16:16 ` Stefan Liebler
2017-03-23 17:52 ` Szabolcs Nagy
2017-04-06 12:04 ` Torvald Riegel
2017-03-27 13:08 ` Stefan Liebler
2017-04-04 10:29 ` [PING] " Stefan Liebler
2017-03-29 14:16 ` Stefan Liebler
2017-04-06 14:00 ` Torvald Riegel
2017-04-07 16:23 ` Stefan Liebler
2017-04-09 13:51 ` Torvald Riegel
2017-04-10 12:00 ` Stefan Liebler
2017-04-18 13:09 ` Stefan Liebler
2017-04-25 6:47 ` Stefan Liebler
2017-05-03 11:38 ` [PATCH 1/2] [PING] " Stefan Liebler
2017-05-10 13:00 ` Stefan Liebler
2017-05-17 13:09 ` Stefan Liebler
2017-05-24 6:37 ` Stefan Liebler
2017-05-30 7:18 ` Torvald Riegel
2017-05-31 8:29 ` Stefan Liebler
2017-05-31 16:48 ` Torvald Riegel
2017-06-01 13:40 ` Joseph Myers
2017-06-01 14:33 ` Torvald Riegel
2017-06-06 7:51 ` [PATCH 1/2] [COMMITTED] " Stefan Liebler
2017-04-10 8:17 ` [PATCH 1/2] " Andreas Schwab
2017-04-10 12:00 ` Stefan Liebler
2017-04-10 13:36 ` Andreas Schwab
2017-04-11 7:06 ` Stefan Liebler
2017-04-11 8:45 ` Andreas Schwab
2017-04-11 10:15 ` Stefan Liebler
2017-04-11 12:05 ` Andreas Schwab
2017-04-11 12:19 ` Stefan Liebler
2017-04-11 13:08 ` Zack Weinberg
2017-04-13 16:36 ` Torvald Riegel
2017-05-30 21:00 ` Tulio Magno Quites Machado Filho
2017-04-18 21:17 ` Joseph Myers
2017-04-19 8:27 ` Stefan Liebler
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1481905917-15654-2-git-send-email-stli@linux.vnet.ibm.com \
--to=stli@linux.vnet.ibm.com \
--cc=libc-alpha@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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 read-only IMAP folder(s) and NNTP newsgroup(s).