From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by sourceware.org (Postfix) with ESMTP id 4FE4F385DC2E for ; Wed, 25 Nov 2020 12:32:20 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 4FE4F385DC2E Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-402-coO3lRU2O36YOo2cHt6lbw-1; Wed, 25 Nov 2020 07:32:15 -0500 X-MC-Unique: coO3lRU2O36YOo2cHt6lbw-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 94D453E760; Wed, 25 Nov 2020 12:32:14 +0000 (UTC) Received: from localhost (unknown [10.33.37.15]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0F6F619D6C; Wed, 25 Nov 2020 12:32:13 +0000 (UTC) Date: Wed, 25 Nov 2020 12:32:13 +0000 From: Jonathan Wakely To: "H.J. Lu" Cc: Andreas Schwab , trodgers@redhat.com, GCC Patches , libstdc++ Subject: Re: [PATCH] libstdc++: Add C++2a synchronization support Message-ID: <20201125123213.GH1312820@redhat.com> References: <20201023102859.GA1525304@redhat.com> <20201026214827.3530995-1-rodgert@appliantology.com> <87a6va3fl3.fsf@igel.home> <20201121170450.GN1312820@redhat.com> <20201121173931.GO1312820@redhat.com> <20201124234521.GD1312820@redhat.com> <20201125010711.GE1312820@redhat.com> <20201125103544.GG1312820@redhat.com> MIME-Version: 1.0 In-Reply-To: <20201125103544.GG1312820@redhat.com> X-Clacks-Overhead: GNU Terry Pratchett X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: multipart/mixed; boundary="zROEGoKAXsG5UqGB" Content-Disposition: inline X-Spam-Status: No, score=-14.1 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=unavailable autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libstdc++@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libstdc++ mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 25 Nov 2020 12:32:21 -0000 --zROEGoKAXsG5UqGB Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline On 25/11/20 10:35 +0000, Jonathan Wakely wrote: >On 25/11/20 01:07 +0000, Jonathan Wakely wrote: >>On 24/11/20 23:45 +0000, Jonathan Wakely wrote: >>>On 21/11/20 16:36 -0800, H.J. Lu wrote: >>>>On Sat, Nov 21, 2020 at 9:40 AM Jonathan Wakely via Gcc-patches >>>> wrote: >>>>> >>>>>On 21/11/20 17:04 +0000, Jonathan Wakely wrote: >>>>>>On 21/11/20 16:16 +0100, Andreas Schwab wrote: >>>>>>>In file included from /daten/aranym/gcc/gcc-20201121/Build/m68k-linux/libstdc++-v3/include/bits/shared_ptr_atomic.h:33, >>>>>>> from /daten/aranym/gcc/gcc-20201121/Build/m68k-linux/libstdc++-v3/include/memory:78, >>>>>>> from /daten/aranym/gcc/gcc-20201121/Build/m68k-linux/libstdc++-v3/include/m68k-linux/bits/stdc++.h:82, >>>>>>> from /daten/aranym/gcc/gcc-20201121/Build/m68k-linux/libstdc++-v3/include/m68k-linux/bits/extc++.h:32, >>>>>>> from /daten/aranym/gcc/gcc-20201121/libstdc++-v3/testsuite/17_intro/headers/c++2020/all_attributes.cc:37: >>>>>>>/daten/aranym/gcc/gcc-20201121/Build/m68k-linux/libstdc++-v3/include/bits/atomic_base.h: In member function 'void std::atomic_flag::wait(bool, std::memory_order) const': >>>>>>>/daten/aranym/gcc/gcc-20201121/Build/m68k-linux/libstdc++-v3/include/bits/atomic_base.h:239: error: no matching function for call to '__atomic_wait(const __atomic_flag_data_type*, bool&, std::atomic_flag::wait(bool, std::memory_order) const::)' >>>>>>>In file included from /daten/aranym/gcc/gcc-20201121/Build/m68k-linux/libstdc++-v3/include/bits/atomic_base.h:41, >>>>>>> from /daten/aranym/gcc/gcc-20201121/Build/m68k-linux/libstdc++-v3/include/bits/shared_ptr_atomic.h:33, >>>>>>> from /daten/aranym/gcc/gcc-20201121/Build/m68k-linux/libstdc++-v3/include/memory:78, >>>>>>> from /daten/aranym/gcc/gcc-20201121/Build/m68k-linux/libstdc++-v3/include/m68k-linux/bits/stdc++.h:82, >>>>>>> from /daten/aranym/gcc/gcc-20201121/Build/m68k-linux/libstdc++-v3/include/m68k-linux/bits/extc++.h:32, >>>>>>> from /daten/aranym/gcc/gcc-20201121/libstdc++-v3/testsuite/17_intro/headers/c++2020/all_attributes.cc:37: >>>>>>>/daten/aranym/gcc/gcc-20201121/Build/m68k-linux/libstdc++-v3/include/bits/atomic_wait.h:265: note: candidate: 'template void std::__atomic_wait(const _Tp*, _Tp, _Pred)' >>>>>>>/daten/aranym/gcc/gcc-20201121/Build/m68k-linux/libstdc++-v3/include/bits/atomic_wait.h:265: note: template argument deduction/substitution failed: >>>>>>>In file included from /daten/aranym/gcc/gcc-20201121/Build/m68k-linux/libstdc++-v3/include/bits/shared_ptr_atomic.h:33, >>>>>>> from /daten/aranym/gcc/gcc-20201121/Build/m68k-linux/libstdc++-v3/include/memory:78, >>>>>>> from /daten/aranym/gcc/gcc-20201121/Build/m68k-linux/libstdc++-v3/include/m68k-linux/bits/stdc++.h:82, >>>>>>> from /daten/aranym/gcc/gcc-20201121/Build/m68k-linux/libstdc++-v3/include/m68k-linux/bits/extc++.h:32, >>>>>>> from /daten/aranym/gcc/gcc-20201121/libstdc++-v3/testsuite/17_intro/headers/c++2020/all_attributes.cc:37: >>>>>>>/daten/aranym/gcc/gcc-20201121/Build/m68k-linux/libstdc++-v3/include/bits/atomic_base.h:239: note: deduced conflicting types for parameter '_Tp' ('unsigned char' and 'bool') >>>>>> >>>>>>I'm testing this. >>>>> >>>>>I'm committing this instead, it's the same but also disables >>>>>29_atomics/atomic/wait_notify/generic.cc on non-linux targets. >>>>> >>>>>Tested sparc-solaris2.11 and powerpc64le-linux. >>>>> >>>>>There are still some timeouts on linux: >>>>> >>>>>FAIL: 30_threads/latch/3.cc execution test >>>>>FAIL: 30_threads/semaphore/try_acquire_for.cc execution test >>>>> >>>> >>>>I opened: >>>> >>>>https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97936 >>> >>>I've disabled the failing tests for now. They can be re-enabled after >>>the problem is found and fixed. >> >>I was finally able to reproduce the hangs, and I think this is the >>fix: >> >>--- a/libstdc++-v3/include/bits/atomic_wait.h >>+++ b/libstdc++-v3/include/bits/atomic_wait.h >>@@ -100,9 +100,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION >> auto __e = syscall (SYS_futex, static_cast(__addr), >> static_cast(__futex_wait_flags::__wait_private), >> __val, nullptr); >>- if (!__e) >>+ if (!__e || errno == EAGAIN) >> break; >>- else if (!(errno == EINTR || errno == EAGAIN)) >>+ else if (errno != EINTR) >> __throw_system_error(__e); >> } >> } >> >>The problem is that we're going into a busy loop when SYS_futex >>returns EAGAIN, but that means the current value doesn't match the >>expected value, so we should return not keep waiting for the value to >>change. > >I've pushed that as ad9cbcee543ecccd79fa49dafcd925532d2ce210 but there >are still other FAILs to be fixed. Except that what I pushed was not what I wrote above, as noticed by Jakub. I need to get more sleep. Fixed with this patch, pushed to trunk. --zROEGoKAXsG5UqGB Content-Type: text/x-patch; charset=us-ascii Content-Disposition: attachment; filename="patch.txt" commit a5ccfd04605d940daded7e95474389f1c7dfad61 Author: Jonathan Wakely Date: Wed Nov 25 12:16:07 2020 libstdc++: Fix silly typos [PR 97936] libstdc++-v3/ChangeLog: PR libstdc++/97936 * include/bits/atomic_wait.h (__platform_wait): Check errno, not just the value of EAGAIN. (__waiters::__waiters()): Fix name of data member. diff --git a/libstdc++-v3/include/bits/atomic_wait.h b/libstdc++-v3/include/bits/atomic_wait.h index fdf7c4586f22..5af9367ca2e9 100644 --- a/libstdc++-v3/include/bits/atomic_wait.h +++ b/libstdc++-v3/include/bits/atomic_wait.h @@ -100,7 +100,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION auto __e = syscall (SYS_futex, static_cast(__addr), static_cast(__futex_wait_flags::__wait_private), __val, nullptr); - if (!__e || EAGAIN) + if (!__e || errno == EAGAIN) break; else if (errno != EINTR) __throw_system_error(__e); @@ -133,7 +133,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION mutable __gthread_cond_t _M_cv; __waiters() noexcept { - __GTHREAD_COND_INIT_FUNCTION(&_M_cond); + __GTHREAD_COND_INIT_FUNCTION(&_M_cv); } # endif #endif --zROEGoKAXsG5UqGB--