From patchwork Fri Dec 16 16:31:57 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Liebler X-Patchwork-Id: 18515 Received: (qmail 16378 invoked by alias); 16 Dec 2016 16:32:14 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 16302 invoked by uid 89); 16 Dec 2016 16:32:14 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.1 required=5.0 tests=AWL, BAYES_00, KAM_LAZY_DOMAIN_SECURITY, RCVD_IN_DNSWL_LOW, RCVD_IN_SEMBACKSCATTER autolearn=no version=3.3.2 spammy=acquired, 16, 9, 2003-2016, 20032016 X-HELO: mx0a-001b2d01.pphosted.com From: Stefan Liebler To: libc-alpha@sourceware.org Cc: Stefan Liebler Subject: [PATCH 2/2] S390: Use generic spinlock code. Date: Fri, 16 Dec 2016 17:31:57 +0100 In-Reply-To: <1481905917-15654-1-git-send-email-stli@linux.vnet.ibm.com> References: <1481905917-15654-1-git-send-email-stli@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 X-Content-Scanned: Fidelis XPS MAILER x-cbid: 16121616-0020-0000-0000-000002DFCBF8 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 16121616-0021-0000-0000-00003FBC72C2 Message-Id: <1481905917-15654-2-git-send-email-stli@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2016-12-16_10:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=4 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1612050000 definitions=main-1612160260 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 , 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 - . */ - -/* 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 . */ -#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 " because + it will resolve to this very file. Using "sysdeps/.." as reference to the + top level directory does the job. */ +#include 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 . */ -#include -#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 " because + it will resolve to this very file. Using "sysdeps/.." as reference to the + top level directory does the job. */ +#include 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 , 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 - . */ - -/* 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)