cvs commit: src/sys/kern kern_timeout.c
emaste at FreeBSD.org
Wed Jul 30 20:22:31 UTC 2008
emaste 2008-07-30 20:22:21 UTC
FreeBSD src repository
Modified files: (Branch: RELENG_6)
SVN rev 181012 on 2008-07-30 20:22:21Z by emaste
MFC improved and simplified callout_drain logic and improved ktr(4)
Use the recently added msleep_spin() function to simplify the
callout_drain() logic. We no longer need a separate non-spin mutex to
do sleep/wakeup with, instead we can now just use the one spin mutex
to manage all the callout functionality.
Improve ktr(4) logging for callout(9) subsystem. Log all inserts and
removals, including failures, into the callwheel.
Fix an old standing LOR between callout_lock and sleepqueues chain
(which could lead to a deadlock).
- sleepq_set_timeout acquires callout_lock (via callout_reset()) only
with sleepq chain lock held
- msleep_spin in _callout_stop_safe lock the sleepqueue chain with
In order to solve this don't use msleep_spin in _callout_stop_safe()
but use directly sleepqueues as inline msleep_spin code. Rearrange the
wakeup path in order to have it consistent too.
Close a race that snuck in with the recent changes to fix a LOR
between the callout_lock spin lock and the sleepqueue spin locks.
In the fix, callout_drain() has to drop the callout_lock so it can
acquire the sleepqueue lock. The state of the callout can change
while the callout_lock is held however (for example, it can be
rescheduled via callout_reset()). The previous code assumed that the
only state change that could happen is that the callout could finish
executing. This change alters callout_drain() to effectively restart
and recheck everything after it acquires the sleepqueue lock thus
handling all the possible states that the callout could be in after
any changes while callout_lock was dropped.
Revision Changes Path
188.8.131.52 +106 -60 src/sys/kern/kern_timeout.c
More information about the cvs-all