git: kernel - Fix GCC reordering problem with td_critcount

Matthew Dillon dillon at crater.dragonflybsd.org
Mon Oct 2 18:43:41 PDT 2017


commit a4d95680362b7eba0c4840b8d5598533900a2f17
Author: Matthew Dillon <dillon at apollo.backplane.com>
Date:   Mon Oct 2 18:42:34 2017 -0700

    kernel - Fix GCC reordering problem with td_critcount
    
    * Wrap all ++td->td_critcount and --td->td_critcount use cases
      with an inline which executes cpu_ccfence() before and after,
      to guarantee that GCC does not try to reorder the operation around
      critical memory changes.
    
    * This fixes a race in lockmgr() and possibly a few other places
      too.

Summary of changes:
 sys/kern/kern_mutex.c                      | 40 ++++++++++++++++--------------
 sys/kern/kern_spinlock.c                   |  3 ++-
 sys/kern/lwkt_thread.c                     |  1 +
 sys/platform/vkernel64/platform/machintr.c |  2 ++
 sys/platform/vkernel64/x86_64/exception.c  | 20 +++++++++------
 sys/sys/mutex2.h                           | 12 ++++-----
 sys/sys/spinlock2.h                        | 20 +++++++--------
 sys/sys/thread2.h                          | 28 ++++++++++++++++++---
 8 files changed, 78 insertions(+), 48 deletions(-)

http://gitweb.dragonflybsd.org/dragonfly.git/commitdiff/a4d95680362b7eba0c4840b8d5598533900a2f17


-- 
DragonFly BSD source repository



More information about the Commits mailing list