From patchwork Mon Nov 23 19:52:47 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 41162 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id E08643840C28; Mon, 23 Nov 2020 19:53:10 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E08643840C28 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1606161190; bh=tsD0slqr6YvPe0ua52iBE0DIsItAzrpcF6yq+3t0Fn4=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=iZd2Zuw4AvZE7jqyKN1AzirZ8mhkgbcCL4xMzZ2Yj1cD9vRVedWqNpWMd8Sa/7apg HsO5O/+CjqT4ai+iMlXllBS6SG4lwp6OgrBd1xmj4++OyUevC4Y1WD28vA4cg2o2Ga fq7UhcidmPF4LbX/jCvy9GLs6SEGDtLUgJ5UsAGM= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-qk1-x744.google.com (mail-qk1-x744.google.com [IPv6:2607:f8b0:4864:20::744]) by sourceware.org (Postfix) with ESMTPS id 40539386EC0B for ; Mon, 23 Nov 2020 19:53:08 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 40539386EC0B Received: by mail-qk1-x744.google.com with SMTP id q5so18156192qkc.12 for ; Mon, 23 Nov 2020 11:53:08 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=tsD0slqr6YvPe0ua52iBE0DIsItAzrpcF6yq+3t0Fn4=; b=GoJSPSU4ImvqWtjiGrV0Zgkc+mLGGaa9Ou/7jjHf+hJn0lm3rGOefaVNEuw5wZm09I OEIHQDht8bFgRuKi6yTWANttpPT2LWK1DTMmvn3q4kErlRMP7ILuDXg2AkyfZ02SseCj HPdIb6yEGn06dvEVBYe7C93QLu6FIM4vn7dPwvinmgTwYIqqFqDX8rwJ7wJBNGq8m6vv DoviZa1bEgJ9oQDynstbxOv9D0JE9H9bACygq3mu59Gld89nvMjN/QarWxNha6Y7nppi c8O0t+xzxSUg+nU8tcH6pgLvycT8P1hJhceRfUmcnnQn3wJ+osvYPeVVWoHfSjF7L+g0 Kx8Q== X-Gm-Message-State: AOAM533rEwIEutGf2Q05FHRADO5pGJWT6GcODLtR5ABk2RONH1YaHGHw 6wpS6eHgmyXK8CaFdCgIIq8Mz7KoEWuP+A== X-Google-Smtp-Source: ABdhPJzasNv9J42/Y6s5cve6vpil9Ome2lE8wnLpJZMivR6IT57IS0HiVIgX76HcFiYXsfDcjJ9FcQ== X-Received: by 2002:a05:620a:746:: with SMTP id i6mr1195524qki.16.1606161187665; Mon, 23 Nov 2020 11:53:07 -0800 (PST) Received: from localhost.localdomain ([177.194.48.209]) by smtp.googlemail.com with ESMTPSA id v9sm10440432qkv.34.2020.11.23.11.53.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Nov 2020 11:53:07 -0800 (PST) To: libc-alpha@sourceware.org Subject: [PATCH 04/13] linux: Extend __futex_abstimed_wait_cancelable64 comment Date: Mon, 23 Nov 2020 16:52:47 -0300 Message-Id: <20201123195256.3336217-4-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201123195256.3336217-1-adhemerval.zanella@linaro.org> References: <20201123195256.3336217-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-13.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, 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-Patchwork-Original-From: Adhemerval Zanella via Libc-alpha From: Adhemerval Zanella Netto Reply-To: Adhemerval Zanella Cc: Michael Kerrisk Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" And add a small optimization to avoid setting the operation for the 32-bit time fallback operation. Checked on x86_64-linux-gnu and i686-linux-gnu. Reviewed-by: Lukasz Majewski --- sysdeps/nptl/futex-internal.c | 8 ++------ sysdeps/nptl/futex-internal.h | 18 +++++++++++++++--- 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/sysdeps/nptl/futex-internal.c b/sysdeps/nptl/futex-internal.c index 457cd3cd69..e4a14b477c 100644 --- a/sysdeps/nptl/futex-internal.c +++ b/sysdeps/nptl/futex-internal.c @@ -25,7 +25,7 @@ #ifndef __ASSUME_TIME64_SYSCALLS static int __futex_abstimed_wait_cancelable32 (unsigned int* futex_word, - unsigned int expected, clockid_t clockid, + unsigned int expected, int op, const struct __timespec64* abstime, int private) { @@ -39,10 +39,6 @@ __futex_abstimed_wait_cancelable32 (unsigned int* futex_word, pts32 = &ts32; } - unsigned int clockbit = (clockid == CLOCK_REALTIME) - ? FUTEX_CLOCK_REALTIME : 0; - int op = __lll_private_flag (FUTEX_WAIT_BITSET | clockbit, private); - return INTERNAL_SYSCALL_CANCEL (futex, futex_word, op, expected, pts32, NULL /* Unused. */, FUTEX_BITSET_MATCH_ANY); @@ -119,7 +115,7 @@ __futex_abstimed_wait_cancelable64 (unsigned int* futex_word, #ifndef __ASSUME_TIME64_SYSCALLS if (err == -ENOSYS) err = __futex_abstimed_wait_cancelable32 (futex_word, expected, - clockid, abstime, private); + op, abstime, private); #endif switch (err) diff --git a/sysdeps/nptl/futex-internal.h b/sysdeps/nptl/futex-internal.h index d5f13d15fb..cefab74301 100644 --- a/sysdeps/nptl/futex-internal.h +++ b/sysdeps/nptl/futex-internal.h @@ -390,9 +390,21 @@ futex_unlock_pi (unsigned int *futex_word, int private) } } -/* The futex_abstimed_wait_cancelable64 has been moved to a separate file - to avoid problems with exhausting available registers on some architectures - - e.g. on m68k architecture. */ +/* Like futex_wait, but will eventually time out (i.e., stop being blocked) + after the duration of time provided (i.e., ABSTIME) has passed using the + clock specified by CLOCKID (currently only CLOCK_REALTIME and + CLOCK_MONOTONIC, the ones support by lll_futex_supported_clockid). ABSTIME + can also equal NULL, in which case this function behaves equivalent to + futex_wait. + + Returns the same values as futex_wait under those same conditions; + additionally, returns ETIMEDOUT if the timeout expired. + + The call acts a cancellation entrypoint. + + (The implementation has been moved to a separate file to avoid problems + with exhausting available registers on some architectures - e.g. on + m68k). */ int __futex_abstimed_wait_cancelable64 (unsigned int* futex_word, unsigned int expected, clockid_t clockid,