From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-qk1-x733.google.com (mail-qk1-x733.google.com [IPv6:2607:f8b0:4864:20::733]) by sourceware.org (Postfix) with ESMTPS id 5C2F03857C6F for ; Tue, 22 Jun 2021 12:30:52 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 5C2F03857C6F Received: by mail-qk1-x733.google.com with SMTP id o6so3564399qkh.4 for ; Tue, 22 Jun 2021 05:30:52 -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=TYD0oB0bkm/13F70rAoGrH0Vw9DWUsHdMnVQvb3zNVM=; b=NEVtzJIepLiAEYpXEkuN+7JcXP2UjSwNdWKhz/+pDA2UDxA0m0FHhnGovOQiQ7WgeO S8whtk46rXIIC0X/3F5hQ6mdxYhuUCxZ0aehM2fmP1c3c3SHsCeG6Th7hlQPKagwc2ef wU6EHijM+O5QlWT8HxYqY3qmcSnjkSIuKWz9Y+H2ymWASZCwPeqbPJ85hPoAvnYaGFgq Ya12g+/sAY55P6vvi8QGpeTAz4dLoMgTQOygvKG6EUGmc6rtTLuwt331kbfopvxQ6VFZ vKHkX82ZpJeGTy06gDGSeb4xPpE7kVFvl2b0NjK+EsIrFn2fo5dROHG9rTv1D4KkjCxU BYcA== X-Gm-Message-State: AOAM5331VfKJea9Wg11Vklb9hkeAKE9Qn+0QuxveP891ZWLsItGbkcyE +yFhrcp7g7/mqRzuWU4loJHmT5uK1ZW9vA== X-Google-Smtp-Source: ABdhPJwHyNznDKQpESKbdEJ/y5TWnS4d6jZZN+2VYoGHghI/FCsUlDCrJ89cjZJSilUykU8e/7b2ng== X-Received: by 2002:a37:a548:: with SMTP id o69mr3995041qke.376.1624365051880; Tue, 22 Jun 2021 05:30:51 -0700 (PDT) Received: from [192.168.1.108] ([177.194.59.218]) by smtp.gmail.com with ESMTPSA id f13sm1576900qtx.3.2021.06.22.05.30.49 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 22 Jun 2021 05:30:51 -0700 (PDT) Subject: Re: [PATCH RFC 0/3] nptl: Introduce and use FUTEX_LOCK_PI2 To: Kurt Kanzenbach , libc-alpha@sourceware.org Cc: Florian Weimer , Carlos O'Donell , Thomas Gleixner , Sebastian Andrzej Siewior References: <20210621111650.1164689-1-kurt@linutronix.de> <87h7hql5qm.fsf@kurt> From: Adhemerval Zanella Message-ID: <93a48890-f364-c44f-43ce-dd97c8092ef0@linaro.org> Date: Tue, 22 Jun 2021 09:30:48 -0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.8.1 MIME-Version: 1.0 In-Reply-To: <87h7hql5qm.fsf@kurt> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-5.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, KAM_NUMSUBJECT, NICE_REPLY_A, RCVD_IN_DNSWL_NONE, 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: Tue, 22 Jun 2021 12:30:53 -0000 On 22/06/2021 04:26, Kurt Kanzenbach wrote: >> #else /* __ASSUME_TIME64_SYSCALLS */ >> bool need_time64 = abstime != NULL && !in_time_t_range (abstime->tv_sec) >> if (need_time64) >> { >> err = futex_lock_pi2_64 (futex_word, abstime, private); >> } >> else >> { >> struct timespec ts32; >> if (abstime != NULL) >> ts32 = valid_timespec64_to_timespec (*abstime); >> >> err = INTERNAL_SYSCALL_CALL (futex, futex_word, __lll_private_flag >> (FUTEX_LOCK_PI, private), 0, >> abstime != NULL ? &ts32 : NULL); >> } >> #endif /* __ASSUME_TIME64_SYSCALLS */ >> [...] >> } >> >> It would make the changes on pthread_mutex code minimal, it would be only to >> remove the extra check for clockid and adjust the comment. > > Well, that's an interesting point. I think the current check has to > stay, because there are two locking paths. Only the slow path calls > futex_lock_pi_64() which may result in ENOSYS for clock monotonic. But, > the fast path which doesn't call futex_lock_pi64() would succeed if the > check is removed. > > Maybe something like this: > > sysdeps/nptl/futex-internal.h: > |static __always_inline bool > |futex_lockpi2_supported (void) > |{ > | return __ASSUME_FUTEX_LOCK_PI2; > |} > > nptl/pthread_mutex_timedlock.c: > | if (__glibc_unlikely (! futex_lockpi2_supported () && > | clockid != CLOCK_REALTIME)) > | return EINVAL; > > Or did I get something wrong? Besides what Florian has explained about __ASSUME_* macros, another issue we have static initialization for pthread_mutex. So the syscall probe only works for dynamic initialization (where caller issue a pthread_mutex_init). I view this as an inconsistent behavior and I don't have a straightforward solution that won't result in a performance penalization for common cases (it would require to probe for FUTEX_LOCK_PI2 *and* FUTEX_LOCK_PI). Instead I think we should move the possible error on the slow path and let the kernel advertise it any missing support.