public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
* [PATCH RFC 0/3] nptl: Introduce and use FUTEX_LOCK_PI2
@ 2021-06-21 11:16 Kurt Kanzenbach
  2021-06-21 11:16 ` [PATCH RFC 1/3] nptl: Introduce futex_lock_pi2() Kurt Kanzenbach
                   ` (3 more replies)
  0 siblings, 4 replies; 12+ messages in thread
From: Kurt Kanzenbach @ 2021-06-21 11:16 UTC (permalink / raw)
  To: libc-alpha
  Cc: Adhemerval Zanella, Florian Weimer, Carlos O'Donell,
	Thomas Gleixner, Sebastian Andrzej Siewior, Kurt Kanzenbach

Hi,

Linux real time application 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 doesn't support it, yet. Using CLOCK_REALTIME is
possible, but it is subject to adjustments (NTP, PTP, ...). Therefore, Thomas
proposed to add a new futex operation called FUTEX_LOCK_PI2 with support for
selectable clocks [1]. That patch series is not merged, yet.

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. I think,
you get the idea.

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

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

Thoughts?

Thanks,
Kurt

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

Kurt Kanzenbach (3):
  nptl: Introduce futex_lock_pi2()
  nptl: Use futex_lock_pi2()
  nptl: Include CLOCK_MONOTONIC in mutex tests

 nptl/pthread_mutex_timedlock.c            | 24 ++++--
 nptl/tst-mutexpi10.c                      |  8 ++
 sysdeps/nptl/futex-internal.h             | 94 +++++++++++++++++++++++
 sysdeps/nptl/lowlevellock-futex.h         |  1 +
 sysdeps/pthread/tst-mutex5.c              |  3 +-
 sysdeps/pthread/tst-mutex9.c              |  3 +-
 sysdeps/unix/sysv/linux/kernel-features.h |  8 ++
 7 files changed, 133 insertions(+), 8 deletions(-)

-- 
2.30.2


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

end of thread, other threads:[~2021-06-22 14:25 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-21 11:16 [PATCH RFC 0/3] nptl: Introduce and use FUTEX_LOCK_PI2 Kurt Kanzenbach
2021-06-21 11:16 ` [PATCH RFC 1/3] nptl: Introduce futex_lock_pi2() Kurt Kanzenbach
2021-06-21 11:16 ` [PATCH RFC 2/3] nptl: Use futex_lock_pi2() Kurt Kanzenbach
2021-06-21 11:16 ` [PATCH RFC 3/3] nptl: Include CLOCK_MONOTONIC in mutex tests Kurt Kanzenbach
2021-06-21 20:07   ` Joseph Myers
2021-06-22  8:58     ` Kurt Kanzenbach
2021-06-21 21:32 ` [PATCH RFC 0/3] nptl: Introduce and use FUTEX_LOCK_PI2 Adhemerval Zanella
2021-06-22  7:26   ` Kurt Kanzenbach
2021-06-22  7:29     ` Florian Weimer
2021-06-22  8:55       ` Kurt Kanzenbach
2021-06-22 12:30     ` Adhemerval Zanella
2021-06-22 14:25       ` 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).