From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by sourceware.org (Postfix) with ESMTPS id 55F09393A425 for ; Mon, 21 Jun 2021 11:17:20 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 55F09393A425 From: Kurt Kanzenbach To: libc-alpha@sourceware.org Cc: Adhemerval Zanella , Florian Weimer , Carlos O'Donell , Thomas Gleixner , Sebastian Andrzej Siewior , Kurt Kanzenbach Subject: [PATCH RFC 0/3] nptl: Introduce and use FUTEX_LOCK_PI2 Date: Mon, 21 Jun 2021 13:16:47 +0200 Message-Id: <20210621111650.1164689-1-kurt@linutronix.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-3.7 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, KAM_NUMSUBJECT, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=no autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 21 Jun 2021 11:17:21 -0000 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