about summary refs log tree commit diff
path: root/nptl
Commit message (Collapse)AuthorAgeFilesLines
* nptl: Remove connect from libpthreadAdhemerval Zanella2021-03-182-4/+1
| | | | | | The libc version is identical and built with same flags. Checked on x86_64-linux-gnu.
* nptl: Remove accept from libpthreadAdhemerval Zanella2021-03-182-3/+0
| | | | | | The libc version is identical and built with same flags. Checked on x86_64-linux-gnu.
* nptl: Remove close from libpthreadAdhemerval Zanella2021-03-182-4/+1
| | | | | | The libc version is identical and built with same flags. Checked on x86_64-linux-gnu.
* nptl: Remove read from libpthreadAdhemerval Zanella2021-03-182-4/+1
| | | | | | The libc version is identical and built with same flags. Checked on x86_64-linux-gnu.
* nptl: Remove write from libpthreadAdhemerval Zanella2021-03-183-5/+2
| | | | | | The libc version is identical and built with same flags. Checked on x86_64-linux-gnu.
* nptl: Move fork into libcAdhemerval Zanella2021-03-123-52/+0
| | | | | | | | This is part of the libpthread removal project: <https://sourceware.org/ml/libc-alpha/2019-10/msg00080.html> Checked on x86_64-linux-gnu.
* posix: Consolidate register-atforkAdhemerval Zanella2021-03-122-151/+0
| | | | | | | | | | | | | Both htl and nptl uses a different data structure to implement atfork handlers. The nptl one was refactored by 27761a1042d to use a dynarray which simplifies the code. This patch moves the nptl one to be the generic implementation and replace Hurd linked one. Different than previous NPTL, Hurd also uses a global lock, so performance should be similar. Checked on x86_64-linux-gnu, i686-linux-gnu, and with a build for i686-gnu.
* nptl: Move Linux pthread_kill to nptlAdhemerval Zanella2021-03-121-9/+17
| | | | | | | The nptl already expects a Linux syscall internally. Also __is_internal_signal is used and the DEBUGGING_P check is removed. Checked on x86_64-linux-gnu.
* nptl: Fix __pthread_clockjoin_np64 __pthread_timedjoin_np64 hidden protoAdhemerval Zanella2021-03-053-4/+4
| | | | They are both implemented in libpthread instead of libc.
* [PATCH] pthread_once hangs when init routine throws an exception [BZ #18435]Jakub Jelinek2021-03-044-9/+64
| | | | | | | | | | | | | | | | | | | | | | | | | | | | This is another attempt at making pthread_once handle throwing exceptions from the init routine callback. As the new testcases show, just switching to the cleanup attribute based cleanup does fix the tst-once5 test, but breaks the new tst-oncey3 test. That is because when throwing exceptions, only the unwind info registered cleanups (i.e. C++ destructors or cleanup attribute), when cancelling threads and there has been unwind info from the cancellation point up to whatever needs cleanup both unwind info registered cleanups and THREAD_SETMEM (self, cleanup, ...) registered cleanups are invoked, but once we hit some frame with no unwind info, only the THREAD_SETMEM (self, cleanup, ...) registered cleanups are invoked. So, to stay fully backwards compatible (allow init routines without unwind info which encounter cancellation points) and handle exception throwing we actually need to register the pthread_once cleanups in both unwind info and in the THREAD_SETMEM (self, cleanup, ...) way. If an exception is thrown, only the former will happen and we in that case need to also unregister the THREAD_SETMEM (self, cleanup, ...) registered handler, because otherwise after catching the exception the user code could call deeper into the stack some cancellation point, get cancelled and then a stale cleanup handler would clobber stack and probably crash. If a thread calling init routine is cancelled and unwind info ends before the pthread_once frame, it will be cleaned up through self->cleanup as before. And if unwind info is present, unwind_stop first calls the self->cleanup registered handler for the frame, then it will call the unwind info registered handler but that will already see __do_it == 0 and do nothing.
* nptl: Use <unwind-link.h> for accessing the libgcc_s unwinderFlorian Weimer2021-03-013-4/+6
| | | | Reviewed-by: Carlos O'Donell <carlos@redhat.com>
* nptl: Move elision implementations into libcFlorian Weimer2021-02-2312-39/+101
| | | | | | | | | | | | | | | | | | 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.)
* nptl: Move futex-internal into libcFlorian Weimer2021-02-223-5/+5
| | | | | | | | This moves __futex_abstimed_wait64 and __futex_abstimed_wait_cancelable64 and exports these functions as GLIBC_PRIVATE. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
* nptl: Move lowlevellock into libc [BZ #15648]Florian Weimer2021-02-224-26/+5
| | | | | | And export __lll_lock_wait and __lll_lock_wait_private as GLIBC_PRIVATE. This should eliminate the need for the previous riscv kludge.
* nptl: Move futex-internal.c into main nptl directoryFlorian Weimer2021-02-222-0/+129
| | | | Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
* nptl: Reformat VersionsFlorian Weimer2021-02-221-188/+279
| | | | | | One symbol per line, lexicographically ordered. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
* nptl: Split libpthread-routines into one routine per lineFlorian Weimer2021-02-221-86/+152
| | | | | | | And sort the lines lexicographically. This will make it easier to review patches which move symbols from libpthread to libc. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
* pthread: Refactor semaphore codeAdhemerval Zanella2021-02-082-22/+1
| | | | | | | | | | | The internal semaphore list code is moved to a specific file, sem_routine.c, and the internal usage is simplified to only two functions (one to insert a new semaphore and one to remove it from the internal list). There is no need to expose the internal locking, neither how the semaphore mapping is implemented. No functional or semantic change is expected, tested on x86_64-linux-gnu.
* linux: Require /dev/shm as the shared memory file systemFlorian Weimer2021-02-084-4/+0
| | | | | | | | | | | | | | | | | | | | | Previously, glibc would pick an arbitrary tmpfs file system from /proc/mounts if /dev/shm was not available. This could lead to an unsuitable file system being picked for the backing storage for shm_open, sem_open, and related functions. This patch introduces a new function, __shm_get_name, which builds the file name under the appropriate (now hard-coded) directory. It is called from the various shm_* and sem_* function. Unlike the SHM_GET_NAME macro it replaces, the callers handle the return values and errno updates. shm-directory.c is moved directly into the posix subdirectory because it can be implemented directly using POSIX functionality. It resides in libc because it is needed by both librt and nptl/htl. In the sem_open implementation, tmpfname is initialized directly from a string constant. This happens to remove one alloca call. Checked on x86_64-linux-gnu.
* nptl: Fix comment typo in pthread_cond_wait.cJangwoong Kim2021-01-041-1/+1
|
* nptl: Remove set*id, set*gid files which are not builtFlorian Weimer2021-01-049-28/+0
|
* Update copyright dates not handled by scripts/update-copyrights.Paul Eggert2021-01-021-1/+1
| | | | | | | | | | | | | | I've updated copyright dates in glibc for 2021. This is the patch for the changes not generated by scripts/update-copyrights and subsequent build / regeneration of generated files. As well as the usual annual updates, mainly dates in --version output (minus csu/version.c which previously had to be handled manually but is now successfully updated by update-copyrights), there is a small change to the copyright notice in NEWS which should let NEWS get updated automatically next year. Please remember to include 2021 in the dates for any new files added in future (which means updating any existing uncommitted patches you have that add new files to use the new copyright dates in them).
* Update copyright dates with scripts/update-copyrightsPaul Eggert2021-01-02280-280/+280
| | | | | | | | | | | | | | | | I used these shell commands: ../glibc/scripts/update-copyrights $PWD/../gnulib/build-aux/update-copyright (cd ../glibc && git commit -am"[this commit message]") and then ignored the output, which consisted lines saying "FOO: warning: copyright statement not found" for each of 6694 files FOO. I then removed trailing white space from benchtests/bench-pthread-locks.c and iconvdata/tst-iconv-big5-hkscs-to-2ucs4.c, to work around this diagnostic from Savannah: remote: *** pre-commit check failed ... remote: *** error: lines with trailing whitespace found remote: error: hook declined to update refs/heads/master
* {nptl,htl}/semaphoreP.h: clean upSamuel Thibault2020-12-161-2/+2
| | | | | This removes "Contributed by", and uses a C99 flexible array instead of char name[0];
* htl: Get sem_open/sem_close/sem_unlink support [BZ #25524]Samuel Thibault2020-12-163-439/+0
| | | | | This just moves the existing nptl implementation to reuse as it is in htl.
* pthread: Move semaphore initialization for open to semaphoreP.hSamuel Thibault2020-12-162-11/+16
| | | | | This allows to easily reuse all of the sem_open/sem_close/sem_unlink implementations in the various ports.
* nptl: Fix __futex_clocklock64 return error check [BZ #26964]Lucas A. M. Magalhaes2020-12-012-1/+139
| | | | | | | | | | | | | | | | | The earlier implementation of this, __lll_clocklock, calls lll_clockwait that doesn't return the futex syscall error codes. It always tries again if that fails. However in the current implementation, when the futex returns EAGAIN, __futex_clocklock64 will also return EGAIN, even if the futex is taken. This patch fixes the EAGAIN issue and also adds a check for EINTR. As futex syscall can return EINTR if the thread is interrupted by a signal. In this case I'm assuming the function should continue trying to lock as there is no mention to about it on POSIX. Also add a test for both scenarios. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
* y2038: Convert aio_suspend to support 64 bit timeLukasz Majewski2020-11-301-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The aio_suspend function has been converted to support 64 bit time. This change uses (in aio_misc.h): - __futex_abstimed_wait64 (instead of futex_reltimed_wait) - __futex_abstimed_wait_cancellable64 (instead of futex_reltimed_wait_cancellable) from ./sysdeps/nptl/futex-helpers.h The aio_suspend() accepts relative timeout, which then is converted to absolute one. The i686-gnu port (HURD) do not define DONT_NEED_AIO_MISC_COND and as it doesn't (yet) support 64 bit time it uses not converted pthread_cond_timedwait(). The __aio_suspend() is supposed to be run on ports with __TIMESIZE !=64 and __WORDSIZE==32. It internally utilizes __aio_suspend_time64() and hence the conversion from 32 bit struct timespec to 64 bit one is required. For ports supporting 64 bit time the __aio_suspend_time64() will be used either via alias (to __aio_suspend when __TIMESIZE==64) or redirection (when -D_TIME_BITS=64 is passed). Build tests: ./src/scripts/build-many-glibcs.py glibcs Reviewed-by: Alistair Francis <alistair.francis@wdc.com> Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
* nptl: Add EOVERFLOW checks for futex callsAdhemerval Zanella2020-11-274-13/+13
| | | | | | | | | | | | | | | | | | | | | Some futex-internal calls require additional check for EOVERFLOW (as indicated by [1] [2] [3]). For both mutex and rwlock code, EOVERFLOW is handle as ETIMEDOUT; since it indicate to the caller that the blocking operation could not be issued. For mutex it avoids a possible issue where PTHREAD_MUTEX_ROBUST_* might assume EOVERFLOW indicate futex has succeed, and for PTHREAD_MUTEX_PP_* it avoid a potential busy infinite loop. For rwlock and semaphores, it also avoids potential busy infinite loops. Checked on x86_64-linux-gnu and i686-linux-gnu, although EOVERFLOW won't be possible with current usage (since all timeouts on 32-bit architectures with 32-bit time_t support will be in the range of 32-bit time_t). [1] https://sourceware.org/pipermail/libc-alpha/2020-November/120079.html [2] https://sourceware.org/pipermail/libc-alpha/2020-November/120080.html [3] https://sourceware.org/pipermail/libc-alpha/2020-November/120127.html
* nptl: Fix PTHREAD_PRIO_PROTECT timed lockAdhemerval Zanella2020-11-274-25/+11
| | | | | | | | | | | | | | | | | The 878fe624d4 changed lll_futex_timed_wait, which expects a relative timeout, with a __futex_abstimed_wait64, which expects an absolute timeout. However the code still passes a relative timeout. Also, the PTHREAD_PRIO_PROTECT support for clocks different than CLOCK_REALTIME was broken since the inclusion of pthread_mutex_clocklock (9d20e22e46) since lll_futex_timed_wait always use CLOCK_REALTIME. This patch fixes by removing the relative time calculation. It also adds some xtests that tests both thread and inter-process usage. Checked on x86_64-linux-gnu.
* nptl: Return EINVAL for invalid clock for pthread_clockjoin_npAdhemerval Zanella2020-11-251-0/+4
| | | | | | | | | The align the GNU extension with the others one that accept specify which clock to wait for (such as pthread_mutex_clocklock). Check on x86_64-linux-gnu. Reviewed-by: Lukasz Majewski <lukma@denx.de>
* nptl: Return EINVAL for pthread_mutex_clocklock/PI with CLOCK_MONOTONIC [BZ ↵Adhemerval Zanella2020-11-253-1/+76
| | | | | | | | | | | | | | | | #26801] Linux futex FUTEX_LOCK_PI operation only supports CLOCK_REALTIME, so pthread_mutex_clocklock operation with priority aware mutexes may fail depending of the input timeout. Also, it is not possible to convert a CLOCK_MONOTONIC to a CLOCK_REALTIME due the possible wall clock time change which might invalid the requested timeout. Checked on x86_64-linux-gnu and i686-linux-gnu. Reviewed-by: Lukasz Majewski <lukma@denx.de>
* nptl: Replace lll_futex_wake with futex-internal.hAdhemerval Zanella2020-11-253-12/+7
| | | | | | | | | The idea is to make NPTL implementation to use on the functions provided by futex-internal.h. Checked on x86_64-linux-gnu and i686-linux-gnu. Reviewed-by: Lukasz Majewski <lukma@denx.de>
* nptl: Replace lll_futex_supported_clockid with futex-internal.hAdhemerval Zanella2020-11-251-1/+1
| | | | | | | | | The idea is to make NPTL implementation to use on the functions provided by futex-internal.h. Checked on x86_64-linux-gnu and i686-linux-gnu. Reviewed-by: Lukasz Majewski <lukma@denx.de>
* nptl: Replace lll_futex_{timed_}wait by futex-internal.hAdhemerval Zanella2020-11-254-12/+14
| | | | | | | | | The idea is to make NPTL implementation to use on the functions provided by futex-internal.h. Checked on x86_64-linux-gnu and i686-linux-gnu. Reviewed-by: Lukasz Majewski <lukma@denx.de>
* nptl: Replace lll_timedwait with __futex_abstimed_wait64Adhemerval Zanella2020-11-253-65/+2
| | | | | | Checked with x86_64-linux-gnu and i686-linux-gnu. Reviewed-by: Lukasz Majewski <lukma@denx.de>
* nptl: Replace __futex_clocklock_wait64 with __futex_abstimed_wait64Adhemerval Zanella2020-11-251-2/+2
| | | | | | | | | | | | | | | | | For non null timeouts, the __futex_clocklock_wait64 creates an a relative timeout by subtracting the current time from the input argument. The same behavior can be obtained with FUTEX_WAIT_BITSET without the need to calculate the relative timeout. Besides consolidate the code it also avoid the possible relative timeout issues [1]. The __futex_abstimed_wait64 needs also to return EINVAL syscall errors. Checked on x86_64-linux-gnu and i686-linux-gnu. [1] https://sourceware.org/pipermail/libc-alpha/2020-November/119881.html Reviewed-by: Lukasz Majewski <lukma@denx.de>
* nptl: Remove _futex_clock_wait_bitset64Adhemerval Zanella2020-11-251-3/+4
| | | | | | | | It can be replaced with a __futex_abstimed_wait64 call. Checked on x86_64-linux-gnu and i686-linux-gnu. Reviewed-by: Lukasz Majewski <lukma@denx.de>
* nptl: Remove clockwait_tidAdhemerval Zanella2020-11-251-58/+18
| | | | | | | | | | | It can be replaced with a __futex_abstimed_wait_cancelable64 call, with the advantage that there is no need to further clock adjustments to create a absolute timeout. It allows to remove the now ununsed futex_timed_wait_cancel64 internal function. Checked on x86_64-linux-gnu and i686-linux-gnu. Reviewed-by: Lukasz Majewski <lukma@denx.de>
* nptl: Remove futex_wait_cancelableAdhemerval Zanella2020-11-251-20/+2
| | | | | | | | | It is used solely on __pthread_cond_wait_common and the call can be replaced by a __futex_abstimed_wait_cancelable64 one. Checked on x86_64-linux-gnu and i686-linux-gnu. Reviewed-by: Lukasz Majewski <lukma@denx.de>
* nptl: Remove unused internal futex functionsAdhemerval Zanella2020-11-251-2/+1
| | | | | | | | | | The __futex_abstimed_wait usage was remove with 3102e28bd11 and the __futex_abstimed_wait_cancelable by 323592fdc92 and b8d3e8fbaac. The futex_lock_pi can be replaced by a futex_lock_pi64. Checked on x86_64-linux-gnu and i686-linux-gnu. Reviewed-by: Lukasz Majewski <lukma@denx.de>
* Add {,sysdep-}ld-library-path make variableSamuel Thibault2020-11-161-1/+1
| | | | | | | | On GNU/Hurd we not only need $(common-objpfx) in LD_LIBRARY_PATH when loading dynamic objects, but also $(common-objpfx)/mach and $(common-objpfx)/hurd. This adds an ld-library-path variable to be used as LD_LIBRARY_PATH basis in Makefiles, and a sysdep-ld-library-path variable for sysdeps to add some more paths, here mach/ and hurd/.
* nptl: Move stack list variables into _rtld_globalFlorian Weimer2020-11-165-126/+47
| | | | | | | | | Now __thread_gscope_wait (the function behind THREAD_GSCOPE_WAIT, formerly __wait_lookup_done) can be implemented directly in ld.so, eliminating the unprotected GL (dl_wait_lookup_done) function pointer. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
* nptl: Eliminate <smp.h> and __is_smpFlorian Weimer2020-11-136-43/+0
| | | | | | | | | | | Most systems are SMP, so optimizing for the UP case is no longer approriate. A dynamic check based on the kernel identification has been only implemented for i386 anyway. To disable adaptive mutexes on sh, define DEFAULT_ADAPTIVE_COUNT as zero for this architecture. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
* tst-setuid1-static-ENV: Add $(common-objpfx)nss [BZ #26820]H.J. Lu2020-11-031-1/+1
| | | | | | | | | | | | | | | | | | commit def674652eeac60c386d04733318b311f8a5b620 Author: Florian Weimer <fweimer@redhat.com> Date: Mon Apr 27 15:00:14 2020 +0200 nptl/tst-setuid1-static: Improve isolation from system objects Static dlopen needs an LD_LIBRARY_PATH setting to avoid loading system libraries. missed $(common-objpfx)nss. Add $(common-objpfx)nss to LD_LIBRARY_PATH for tst-setuid1-static to support struct passwd *pwd = getpwnam ("nobody"); in nptl/tst-setuid1.c.
* Disable spurious -Wstringop-overflow for setjmp/longjmp (bug 26647)Joseph Myers2020-10-302-0/+20
| | | | | | | | | | | | | | | | | Building glibc with GCC 11 fails with (among other warnings) spurious -Wstringop-overflow warnings from calls to setjmp and longjmp with a pointer to a pthread_unwind_buf that is smaller than jmp_buf. As discussed in bug 26647, the warning in libc-start.c is a false positive, because setjmp and longjmp do not access anything (the signal mask) beyond the common prefix of the two structures, so this patch disables the warning for that call to setjmp, as well as for two calls in NPTL code that produce the same warning and look like false positives for the same reason. Tested with build-many-glibcs.py for arm-linux-gnueabi, where this allows the build to get further. Reviewed-by: DJ Delorie <dj@redhat.com>
* y2038: nptl: Provide __futex_clock_wait_bitset64 to support 64 bit bitsetLukasz Majewski2020-10-211-1/+1
| | | | | | | | | | | | | | | The commit: "y2038: nptl: Convert pthread_mutex_{clock|timed}lock to support 64 bit" SHA1: 29e9874a048f47e2d46c40253036c8d2de921548 introduced support for 64 bit timeouts. Unfortunately, it was missing the code for bitset - i.e. lll_futex_clock_wait_bitset C preprocessor macro was used. As a result the 64 bit struct __timespec64 was coerced to 32 bit struct timespec and regression visible as timeout was observed (nptl/tst-robust10 on s390). Reported-by: Stefan Liebler <stli@linux.ibm.com> Tested-by: Stefan Liebler <stli@linux.ibm.com>
* y2038: nptl: Convert pthread_mutex_{clock|timed}lock to support 64 bitLukasz Majewski2020-10-152-20/+55
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The pthread_mutex_clocklock and pthread_mutex_timedlock have been converted to support 64 bit time. This change uses: - New __futex_clocklock_wait64 (instead of lll_timedwait) from ./sysdeps/nptl/futex-helpers.c and - New __futex_clocklock64 function (instead of lll_clocklock) - New futex_lock_pi64 defined in sysdeps/nptl/futex-internal.h The pthread_mutex_{clock|timed}lock only accepts absolute time. Moreover, there is no need to check for NULL passed as *abstime pointer to the syscalls as those calls have exported symbols marked with __nonull attribute for abstime. Some architectures - namely x86, powerpc and s390 - do support lock elision. For those - adjustments have been made in arch specific elision-*.c files to use __futex_clocklock64 instead of lll_clocklock. The __lll_lock_elision (aliased to __lll_clocklock_elision in e.g. sysdeps/unix/sysv/linux/s390/elision-timed.c) just uses, in this patch provided, __futex_clocklock64. For systems with __TIMESIZE != 64 && __WORDSIZE == 32: - Conversions between 64 bit time to 32 bit are necessary - Redirection to pthread_mutex_{clock|timed}lock will provide support for 64 bit time Build tests: ./src/scripts/build-many-glibcs.py glibcs Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
* Revert "Fix missing redirects in testsuite targets"Andreas Schwab2020-10-081-1/+1
| | | | | This reverts commit d5afb38503. The log files are actually created by the various shell scripts that drive the tests.
* y2038: nptl: Convert pthread_rwlock_{clock|timed}{rd|wr}lock to support 64 ↵Lukasz Majewski2020-10-048-31/+104
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | bit time The pthread_rwlock_clockrdlock, pthread_rwlock_clockwrlock, pthread_rwlock_timedrdlock and pthread_rwlock_timedwrlock have been converted to support 64 bit time. This change uses new futex_abstimed_wait64 function in ./sysdeps/nptl/futex-helpers.c, which uses futex_time64 where possible. The pthread_rwlock_{clock|timed}{rd|wr}lock only accepts absolute time. Moreover, there is no need to check for NULL passed as *abstime pointer to the syscalls as those calls have exported symbols marked with __nonull attribute for abstime. For systems with __TIMESIZE != 64 && __WORDSIZE == 32: - Conversions between 64 bit time to 32 bit are necessary - Redirection to pthread_rwlock_{clock|timed}{rd|wr}lock will provide support for 64 bit time Build tests: ./src/scripts/build-many-glibcs.py glibcs Run-time tests: - Run specific tests on ARM/x86 32bit systems (qemu): https://github.com/lmajewski/meta-y2038 and run tests: https://github.com/lmajewski/y2038-tests/commits/master Above tests were performed with Y2038 redirection applied as well as without to test the proper usage of both __pthread_rwlock_{clock|timed}{rd|wr}lock64 and __pthread_rwlock_{clock|timed}{rd|wr}lock. Reviewed-by: Alistair Francis <alistair.francis@wdc.com>