Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/lib/libpthread pthread__mutex_unlock_slow(): ignore the DEFE...



details:   https://anonhg.NetBSD.org/src/rev/07a43cd4addb
branches:  trunk
changeset: 1006730:07a43cd4addb
user:      ad <ad%NetBSD.org@localhost>
date:      Sat Jan 25 17:58:28 2020 +0000

description:
pthread__mutex_unlock_slow(): ignore the DEFERRED bit.  It's only purpose
is to get the thread to go through the slow path.  If there are waiters,
process them there and then.  Should not affect well behaved apps.  Maybe
of help for:

PR bin/50350: rump/rumpkern/t_sp/stress_{long,short} fail on Core 2 Quad

diffstat:

 lib/libpthread/pthread_mutex.c |  15 ++++-----------
 1 files changed, 4 insertions(+), 11 deletions(-)

diffs (52 lines):

diff -r 206a91e97bee -r 07a43cd4addb lib/libpthread/pthread_mutex.c
--- a/lib/libpthread/pthread_mutex.c    Sat Jan 25 16:19:29 2020 +0000
+++ b/lib/libpthread/pthread_mutex.c    Sat Jan 25 17:58:28 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: pthread_mutex.c,v 1.66 2020/01/13 18:22:56 ad Exp $    */
+/*     $NetBSD: pthread_mutex.c,v 1.67 2020/01/25 17:58:28 ad Exp $    */
 
 /*-
  * Copyright (c) 2001, 2003, 2006, 2007, 2008 The NetBSD Foundation, Inc.
@@ -47,7 +47,7 @@
  */
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: pthread_mutex.c,v 1.66 2020/01/13 18:22:56 ad Exp $");
+__RCSID("$NetBSD: pthread_mutex.c,v 1.67 2020/01/25 17:58:28 ad Exp $");
 
 #include <sys/types.h>
 #include <sys/lwpctl.h>
@@ -466,7 +466,7 @@
 pthread__mutex_unlock_slow(pthread_mutex_t *ptm)
 {
        pthread_t self, owner, new;
-       int weown, error, deferred;
+       int weown, error;
 
        pthread__error(EINVAL, "Invalid mutex",
            ptm->ptm_magic == _PT_MUTEX_MAGIC);
@@ -474,7 +474,6 @@
        self = pthread__self();
        owner = ptm->ptm_owner;
        weown = (MUTEX_OWNER(owner) == (uintptr_t)self);
-       deferred = (int)((uintptr_t)owner & MUTEX_DEFERRED_BIT);
        error = 0;
 
        if (__SIMPLELOCK_LOCKED_P(&ptm->ptm_errorcheck)) {
@@ -516,15 +515,9 @@
                        pthread__mutex_wakeup(self, ptm);
                        return 0;
                }
+               error = 0;
        }
 
-       /*
-        * There were no waiters, but we may have deferred waking
-        * other threads until mutex unlock - we must wake them now.
-        */
-       if (!deferred)
-               return error;
-
        if (self->pt_nwaiters == 1) {
                /*
                 * If the calling thread is about to block, defer



Home | Main Index | Thread Index | Old Index