Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 03 Feb 2010 12:05:02 +0800
From:      David Xu <davidxu@freebsd.org>
To:        Justin Teller <justin.teller@gmail.com>
Cc:        freebsd-current@freebsd.org
Subject:   Re: Bug in kern_umtx.c -- read-write locks
Message-ID:  <4B68F5EE.9060606@freebsd.org>
In-Reply-To: <c47019cc1002021207rc9ca100ga0dd865febdb0014@mail.gmail.com>
References:  <c47019cc1002021207rc9ca100ga0dd865febdb0014@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
Justin Teller wrote:
> I was working on a highly threaded app (125+ threads) that was using
> the pthread rw locks, and we were stalling at strange times.  After a
> lot of debugging in our app, we found that a call to
> pthread_rwlock_wrlock() would sometimes never return -- it seemed like
> a wakeup was lost.  After we convinced ourselves the bug wasn't in the
> app's locking code, I started digging into the kernel.  I found that
> there is an issue where a wakeup can be "lost" when a thread goes to
> sleep calling pthread_rwlock_wrlock.  The issue is in the file
> kern_umtx.c in the function do_rw_wrlock(): the code busies the lock
> before sleeping, but when it tries to set the waiters bit, it's
> looking at at old value (from the "try-lock" just before the busy).
> This allows a race where a thread can go to sleep w/o setting the
> waiters bit.  Then the last thread to unlock won't wakeup the sleeping
> thread.  The patch below (based off of 8.0 release) fixes my problem
> for the write lock and should fix the complimentary issue in
> do_rw_rdlock.
> 
>  <snip>

Committed, thanks!




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?4B68F5EE.9060606>