From fbb31b4519256c119b99fcf5b8bed9dd0acb937b Mon Sep 17 00:00:00 2001 From: Brian Gianforcaro Date: Tue, 14 Sep 2021 11:05:17 -0700 Subject: [PATCH] Kernel: Disable lock rank enforcement by default for now There are a few violations with signal handling that I won't be able to fix it until later this week. So lets put lock rank enforcement under a debug option for now so other folks don't hit these crashes until rank enforcement is more fleshed out. --- Kernel/Debug.h.in | 4 ++++ Kernel/Locking/LockRank.cpp | 16 ++++++++++------ Meta/CMake/all_the_debug_macros.cmake | 1 + 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/Kernel/Debug.h.in b/Kernel/Debug.h.in index 78820e6848..d8315c095c 100644 --- a/Kernel/Debug.h.in +++ b/Kernel/Debug.h.in @@ -170,6 +170,10 @@ #cmakedefine01 LOCK_IN_CRITICAL_DEBUG #endif +#ifndef LOCK_RANK_ENFORCEMENT +#cmakedefine01 LOCK_RANK_ENFORCEMENT +#endif + #ifndef LOCK_RESTORE_DEBUG #cmakedefine01 LOCK_RESTORE_DEBUG #endif diff --git a/Kernel/Locking/LockRank.cpp b/Kernel/Locking/LockRank.cpp index 62efe7400d..338e24d508 100644 --- a/Kernel/Locking/LockRank.cpp +++ b/Kernel/Locking/LockRank.cpp @@ -14,16 +14,20 @@ namespace Kernel { void track_lock_acquire(LockRank rank) { - auto thread = Thread::current(); - if (thread && !thread->is_crashing()) - thread->track_lock_acquire(rank); + if constexpr (LOCK_RANK_ENFORCEMENT) { + auto thread = Thread::current(); + if (thread && !thread->is_crashing()) + thread->track_lock_acquire(rank); + } } void track_lock_release(LockRank rank) { - auto thread = Thread::current(); - if (thread && !thread->is_crashing()) - thread->track_lock_release(rank); + if constexpr (LOCK_RANK_ENFORCEMENT) { + auto thread = Thread::current(); + if (thread && !thread->is_crashing()) + thread->track_lock_release(rank); + } } } diff --git a/Meta/CMake/all_the_debug_macros.cmake b/Meta/CMake/all_the_debug_macros.cmake index 896b1803f8..0787970f2c 100644 --- a/Meta/CMake/all_the_debug_macros.cmake +++ b/Meta/CMake/all_the_debug_macros.cmake @@ -102,6 +102,7 @@ set(LINE_EDITOR_DEBUG ON) set(LOCAL_SOCKET_DEBUG ON) set(LOCK_DEBUG ON) set(LOCK_IN_CRITICAL_DEBUG ON) +set(LOCK_RANK_ENFORCEMENT ON) set(LOCK_RESTORE_DEBUG ON) set(LOCK_TRACE_DEBUG ON) set(LOOKUPSERVER_DEBUG ON)