]> git.proxmox.com Git - mirror_spl.git/commit
Block in cv_destroy() on all waiters
authorBrian Behlendorf <behlendorf1@llnl.gov>
Fri, 4 Feb 2011 22:09:08 +0000 (14:09 -0800)
committerBrian Behlendorf <behlendorf1@llnl.gov>
Fri, 4 Feb 2011 22:09:08 +0000 (14:09 -0800)
commitd599e4fa793b304609d32e336c668b70831b6b3b
tree1c1fae24ec55db39e7f35285c31b6a52c2fa5d6f
parent0aff071d18bbef2fb6b2ab41f60ab3b957ae58c7
Block in cv_destroy() on all waiters

Previously we would ASSERT in cv_destroy() if it was ever called
with active waiters.  However, I've now seen several instances in
OpenSolaris code where they do the following:

  cv_broadcast();
  cv_destroy();

This leaves no time for active waiters to be woken up and scheduled
and we trip the ASSERT.  This has not been observed to be an issue
on OpenSolaris because their cv_destroy() basically does nothing.
They still do run the risk of the memory being free'd after the
cv_destroy() and hitting a bad paging request.  But in practice
this race is so small and unlikely it either doesn't happen, or
is so unlikely when it does happen the root cause has not yet been
identified.

Rather than risk the same issue in our code this change updates
cv_destroy() to block until all waiters have been woken and
scheduled.  This may take some time because each waiter must
acquire the mutex.

This change may have an impact on performance for frequently
created and destroyed condition variables.  That however is a price
worth paying it avoid crashing your system.  If performance issues
are observed they can be addressed by the caller.
include/sys/condvar.h
module/spl/spl-condvar.c