kernel - Refactor dsched ref/unref routines
authorMatthew Dillon <dillon@apollo.backplane.com>
Tue, 1 Mar 2011 23:52:19 +0000 (15:52 -0800)
committerMatthew Dillon <dillon@apollo.backplane.com>
Tue, 1 Mar 2011 23:52:19 +0000 (15:52 -0800)
commit265b0d4af67ddbef1cf048a4fd2783bfdec1795c
treeea09af2dc26f4b9e70ceb12ea00d0f41ca42fece
parentfd87e9e4b293977dbbe9a61805338f2190c4a9a9
kernel - Refactor dsched ref/unref routines

* Refactor the dsched ref/unref routines to handle 1->0 transitions
  atomically and to properly deal with 1->0 races related to any
  re-referencing of the structure which can occur concurrently.

  Such races can occur because the structure must acquire other locks
  while removing itself from the various lists it is on and thus can
  be accessed via those lists in the mean time.

  Instead of using -0x400 as a separate atomic op after a 1->0 transition
  we directly transition from 1 to 0x80000000, removing a race condition.

  This also allows temporary references to be made during destruction.

* Get a temporary ref and re-check flag state after acquiring a lock to
  determine if the structure in question is still on the list we are trying
  to remove it from.
sys/kern/kern_dsched.c