Author: davidxu Date: Wed Oct 20 02:34:02 2010 New Revision: 214093 URL: http://svn.freebsd.org/changeset/base/214093
Log: Revert revision 214007, I realized that MySQL wants to resolve a silly rwlock deadlock problem, the deadlock is caused by writer waiters, if a thread has already locked a reader lock, and wants to acquire another reader lock, it will be blocked by writer waiters, but we had already fixed it years ago. Modified: head/lib/libc/include/namespace.h head/lib/libc/include/un-namespace.h head/lib/libthr/pthread.map head/lib/libthr/thread/thr_private.h head/lib/libthr/thread/thr_rwlock.c head/lib/libthr/thread/thr_rwlockattr.c Modified: head/lib/libc/include/namespace.h ============================================================================== --- head/lib/libc/include/namespace.h Wed Oct 20 01:22:04 2010 (r214092) +++ head/lib/libc/include/namespace.h Wed Oct 20 02:34:02 2010 (r214093) @@ -177,10 +177,8 @@ #define pthread_rwlock_unlock _pthread_rwlock_unlock #define pthread_rwlock_wrlock _pthread_rwlock_wrlock #define pthread_rwlockattr_destroy _pthread_rwlockattr_destroy -#define pthread_rwlockattr_getkind_np _pthread_rwlockattr_getkind_np #define pthread_rwlockattr_getpshared _pthread_rwlockattr_getpshared #define pthread_rwlockattr_init _pthread_rwlockattr_init -#define pthread_rwlockattr_setkind_np _pthread_rwlockattr_setkind_np #define pthread_rwlockattr_setpshared _pthread_rwlockattr_setpshared #define pthread_self _pthread_self #define pthread_set_name_np _pthread_set_name_np Modified: head/lib/libc/include/un-namespace.h ============================================================================== --- head/lib/libc/include/un-namespace.h Wed Oct 20 01:22:04 2010 (r214092) +++ head/lib/libc/include/un-namespace.h Wed Oct 20 02:34:02 2010 (r214093) @@ -158,10 +158,8 @@ #undef pthread_rwlock_unlock #undef pthread_rwlock_wrlock #undef pthread_rwlockattr_destroy -#undef pthread_rwlockattr_getkind_np #undef pthread_rwlockattr_getpshared #undef pthread_rwlockattr_init -#undef pthread_rwlockattr_setkind_np #undef pthread_rwlockattr_setpshared #undef pthread_self #undef pthread_set_name_np Modified: head/lib/libthr/pthread.map ============================================================================== --- head/lib/libthr/pthread.map Wed Oct 20 01:22:04 2010 (r214092) +++ head/lib/libthr/pthread.map Wed Oct 20 02:34:02 2010 (r214093) @@ -318,9 +318,7 @@ FBSDprivate_1.0 { _pthread_rwlock_wrlock; _pthread_rwlockattr_destroy; _pthread_rwlockattr_getpshared; - _pthread_rwlockattr_getkind_np; _pthread_rwlockattr_init; - _pthread_rwlockattr_setkind_np; _pthread_rwlockattr_setpshared; _pthread_self; _pthread_set_name_np; @@ -403,8 +401,6 @@ FBSD_1.1 { FBSD_1.2 { openat; - pthread_rwlockattr_getkind_np; - pthread_rwlockattr_setkind_np; setcontext; swapcontext; }; Modified: head/lib/libthr/thread/thr_private.h ============================================================================== --- head/lib/libthr/thread/thr_private.h Wed Oct 20 01:22:04 2010 (r214092) +++ head/lib/libthr/thread/thr_private.h Wed Oct 20 02:34:02 2010 (r214093) @@ -285,14 +285,11 @@ struct pthread_prio { struct pthread_rwlockattr { int pshared; - int kind; }; struct pthread_rwlock { struct urwlock lock; struct pthread *owner; - int recurse; - int kind; }; /* Modified: head/lib/libthr/thread/thr_rwlock.c ============================================================================== --- head/lib/libthr/thread/thr_rwlock.c Wed Oct 20 01:22:04 2010 (r214092) +++ head/lib/libthr/thread/thr_rwlock.c Wed Oct 20 02:34:02 2010 (r214093) @@ -63,19 +63,13 @@ __weak_reference(_pthread_rwlock_timedwr */ static int -rwlock_init(pthread_rwlock_t *rwlock, const pthread_rwlockattr_t *attr) +rwlock_init(pthread_rwlock_t *rwlock, const pthread_rwlockattr_t *attr __unused) { pthread_rwlock_t prwlock; prwlock = (pthread_rwlock_t)calloc(1, sizeof(struct pthread_rwlock)); if (prwlock == NULL) return (ENOMEM); - if (attr != NULL) - prwlock->kind = (*attr)->kind; - else - prwlock->kind = PTHREAD_RWLOCK_DEFAULT_NP; - if (prwlock->kind == PTHREAD_RWLOCK_PREFER_READER_NP) - prwlock->lock.rw_flags |= URWLOCK_PREFER_READER; *rwlock = prwlock; return (0); } @@ -118,7 +112,7 @@ init_static(struct pthread *thread, pthr } int -_pthread_rwlock_init(pthread_rwlock_t *rwlock, const pthread_rwlockattr_t *attr) +_pthread_rwlock_init (pthread_rwlock_t *rwlock, const pthread_rwlockattr_t *attr) { *rwlock = NULL; return (rwlock_init(rwlock, attr)); @@ -266,14 +260,6 @@ rwlock_wrlock_common (pthread_rwlock_t * CHECK_AND_INIT_RWLOCK - if (__predict_false(prwlock->owner == curthread)) { - if (__predict_false( - prwlock->kind == PTHREAD_RWLOCK_PREFER_WRITER_NP)) { - prwlock->recurse++; - return (0); - } - } - /* * POSIX said the validity of the abstimeout parameter need * not be checked if the lock can be immediately acquired. @@ -349,13 +335,6 @@ _pthread_rwlock_unlock (pthread_rwlock_t if (state & URWLOCK_WRITE_OWNER) { if (__predict_false(prwlock->owner != curthread)) return (EPERM); - if (__predict_false( - prwlock->kind == PTHREAD_RWLOCK_PREFER_WRITER_NP)) { - if (prwlock->recurse > 0) { - prwlock->recurse--; - return (0); - } - } prwlock->owner = NULL; } Modified: head/lib/libthr/thread/thr_rwlockattr.c ============================================================================== --- head/lib/libthr/thread/thr_rwlockattr.c Wed Oct 20 01:22:04 2010 (r214092) +++ head/lib/libthr/thread/thr_rwlockattr.c Wed Oct 20 02:34:02 2010 (r214093) @@ -36,10 +36,8 @@ __weak_reference(_pthread_rwlockattr_destroy, pthread_rwlockattr_destroy); __weak_reference(_pthread_rwlockattr_getpshared, pthread_rwlockattr_getpshared); -__weak_reference(_pthread_rwlockattr_getkind_np, pthread_rwlockattr_getkind_np); __weak_reference(_pthread_rwlockattr_init, pthread_rwlockattr_init); __weak_reference(_pthread_rwlockattr_setpshared, pthread_rwlockattr_setpshared); -__weak_reference(_pthread_rwlockattr_setkind_np, pthread_rwlockattr_setkind_np); int _pthread_rwlockattr_destroy(pthread_rwlockattr_t *rwlockattr) @@ -83,7 +81,6 @@ _pthread_rwlockattr_init(pthread_rwlocka return(ENOMEM); prwlockattr->pshared = PTHREAD_PROCESS_PRIVATE; - prwlockattr->kind = PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP; *rwlockattr = prwlockattr; return(0); @@ -100,22 +97,3 @@ _pthread_rwlockattr_setpshared(pthread_r return(0); } - -int -_pthread_rwlockattr_setkind_np(pthread_rwlockattr_t *attr, int kind) -{ - if (kind != PTHREAD_RWLOCK_PREFER_READER_NP && - kind != PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP && - kind != PTHREAD_RWLOCK_PREFER_WRITER_NP) { - return (EINVAL); - } - (*attr)->kind = kind; - return (0); -} - -int -_pthread_rwlockattr_getkind_np(const pthread_rwlockattr_t *attr, int *kind) -{ - *kind = (*attr)->kind; - return (0); -} _______________________________________________ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"