git: kernel - Fix callout race and panic (2)

Matthew Dillon dillon at crater.dragonflybsd.org
Tue Aug 22 09:37:17 PDT 2017


commit 7b045ca837e37d7065b8971267d2c95362cd6276
Author: Matthew Dillon <dillon at apollo.backplane.com>
Date:   Tue Aug 22 09:26:27 2017 -0700

    kernel - Fix callout race and panic (2)
    
    * Previous fix couldn't handle a callout_stop() vs callout_reset() race
      on different cpus.  When this race occurred, the callout_stop() would
      get stuck waiting for the ARMED bit to clear, which it never would
      because a new callout_reset() re-armed it.
    
    * Refactor the callout code to clean it up.  Remove the ARMED flag, instead
      a callout is considered ARMED if the IPI_MASK counter bits are not zero
      or PENDING is set.  Use these rules to lock-in the owning cpu with an
      atomic op
    
    * Integrate all flags settings in IPIs with the atomic decrement of the
      IPI_MASK count, rather than as separate operations.
    
    * callout_stop() now just waits for the IPI sequence to end.  callout_reset()
      now re-tests whether the callout is still armed or not after callout_stop()
      returns (since it needs to know for sure) before it tries to take over
      the callout.  This fixes the race.

Summary of changes:
 sys/kern/kern_timeout.c | 547 ++++++++++++++++++------------------------------
 sys/sys/callout.h       |  65 ++++--
 2 files changed, 250 insertions(+), 362 deletions(-)

http://gitweb.dragonflybsd.org/dragonfly.git/commitdiff/7b045ca837e37d7065b8971267d2c95362cd6276


-- 
DragonFly BSD source repository



More information about the Commits mailing list