public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
* [PATCH v1 0/6] nptl: Introduce and use FUTEX_LOCK_PI2
@ 2021-06-25  8:10 Kurt Kanzenbach
  2021-06-25  8:10 ` [PATCH v1 1/6] Linux: Add FUTEX_LOCK_PI2 Kurt Kanzenbach
                   ` (7 more replies)
  0 siblings, 8 replies; 14+ messages in thread
From: Kurt Kanzenbach @ 2021-06-25  8:10 UTC (permalink / raw)
  To: libc-alpha
  Cc: Adhemerval Zanella, Florian Weimer, Carlos O'Donell,
	Lukasz Majewski, Thomas Gleixner, Sebastian Andrzej Siewior,
	Peter Zijlstra, Joseph Myers, Kurt Kanzenbach

Linux real time applications often make use of mutexes with priority inheritance
enabled due to problems such as unbounded priority inversion. In addition, some
applications make use of timeouts e.g., by utilizing pthread_mutex_clocklock().

However, the combination of priority inheritance enabled mutexes with timeouts
based on CLOCK_MONOTONIC doesn't work. That is because the underlying Linux
kernel futex interface didn't support it, yet. Using CLOCK_REALTIME is possible,
but it is subject to adjustments (NTP, PTP, ...). Therefore, Thomas proposed and
introduced a new futex operation called FUTEX_LOCK_PI2 with support for
selectable clocks [1].

Here is a proof of concept patch set adding FUTEX_LOCK_PI2 in order to support
pthread_mutex_clocklock(MONOTONIC)/PI. The idea is to use futex_lock_pi2() by
default, and fallback to futex_lock_pi() in case the kernel is too old.

There's also a bugreport for glibc with a test case:

 https://sourceware.org/bugzilla/show_bug.cgi?id=26801

Changes since RFC:

 * FUTEX_LOCK_PI2 merged in upstream Linux kernel (Thomas Gleixner, Peter Zijlstra)
 * Make of __ASSUME_FUTEX_LOCK_PI2 in the implementation (Adhemerval Zanella)
 * Get rid of probing for FUTEX_LOCK_PI2 in timedlock (Adhemerval Zanella)
 * Adjust the test cases (Adhemerval Zanella)
 * Use correct Linux kernel version (Joseph Myers)

Previous versions:

 * https://sourceware.org/pipermail/libc-alpha/2021-June/127798.html

Thanks,
Kurt

[1] - https://lkml.kernel.org/lkml/20210422194417.866740847@linutronix.de/

Kurt Kanzenbach (6):
  Linux: Add FUTEX_LOCK_PI2
  nptl: Introduce futex_lock_pi2()
  nptl: Use futex_lock_pi2()
  nptl: Remove mutex test 10
  nptl: mutex-test5: Include CLOCK_MONOTONIC for PI
  nptl: mutex-test9: Include CLOCK_MONOTONIC for PI

 nptl/Makefile                             |   2 +-
 nptl/pthread_mutex_timedlock.c            |  10 +-
 nptl/tst-mutexpi10.c                      |  68 -----------
 sysdeps/nptl/futex-internal.h             | 131 ++++++++++++++++++++++
 sysdeps/nptl/lowlevellock-futex.h         |   1 +
 sysdeps/pthread/tst-mutex5.c              |  20 +++-
 sysdeps/pthread/tst-mutex9.c              |   9 +-
 sysdeps/unix/sysv/linux/kernel-features.h |   8 ++
 8 files changed, 163 insertions(+), 86 deletions(-)
 delete mode 100644 nptl/tst-mutexpi10.c

-- 
2.30.2


^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2021-07-09 14:23 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-25  8:10 [PATCH v1 0/6] nptl: Introduce and use FUTEX_LOCK_PI2 Kurt Kanzenbach
2021-06-25  8:10 ` [PATCH v1 1/6] Linux: Add FUTEX_LOCK_PI2 Kurt Kanzenbach
2021-07-09 13:32   ` Adhemerval Zanella
2021-06-25  8:11 ` [PATCH v1 2/6] nptl: Introduce futex_lock_pi2() Kurt Kanzenbach
2021-07-09 14:13   ` Adhemerval Zanella
2021-06-25  8:11 ` [PATCH v1 3/6] nptl: Use futex_lock_pi2() Kurt Kanzenbach
2021-07-09 14:21   ` Adhemerval Zanella
2021-06-25  8:11 ` [PATCH v1 4/6] nptl: Remove mutex test 10 Kurt Kanzenbach
2021-07-09 14:23   ` Adhemerval Zanella
2021-06-25  8:11 ` [PATCH v1 5/6] nptl: mutex-test5: Include CLOCK_MONOTONIC for PI Kurt Kanzenbach
2021-06-25  8:11 ` [PATCH v1 6/6] nptl: mutex-test9: " Kurt Kanzenbach
2021-07-09  6:57 ` [PATCH v1 0/6] nptl: Introduce and use FUTEX_LOCK_PI2 Kurt Kanzenbach
2021-07-09 13:30 ` Adhemerval Zanella
2021-07-09 14:20   ` Kurt Kanzenbach

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).