From patchwork Mon Nov 23 19:52:45 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: 41160 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 C1BBE3870900; Mon, 23 Nov 2020 19:53:07 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C1BBE3870900 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1606161187; bh=Tdm6GyWREpFH7smQ9ILJK7hKJVVnNnEW/aKAHF53DzQ=; 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=oC7LOGMJt6buUUgxukyIIyAshJzAvEgzPnP2TCoGrKtk8ThcydTm86lrxTqWENpYq cz5oaZOLUd+xaSbOwGpIcw4YL/xaqXOY6lrjz/2MJv5e22Yzq8yqVccjiUthIbOEc9 moSqDYHO9VmCJJk6t15AfJLTgWK29Ks/KofB2c7I= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-qk1-x741.google.com (mail-qk1-x741.google.com [IPv6:2607:f8b0:4864:20::741]) by sourceware.org (Postfix) with ESMTPS id B7A8F384A01C for ; Mon, 23 Nov 2020 19:53:04 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org B7A8F384A01C Received: by mail-qk1-x741.google.com with SMTP id v143so18210731qkb.2 for ; Mon, 23 Nov 2020 11:53:04 -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=Tdm6GyWREpFH7smQ9ILJK7hKJVVnNnEW/aKAHF53DzQ=; b=lcIu1EvJUopW0I4s3oY0/0c+GWhVVYnMDlhP9RfAQj2ROVIn/8ksRsSbuZ6SO1q3nY GPtjVWfwBS+9dIBRfFfxadChPFeM3ejwbkMuta6vlxGRObvujRC6glydMomTqMNSEkE3 muzpVEi0TJd7CiQCaIQBEW4S7XxLZC+W3klGT1Q2swh5Fx/W8QCIU5PNpA1y3kh7P6wO LCVLIRgVR3vICIC1wy4DqvGOqnMzqJcZilqxz8iJvznAVdigK19QZg9ZmWK9hZxzzkHv y5F6LxWQf0cewlrpBTOe4EsB9vQ1eAZvMSPgyCYpU89Mjb4kkIXxLH3l+CICCijGda9N K3ow== X-Gm-Message-State: AOAM531mH7etNBHVoNMnSYaXj5dL9J1FOat+aLs0GzYithJ4lyB09RWQ 5r+pLxdE2fhsubPM2+g0140scEFFzTjkvw== X-Google-Smtp-Source: ABdhPJyWmsO9tY5p/Gze4mpxuMsvsV5AsxX/xAUzEJcF6GmURTDopFZAvbMSCKL7hELKGsQf2RmezQ== X-Received: by 2002:a37:a185:: with SMTP id k127mr1124514qke.413.1606161184095; Mon, 23 Nov 2020 11:53:04 -0800 (PST) Received: from localhost.localdomain ([177.194.48.209]) by smtp.googlemail.com with ESMTPSA id v9sm10440432qkv.34.2020.11.23.11.53.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Nov 2020 11:53:03 -0800 (PST) To: libc-alpha@sourceware.org Subject: [PATCH 02/13] nptl: Remove futex_wait_cancelable Date: Mon, 23 Nov 2020 16:52:45 -0300 Message-Id: <20201123195256.3336217-2-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" It is used solely on __pthread_cond_wait_common and the call can be replaced by a __futex_abstimed_wait_cancelable64 one. Checked on x86_64-linux-gnu and i686-linux-gnu. Reviewed-by: Lukasz Majewski --- nptl/pthread_cond_wait.c | 22 ++-------------------- sysdeps/nptl/futex-internal.h | 29 ----------------------------- 2 files changed, 2 insertions(+), 49 deletions(-) diff --git a/nptl/pthread_cond_wait.c b/nptl/pthread_cond_wait.c index 7d158d553f..685dbca32f 100644 --- a/nptl/pthread_cond_wait.c +++ b/nptl/pthread_cond_wait.c @@ -501,26 +501,8 @@ __pthread_cond_wait_common (pthread_cond_t *cond, pthread_mutex_t *mutex, cbuffer.private = private; __pthread_cleanup_push (&buffer, __condvar_cleanup_waiting, &cbuffer); - if (abstime == NULL) - { - /* Block without a timeout. */ - err = futex_wait_cancelable ( - cond->__data.__g_signals + g, 0, private); - } - else - { - /* Block, but with a timeout. - Work around the fact that the kernel rejects negative timeout - values despite them being valid. */ - if (__glibc_unlikely (abstime->tv_sec < 0)) - err = ETIMEDOUT; - else - { - err = __futex_abstimed_wait_cancelable64 - (cond->__data.__g_signals + g, 0, clockid, abstime, - private); - } - } + err = __futex_abstimed_wait_cancelable64 ( + cond->__data.__g_signals + g, 0, clockid, abstime, private); __pthread_cleanup_pop (&buffer, 0); diff --git a/sysdeps/nptl/futex-internal.h b/sysdeps/nptl/futex-internal.h index 21e3b74be6..96d1318091 100644 --- a/sysdeps/nptl/futex-internal.h +++ b/sysdeps/nptl/futex-internal.h @@ -177,35 +177,6 @@ futex_wait_simple (unsigned int *futex_word, unsigned int expected, ignore_value (futex_wait (futex_word, expected, private)); } - -/* Like futex_wait but is a POSIX cancellation point. */ -static __always_inline int -futex_wait_cancelable (unsigned int *futex_word, unsigned int expected, - int private) -{ - int oldtype; - oldtype = __pthread_enable_asynccancel (); - int err = lll_futex_timed_wait (futex_word, expected, NULL, private); - __pthread_disable_asynccancel (oldtype); - switch (err) - { - case 0: - case -EAGAIN: - case -EINTR: - return -err; - - case -ETIMEDOUT: /* Cannot have happened as we provided no timeout. */ - case -EFAULT: /* Must have been caused by a glibc or application bug. */ - case -EINVAL: /* Either due to wrong alignment or due to the timeout not - being normalized. Must have been caused by a glibc or - application bug. */ - case -ENOSYS: /* Must have been caused by a glibc bug. */ - /* No other errors are documented at this time. */ - default: - futex_fatal_error (); - } -} - /* Like futex_wait, but will eventually time out (i.e., stop being blocked) after the duration of time provided (i.e., RELTIME) has passed. The caller must provide a normalized RELTIME. RELTIME can also