From patchwork Mon Aug 18 20:51:53 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 2427 X-Patchwork-Delegate: azanella@linux.vnet.ibm.com Received: (qmail 16755 invoked by alias); 18 Aug 2014 20:52:06 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 16699 invoked by uid 89); 18 Aug 2014 20:52:05 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.5 required=5.0 tests=AWL, BAYES_00, RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: e24smtp05.br.ibm.com Message-ID: <53F26769.20801@linux.vnet.ibm.com> Date: Mon, 18 Aug 2014 17:51:53 -0300 From: Adhemerval Zanella User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.5.0 MIME-Version: 1.0 To: libc-alpha@sourceware.org Subject: Re: Possible fix for bug #13165 References: <20140818195344.GA1187@brightrain.aerifal.cx> In-Reply-To: <20140818195344.GA1187@brightrain.aerifal.cx> X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 14081820-1798-0000-0000-00000041CE92 On 18-08-2014 16:53, Rich Felker wrote: > A couple days ago I posted ideas for a fix for this issue on the bug > tracker: > > https://sourceware.org/bugzilla/show_bug.cgi?id=13165#c38 > > Anybody who does glibc development/builds/testing up for trying my > idea and seeing if it works? > > Rich > If I understood correctly, you are proposing something like: correct? I saw not NPTL issues in nether powerpc64 or x86_64. diff --git a/nptl/pthread_cond_wait.c b/nptl/pthread_cond_wait.c index fc5eac4..a16c5d5 100644 --- a/nptl/pthread_cond_wait.c +++ b/nptl/pthread_cond_wait.c @@ -118,14 +118,6 @@ __pthread_cond_wait (cond, mutex) /* Make sure we are alone. */ lll_lock (cond->__data.__lock, pshared); - /* Now we can release the mutex. */ - err = __pthread_mutex_unlock_usercnt (mutex, 0); - if (__glibc_unlikely (err)) - { - lll_unlock (cond->__data.__lock, pshared); - return err; - } - /* We have one new user of the condvar. */ ++cond->__data.__total_seq; ++cond->__data.__futex; @@ -153,6 +145,14 @@ __pthread_cond_wait (cond, mutex) /* Remember the broadcast counter. */ cbuffer.bc_seq = cond->__data.__broadcast_seq; + /* Now we can release the mutex. */ + err = __pthread_mutex_unlock_usercnt (mutex, 0); + if (__glibc_unlikely (err)) + { + lll_unlock (cond->__data.__lock, pshared); + return err; + } + do { unsigned int futex_val = cond->__data.__futex;