[v3,0/4] Add CLOCK_MONOTONIC support for PI mutexes

Message ID 20210906204740.3988273-1-adhemerval.zanella@linaro.org
Headers
Series Add CLOCK_MONOTONIC support for PI mutexes |

Message

Adhemerval Zanella Sept. 6, 2021, 8:47 p.m. UTC
  It adds support for CLOCK_MONOTONIC for PI mutexes by using the new
Linux v5.14 FUTEX_LOCK_PI2 operation.  Similar to current approach,
pthread_mutex_clocklock might return EINVAL if the underlying kernel
has no support for the futex operation.

Changes since v2:

  * Renamed xpthread_mutex_pi_support_monotonic to
    support_mutex_pi_monotonic.

Changes since v1:
  
  * Refactor futex_lock_pi64 and avoid adding futex_lock_pi2.  The
    FUTEX_LOCK_PI2 logic is done at only one place, so the code change
    on pthread routines are minimal.  Also, FUTEX_LOCK_PI2 is only
    used if it is really required, i.e, when a timeout against
    CLOCK_MONOTONIC is used.
  * Do not remove nptl/tst-mutexpi10.c, but instead adjust it to new
    FUTEX_LOCK_PI2 support.
  * Add pthread_mutex_pi_support_monotonic() to check if monotonic
    clock with PI mutexes are supported and use on test to check for
    the expected result.

Adhemerval Zanella (3):
  nptl: Use FUTEX_LOCK_PI2 when available
  support: Add support_mutex_pi_monotonic
  nptl: Add CLOCK_MONOTONIC support for PI mutexes

Kurt Kanzenbach (1):
  Linux: Add FUTEX_LOCK_PI2

 nptl/futex-internal.c                     | 63 +++++++++++++++++++++++
 nptl/pthread_mutex_lock.c                 |  3 +-
 nptl/pthread_mutex_timedlock.c            | 10 +---
 nptl/tst-mutexpi10.c                      | 42 +++++++++------
 support/Makefile                          |  1 +
 support/support_mutex_pi_monotonic.c      | 33 ++++++++++++
 support/xthread.h                         |  4 ++
 sysdeps/nptl/futex-internal.h             | 58 ++-------------------
 sysdeps/nptl/lowlevellock-futex.h         |  1 +
 sysdeps/pthread/tst-mutex5.c              | 23 ++++++---
 sysdeps/pthread/tst-mutex9.c              | 20 ++++---
 sysdeps/unix/sysv/linux/kernel-features.h |  8 +++
 12 files changed, 172 insertions(+), 94 deletions(-)
 create mode 100644 support/support_mutex_pi_monotonic.c
  

Comments

Adhemerval Zanella Sept. 27, 2021, 1:48 p.m. UTC | #1
Ping on the set.

On 06/09/2021 17:47, Adhemerval Zanella wrote:
> It adds support for CLOCK_MONOTONIC for PI mutexes by using the new
> Linux v5.14 FUTEX_LOCK_PI2 operation.  Similar to current approach,
> pthread_mutex_clocklock might return EINVAL if the underlying kernel
> has no support for the futex operation.
> 
> Changes since v2:
> 
>   * Renamed xpthread_mutex_pi_support_monotonic to
>     support_mutex_pi_monotonic.
> 
> Changes since v1:
>   
>   * Refactor futex_lock_pi64 and avoid adding futex_lock_pi2.  The
>     FUTEX_LOCK_PI2 logic is done at only one place, so the code change
>     on pthread routines are minimal.  Also, FUTEX_LOCK_PI2 is only
>     used if it is really required, i.e, when a timeout against
>     CLOCK_MONOTONIC is used.
>   * Do not remove nptl/tst-mutexpi10.c, but instead adjust it to new
>     FUTEX_LOCK_PI2 support.
>   * Add pthread_mutex_pi_support_monotonic() to check if monotonic
>     clock with PI mutexes are supported and use on test to check for
>     the expected result.
> 
> Adhemerval Zanella (3):
>   nptl: Use FUTEX_LOCK_PI2 when available
>   support: Add support_mutex_pi_monotonic
>   nptl: Add CLOCK_MONOTONIC support for PI mutexes
> 
> Kurt Kanzenbach (1):
>   Linux: Add FUTEX_LOCK_PI2
> 
>  nptl/futex-internal.c                     | 63 +++++++++++++++++++++++
>  nptl/pthread_mutex_lock.c                 |  3 +-
>  nptl/pthread_mutex_timedlock.c            | 10 +---
>  nptl/tst-mutexpi10.c                      | 42 +++++++++------
>  support/Makefile                          |  1 +
>  support/support_mutex_pi_monotonic.c      | 33 ++++++++++++
>  support/xthread.h                         |  4 ++
>  sysdeps/nptl/futex-internal.h             | 58 ++-------------------
>  sysdeps/nptl/lowlevellock-futex.h         |  1 +
>  sysdeps/pthread/tst-mutex5.c              | 23 ++++++---
>  sysdeps/pthread/tst-mutex9.c              | 20 ++++---
>  sysdeps/unix/sysv/linux/kernel-features.h |  8 +++
>  12 files changed, 172 insertions(+), 94 deletions(-)
>  create mode 100644 support/support_mutex_pi_monotonic.c
>
  
Adhemerval Zanella Oct. 1, 2021, 11:42 a.m. UTC | #2
I will push this set shortly if no one opposes it.

On 27/09/2021 10:48, Adhemerval Zanella wrote:
> Ping on the set.
> 
> On 06/09/2021 17:47, Adhemerval Zanella wrote:
>> It adds support for CLOCK_MONOTONIC for PI mutexes by using the new
>> Linux v5.14 FUTEX_LOCK_PI2 operation.  Similar to current approach,
>> pthread_mutex_clocklock might return EINVAL if the underlying kernel
>> has no support for the futex operation.
>>
>> Changes since v2:
>>
>>   * Renamed xpthread_mutex_pi_support_monotonic to
>>     support_mutex_pi_monotonic.
>>
>> Changes since v1:
>>   
>>   * Refactor futex_lock_pi64 and avoid adding futex_lock_pi2.  The
>>     FUTEX_LOCK_PI2 logic is done at only one place, so the code change
>>     on pthread routines are minimal.  Also, FUTEX_LOCK_PI2 is only
>>     used if it is really required, i.e, when a timeout against
>>     CLOCK_MONOTONIC is used.
>>   * Do not remove nptl/tst-mutexpi10.c, but instead adjust it to new
>>     FUTEX_LOCK_PI2 support.
>>   * Add pthread_mutex_pi_support_monotonic() to check if monotonic
>>     clock with PI mutexes are supported and use on test to check for
>>     the expected result.
>>
>> Adhemerval Zanella (3):
>>   nptl: Use FUTEX_LOCK_PI2 when available
>>   support: Add support_mutex_pi_monotonic
>>   nptl: Add CLOCK_MONOTONIC support for PI mutexes
>>
>> Kurt Kanzenbach (1):
>>   Linux: Add FUTEX_LOCK_PI2
>>
>>  nptl/futex-internal.c                     | 63 +++++++++++++++++++++++
>>  nptl/pthread_mutex_lock.c                 |  3 +-
>>  nptl/pthread_mutex_timedlock.c            | 10 +---
>>  nptl/tst-mutexpi10.c                      | 42 +++++++++------
>>  support/Makefile                          |  1 +
>>  support/support_mutex_pi_monotonic.c      | 33 ++++++++++++
>>  support/xthread.h                         |  4 ++
>>  sysdeps/nptl/futex-internal.h             | 58 ++-------------------
>>  sysdeps/nptl/lowlevellock-futex.h         |  1 +
>>  sysdeps/pthread/tst-mutex5.c              | 23 ++++++---
>>  sysdeps/pthread/tst-mutex9.c              | 20 ++++---
>>  sysdeps/unix/sysv/linux/kernel-features.h |  8 +++
>>  12 files changed, 172 insertions(+), 94 deletions(-)
>>  create mode 100644 support/support_mutex_pi_monotonic.c
>>