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 67C1039BECD3 for ; Fri, 25 Jun 2021 08:11:28 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 67C1039BECD3 From: Kurt Kanzenbach To: libc-alpha@sourceware.org Cc: Adhemerval Zanella , Florian Weimer , Carlos O'Donell , Lukasz Majewski , Thomas Gleixner , Sebastian Andrzej Siewior , Peter Zijlstra , Joseph Myers , Kurt Kanzenbach Subject: [PATCH v1 3/6] nptl: Use futex_lock_pi2() Date: Fri, 25 Jun 2021 10:11:01 +0200 Message-Id: <20210625081104.1134598-4-kurt@linutronix.de> In-Reply-To: <20210625081104.1134598-1-kurt@linutronix.de> References: <20210625081104.1134598-1-kurt@linutronix.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-10.6 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham 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: Fri, 25 Jun 2021 08:11:29 -0000 Currently it is not possible to specify CLOCK_MONOTONIC for timeouts for PI mutexes. The FUTEX_LOCK_PI2 operation can be used to implement that. Therefore, use it by default. In case FUTEX_LOCK_PI2 is not available on the running kernel, then EINVAL is returned as of now. Signed-off-by: Kurt Kanzenbach --- nptl/pthread_mutex_timedlock.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/nptl/pthread_mutex_timedlock.c b/nptl/pthread_mutex_timedlock.c index 5afd6222d61e..95892a32a6af 100644 --- a/nptl/pthread_mutex_timedlock.c +++ b/nptl/pthread_mutex_timedlock.c @@ -300,13 +300,6 @@ __pthread_mutex_clocklock_common (pthread_mutex_t *mutex, case PTHREAD_MUTEX_PI_ROBUST_NORMAL_NP: case PTHREAD_MUTEX_PI_ROBUST_ADAPTIVE_NP: { - /* Currently futex FUTEX_LOCK_PI operation only provides support for - CLOCK_REALTIME and trying to emulate by converting a - CLOCK_MONOTONIC to CLOCK_REALTIME will take in account possible - changes to the wall clock. */ - if (__glibc_unlikely (clockid != CLOCK_REALTIME)) - return EINVAL; - int kind, robust; { /* See concurrency notes regarding __kind in struct __pthread_mutex_s @@ -370,7 +363,8 @@ __pthread_mutex_clocklock_common (pthread_mutex_t *mutex, int private = (robust ? PTHREAD_ROBUST_MUTEX_PSHARED (mutex) : PTHREAD_MUTEX_PSHARED (mutex)); - int e = futex_lock_pi64 (&mutex->__data.__lock, abstime, private); + int e = futex_lock_pi2_64 (&mutex->__data.__lock, clockid, abstime, + private); if (e == ETIMEDOUT) return ETIMEDOUT; else if (e == ESRCH || e == EDEADLK) -- 2.30.2