From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS3215 2.6.0.0/16 X-Spam-Status: No, score=-4.2 required=3.0 tests=AWL,BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI,NICE_REPLY_A, RCVD_IN_DNSWL_MED,SPF_HELO_PASS,SPF_PASS shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by dcvr.yhbt.net (Postfix) with ESMTPS id 896B21F8C6 for ; Fri, 9 Jul 2021 14:22:27 +0000 (UTC) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id B679A398CC1A for ; Fri, 9 Jul 2021 14:22:26 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B679A398CC1A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1625840546; bh=JRGYiB/MK3NyWDBB7HmB8t9pOz4AoPupGnCyatFDA8U=; h=Subject:To:References:Date:In-Reply-To:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=cfU/QP6t/WYqEYrqBL26MeMbttPSdrsvW3fp7f014HXweNFtWBGunCpnkOq/n2I3A 4B3a9PF+ddtJ/RbMn3J0ML1emw7+re1h4TVNK8xZXZLCyw+oG/DNAiqOqHBvHw3onS p9h6EKWEDYyfBRf4T9ywugWTvpqCfFUY/P6RGrMU= 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 References: <20210625081104.1134598-1-kurt@linutronix.de> <20210625081104.1134598-4-kurt@linutronix.de> 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-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: , From: Adhemerval Zanella via Libc-alpha Reply-To: Adhemerval Zanella Cc: Florian Weimer , Sebastian Andrzej Siewior , Peter Zijlstra , Thomas Gleixner , Joseph Myers Errors-To: libc-alpha-bounces+e=80x24.org@sourceware.org Sender: "Libc-alpha" 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).