From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx.kolabnow.com (mx.kolabnow.com [95.128.36.41]) by sourceware.org (Postfix) with ESMTPS id 25E283851C04; Mon, 25 May 2020 02:17:33 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 25E283851C04 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=appliantology.com Authentication-Results: sourceware.org; spf=none smtp.mailfrom=rodgert@appliantology.com Received: from localhost (unknown [127.0.0.1]) by ext-mx-out002.mykolab.com (Postfix) with ESMTP id 9113D626; Mon, 25 May 2020 04:17:31 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kolabnow.com; h= references:in-reply-to:date:date:subject:subject:mime-version :content-type:content-type:message-id:from:from:received :received:received; s=dkim20160331; t=1590373050; x=1592187451; bh=Ne7bUQYaj9sNuodj4SBfSiWjMfbyVmjuptsKkpd1zz0=; b=rszkncpFNOJd 3wN0obOEAuFd3ltx+jK72AZPsLLlBaU1PNb/+0SMIVjmz0vp3wfcsEXmPWrTng4C roKOHtY/nt4WBbO994xdcloeNYhmDpVkS7eG17weHN2TRmHuiirSZ2PkFLLwUAOy IySsyAd8zWulX+8zq1zM03RulVhZ3X2f5CuzcmfhaiiWJYv9yF7EdW0rrNhn9J6T +IV3PveID+zbGbNYI4kd/+gM0seiKER9v5q2XVlVxSvPBq6SnKDdCvHUaAu2OIqs EDrcRm3QOzgDXaSFl5Q6TUfVDfNC9znQUj2iJ32IyfWXneMjIvxWvXTtsrZMlcsk FcE+zBNzLTnTiySbIo6FzWVVAagkAM1SznyUIu8+oK+PPXOaAeunR7Ps5xIO4gXO CvHwIdJbzhjpDu/itY1dfy6Zm/R6aRiVBJgFNyMoRjPhtfnQPfQSZMPEmlaFGi2F hFoYJzqve620+Siy3fXdBb1kzYPpX8ibCHK7qckUdtZVAYQveyQ7IgBxa6ezMKSe DovpqPEakyUOoDtHVSiPgrFix8FMgqNIR67K+X9SKlNHGDMU2piHyfBjPPXxJLLH m8Hc0gDEzHIyd8lk/ld6xbGkWN5Saj+YDYjwxjc16a6tNy7s1UHn9GzdvxOBgAHH gn+eKvo9lyY7xtdHWNiL8t8uAUwNS2c= X-Virus-Scanned: amavisd-new at mykolab.com X-Spam-Score: -1.9 X-Spam-Level: X-Spam-Status: No, score=-4.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.2 Received: from mx.kolabnow.com ([127.0.0.1]) by localhost (ext-mx-out002.mykolab.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 1Z-J2sSw661G; Mon, 25 May 2020 04:17:30 +0200 (CEST) Received: from int-mx002.mykolab.com (unknown [10.9.13.2]) by ext-mx-out002.mykolab.com (Postfix) with ESMTPS id 34BAE330; Mon, 25 May 2020 04:17:29 +0200 (CEST) Received: from ext-subm001.mykolab.com (unknown [10.9.6.1]) by int-mx002.mykolab.com (Postfix) with ESMTPS id C90822568; Mon, 25 May 2020 04:17:29 +0200 (CEST) From: Thomas Rodgers Message-Id: <18CE5491-6049-430B-85A3-284117B604E4@appliantology.com> Content-Type: multipart/mixed; boundary="Apple-Mail=_0C19F600-94DF-433D-8F9B-FEA53945AE72" Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.80.23.2.2\)) Subject: Re: [PATCH] Adjust wait logic to limit spurious evalution of wait predicate. Date: Sun, 24 May 2020 19:17:24 -0700 In-Reply-To: <32A8D493-8AA8-47E6-BDDB-65CA10D3D357@appliantology.com> Cc: Thomas Rodgers To: libstdc++ , gcc-patches References: <32A8D493-8AA8-47E6-BDDB-65CA10D3D357@appliantology.com> X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 25 May 2020 02:17:34 -0000 --Apple-Mail=_0C19F600-94DF-433D-8F9B-FEA53945AE72 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=us-ascii And this time, with patch. --Apple-Mail=_0C19F600-94DF-433D-8F9B-FEA53945AE72 Content-Disposition: attachment; filename=wake_up_fix.patch Content-Type: application/octet-stream; x-unix-mode=0644; name="wake_up_fix.patch" Content-Transfer-Encoding: 7bit commit fe8959f61a0945662c2521b3ea47fbc2b751e881 Author: Thomas Rodgers Date: Sun May 24 15:00:13 2020 -0700 Adjust wait logic to limit spurious evalution of wait predicate. * include/bits/atomic_wait.h (__waiters::_M_do_wait): adjust wakeup logic. diff --git a/libstdc++-v3/include/bits/atomic_wait.h b/libstdc++-v3/include/bits/atomic_wait.h index 92c1e2526ed..cce11ae1cf5 100644 --- a/libstdc++-v3/include/bits/atomic_wait.h +++ b/libstdc++-v3/include/bits/atomic_wait.h @@ -138,24 +138,22 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION } void - _M_do_wait(__platform_wait_t __version) noexcept + _M_do_wait(__platform_wait_t __old) noexcept { -#ifdef _GLIBCXX_HAVE_LINUX_FUTEX - __platform_wait(&_M_ver, __version); -#else - __platform_wait_t __cur = 0; - while (__cur <= __version) + __platform_wait_t __cur; + __atomic_load(&_M_ver, &__cur, __ATOMIC_ACQUIRE); + while (__cur == __old) { +#ifdef _GLIBCXX_HAVE_LINUX_FUTEX + __platform_wait(&_M_ver, __cur); +#else __waiters::__lock_t __l(_M_mtx); auto __e = __gthread_cond_wait(&_M_cv, __l.mutex()->native_handle()); if (__e) std::terminate(); - __platform_wait_t __last = __cur; - __atomic_load(&_M_ver, &__cur, __ATOMIC_ACQUIRE); - if (__cur < __last) - break; // break the loop if version overflows - } #endif + __atomic_load(&_M_ver, &__cur, __ATOMIC_ACQUIRE); + } } __platform_wait_t --Apple-Mail=_0C19F600-94DF-433D-8F9B-FEA53945AE72 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=us-ascii > On May 24, 2020, at 3:06 PM, Thomas Rodgers = wrote: >=20 > * include/bits/atomic_wait.h (__waiters::_M_do_wait): adjust = wakeup logic. --Apple-Mail=_0C19F600-94DF-433D-8F9B-FEA53945AE72--