From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pg1-x529.google.com (mail-pg1-x529.google.com [IPv6:2607:f8b0:4864:20::529]) by sourceware.org (Postfix) with ESMTPS id 9D5D6384780D for ; Fri, 9 Jul 2021 14:21:08 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 9D5D6384780D Received: by mail-pg1-x529.google.com with SMTP id y17so10089854pgf.12 for ; Fri, 09 Jul 2021 07:21:08 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=JRGYiB/MK3NyWDBB7HmB8t9pOz4AoPupGnCyatFDA8U=; b=drcBZ4aZdE5M79qthZ7W4olkvCfQuXLq/e902A0Ne5ffasDPETGSI4imJVBuxORUXM BILRppG2UjfUnIdITAhjhu6zsT8lUcRF2/m3q6oilwrWbOBocw/JMprDaFR1b1VsSxEC NQlgK5Lv8fWyjO3N8aMm7U/Da4nBGO5hpcm0052/LRpEYuaSToLXtB9/mwkVztRTG96h ozd19svTCpbtR6SZZWvh7BX9zfePXy9lLjZrM0o7V3PlAZbjUsPqCL2oTjyHSMQ7sqli lcBlQ2HOyDJ7mJTgTvogWRAjxEnqvnikHYqP2oDz+fBfzwMH1GhD3Sepg1ujiMhH7/Vl vs5Q== X-Gm-Message-State: AOAM5323+DBKMyiFK6vsRywz7RC1mP3DuMXiGG7JAbc6/jU7LzRrUmce aYZx4xRPAQBtKYPhHMU11o6Lvw== X-Google-Smtp-Source: ABdhPJwOQbAoZAwI8H6yVhGNkuFw88mk3psVcBejOZytLWP5tBfdKq4a8xQJRMBBRRIUwGRtsnW2Qg== X-Received: by 2002:a63:43c4:: with SMTP id q187mr38216675pga.172.1625840467706; Fri, 09 Jul 2021 07:21:07 -0700 (PDT) Received: from [192.168.1.108] ([177.194.59.218]) by smtp.gmail.com with ESMTPSA id w5sm6437928pfq.130.2021.07.09.07.21.05 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 09 Jul 2021 07:21:07 -0700 (PDT) Subject: Re: [PATCH v1 3/6] nptl: Use futex_lock_pi2() To: Kurt Kanzenbach , libc-alpha@sourceware.org Cc: Florian Weimer , Carlos O'Donell , Lukasz Majewski , Thomas Gleixner , Sebastian Andrzej Siewior , Peter Zijlstra , Joseph Myers References: <20210625081104.1134598-1-kurt@linutronix.de> <20210625081104.1134598-4-kurt@linutronix.de> From: Adhemerval Zanella Message-ID: <32e889eb-345a-7941-b719-82eea5b15411@linaro.org> Date: Fri, 9 Jul 2021 11:21:03 -0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 MIME-Version: 1.0 In-Reply-To: <20210625081104.1134598-4-kurt@linutronix.de> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-12.4 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, NICE_REPLY_A, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) 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, 09 Jul 2021 14:21:10 -0000 On 25/06/2021 05:11, Kurt Kanzenbach wrote: > 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) > I think we should change futex_lock_pi64() to use FUTEX_LOCK_PI2 and only exports it instead of both futex_lock_pi64() and futex_lock_pi2_64. It can simplify the implementation and provide a complete internal futex functionality (since by using two different PI-futex operation caller should be aware that only futex_lock_pi2_64 supports FUTEX_LOCK_PI2).