diff options
author | Florian Weimer <fweimer@redhat.com> | 2021-02-23 14:59:34 +0100 |
---|---|---|
committer | Florian Weimer <fweimer@redhat.com> | 2021-02-23 14:59:34 +0100 |
commit | 5a664d7ae8e42d641a7b4b436987ff67ab483b08 (patch) | |
tree | d2530831e3613ab86b5f536341304ac8cc98f452 /nptl | |
parent | 597d0267b5c4a925f0175837ec09df9f77e0a250 (diff) | |
download | glibc-5a664d7ae8e42d641a7b4b436987ff67ab483b08.zip glibc-5a664d7ae8e42d641a7b4b436987ff67ab483b08.tar.gz glibc-5a664d7ae8e42d641a7b4b436987ff67ab483b08.tar.bz2 |
nptl: Move elision implementations into libc
The elision interfaces are closely aligned between the targets that
implement them, so declare them in the generic <lowlevellock.h>
file.
Empty .c stubs are provided, so that fewer makefile updates
under sysdeps are needed. Also simplify initialization via
__libc_early_init.
The symbols __lll_clocklock_elision, __lll_lock_elision,
__lll_trylock_elision, __lll_unlock_elision, __pthread_force_elision
move into libc. For the time being, non-hidden references are used
from libpthread to access them, but once that part of libpthread
is moved into libc, hidden symbols will be used again. (Hidden
references seem desirable to reduce the likelihood of transactions
aborts.)
Diffstat (limited to 'nptl')
-rw-r--r-- | nptl/Makefile | 5 | ||||
-rw-r--r-- | nptl/Versions | 5 | ||||
-rw-r--r-- | nptl/elision-conf.c | 17 | ||||
-rw-r--r-- | nptl/elision-lock.c | 17 | ||||
-rw-r--r-- | nptl/elision-timed.c | 17 | ||||
-rw-r--r-- | nptl/elision-trylock.c | 17 | ||||
-rw-r--r-- | nptl/elision-unlock.c | 17 | ||||
-rw-r--r-- | nptl/lowlevellock.c | 5 | ||||
-rw-r--r-- | nptl/pthread_mutex_lock.c | 15 | ||||
-rw-r--r-- | nptl/pthread_mutex_timedlock.c | 13 | ||||
-rw-r--r-- | nptl/pthread_mutex_trylock.c | 8 | ||||
-rw-r--r-- | nptl/pthread_mutex_unlock.c | 4 |
12 files changed, 101 insertions, 39 deletions
diff --git a/nptl/Makefile b/nptl/Makefile index 4dd9c6a..5f85dd7 100644 --- a/nptl/Makefile +++ b/nptl/Makefile @@ -30,6 +30,11 @@ extra-libs-others := $(extra-libs) routines = \ alloca_cutoff \ + elision-conf \ + elision-lock \ + elision-timed \ + elision-trylock \ + elision-unlock \ forward \ futex-internal \ libc-cancellation \ diff --git a/nptl/Versions b/nptl/Versions index 6cca579..186befe 100644 --- a/nptl/Versions +++ b/nptl/Versions @@ -79,8 +79,12 @@ libc { __libc_current_sigrtmin_private; __libc_dl_error_tsd; __libc_pthread_init; + __lll_clocklock_elision; + __lll_lock_elision; __lll_lock_wait; __lll_lock_wait_private; + __lll_trylock_elision; + __lll_unlock_elision; __pthread_attr_copy; __pthread_attr_destroy; __pthread_attr_init; @@ -88,6 +92,7 @@ libc { __pthread_attr_setsigmask_internal; __pthread_cond_destroy; # Used by the C11 threads. __pthread_cond_init; # Used by the C11 threads. + __pthread_force_elision; __pthread_getattr_default_np; } } diff --git a/nptl/elision-conf.c b/nptl/elision-conf.c new file mode 100644 index 0000000..d71c30a --- /dev/null +++ b/nptl/elision-conf.c @@ -0,0 +1,17 @@ +/* elision-conf.c: Lock elision tunable parameters. Stub version. + Copyright (C) 2021 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + 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 + <https://www.gnu.org/licenses/>. */ diff --git a/nptl/elision-lock.c b/nptl/elision-lock.c new file mode 100644 index 0000000..a8235cb --- /dev/null +++ b/nptl/elision-lock.c @@ -0,0 +1,17 @@ +/* elision-lock.c: Lock elision locking. Stub version. + Copyright (C) 2021 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + 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 + <https://www.gnu.org/licenses/>. */ diff --git a/nptl/elision-timed.c b/nptl/elision-timed.c new file mode 100644 index 0000000..4723197 --- /dev/null +++ b/nptl/elision-timed.c @@ -0,0 +1,17 @@ +/* elision-lock.c: Lock elision timed locking. Stub version. + Copyright (C) 2021 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + 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 + <https://www.gnu.org/licenses/>. */ diff --git a/nptl/elision-trylock.c b/nptl/elision-trylock.c new file mode 100644 index 0000000..286a741 --- /dev/null +++ b/nptl/elision-trylock.c @@ -0,0 +1,17 @@ +/* elision-lock.c: Lock elision locking attempts. Stub version. + Copyright (C) 2021 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + 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 + <https://www.gnu.org/licenses/>. */ diff --git a/nptl/elision-unlock.c b/nptl/elision-unlock.c new file mode 100644 index 0000000..552a90a --- /dev/null +++ b/nptl/elision-unlock.c @@ -0,0 +1,17 @@ +/* elision-lock.c: Lock elision unlocking support. Stub version. + Copyright (C) 2021 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + 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 + <https://www.gnu.org/licenses/>. */ diff --git a/nptl/lowlevellock.c b/nptl/lowlevellock.c index 7976c6d..2d077d8 100644 --- a/nptl/lowlevellock.c +++ b/nptl/lowlevellock.c @@ -51,3 +51,8 @@ __lll_lock_wait (int *futex, int private) } } libc_hidden_def (__lll_lock_wait) + +#if ENABLE_ELISION_SUPPORT +int __pthread_force_elision __attribute__ ((nocommon)); +libc_hidden_data_def (__pthread_force_elision) +#endif diff --git a/nptl/pthread_mutex_lock.c b/nptl/pthread_mutex_lock.c index 319658a..f0de7b7 100644 --- a/nptl/pthread_mutex_lock.c +++ b/nptl/pthread_mutex_lock.c @@ -27,15 +27,6 @@ #include <futex-internal.h> #include <stap-probe.h> -#ifndef lll_lock_elision -#define lll_lock_elision(lock, try_lock, private) ({ \ - lll_lock (lock, private); 0; }) -#endif - -#ifndef lll_trylock_elision -#define lll_trylock_elision(a,t) lll_trylock(a) -#endif - /* Some of the following definitions differ when pthread_mutex_cond_lock.c includes this file. */ #ifndef LLL_MUTEX_LOCK @@ -52,10 +43,6 @@ PTHREAD_MUTEX_PSHARED (mutex)) #endif -#ifndef FORCE_ELISION -#define FORCE_ELISION(m, s) -#endif - static int __pthread_mutex_lock_full (pthread_mutex_t *mutex) __attribute_noinline__; @@ -80,7 +67,7 @@ __pthread_mutex_lock (pthread_mutex_t *mutex) LLL_MUTEX_LOCK (mutex); assert (mutex->__data.__owner == 0); } -#ifdef HAVE_ELISION +#if ENABLE_ELISION_SUPPORT else if (__glibc_likely (type == PTHREAD_MUTEX_TIMED_ELISION_NP)) { elision: __attribute__((unused)) diff --git a/nptl/pthread_mutex_timedlock.c b/nptl/pthread_mutex_timedlock.c index 8428ebc..5e52a4d 100644 --- a/nptl/pthread_mutex_timedlock.c +++ b/nptl/pthread_mutex_timedlock.c @@ -29,19 +29,6 @@ #include <stap-probe.h> -#ifndef lll_clocklock_elision -#define lll_clocklock_elision(futex, adapt_count, clockid, abstime, private) \ - __futex_clocklock64 (&(futex), clockid, abstime, private) -#endif - -#ifndef lll_trylock_elision -#define lll_trylock_elision(a,t) lll_trylock(a) -#endif - -#ifndef FORCE_ELISION -#define FORCE_ELISION(m, s) -#endif - int __pthread_mutex_clocklock_common (pthread_mutex_t *mutex, clockid_t clockid, diff --git a/nptl/pthread_mutex_trylock.c b/nptl/pthread_mutex_trylock.c index 5197275..e52ddda 100644 --- a/nptl/pthread_mutex_trylock.c +++ b/nptl/pthread_mutex_trylock.c @@ -23,14 +23,6 @@ #include <lowlevellock.h> #include <futex-internal.h> -#ifndef lll_trylock_elision -#define lll_trylock_elision(a,t) lll_trylock(a) -#endif - -#ifndef FORCE_ELISION -#define FORCE_ELISION(m, s) -#endif - int __pthread_mutex_trylock (pthread_mutex_t *mutex) { diff --git a/nptl/pthread_mutex_unlock.c b/nptl/pthread_mutex_unlock.c index e29bb7f..3b5ccda 100644 --- a/nptl/pthread_mutex_unlock.c +++ b/nptl/pthread_mutex_unlock.c @@ -24,10 +24,6 @@ #include <stap-probe.h> #include <futex-internal.h> -#ifndef lll_unlock_elision -#define lll_unlock_elision(a,b,c) ({ lll_unlock (a,c); 0; }) -#endif - static int __pthread_mutex_unlock_full (pthread_mutex_t *mutex, int decr) __attribute_noinline__; |