diff --git a/CMakeLists.txt b/CMakeLists.txt index 2ec76944ed4e..35eb8530948e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -464,6 +464,14 @@ hpx_option(HPX_WITH_SWAP_CONTEXT_EMULATION BOOL "Emulate SwapContext API for coroutines (default: OFF)" OFF CATEGORY "Thread Manager" ADVANCED) +hpx_option(HPX_WITH_SPINLOCK_DEADLOCK_DETECTION BOOL + "Enable spinlock deadlock detection (default: OFF)" + OFF CATEGORY "Thread Manager" ADVANCED) + +if(HPX_WITH_SPINLOCK_DEADLOCK_DETECTION) + hpx_add_config_define(HPX_HAVE_SPINLOCK_DEADLOCK_DETECTION) +endif() + ## Profiling related build options hpx_option(HPX_WITH_APEX BOOL "Enable APEX instrumentation support." OFF CATEGORY "Profiling") diff --git a/docs/manual/build_system/cmake_variables.qbk b/docs/manual/build_system/cmake_variables.qbk index 31622cac2f7a..ea4675553b7f 100644 --- a/docs/manual/build_system/cmake_variables.qbk +++ b/docs/manual/build_system/cmake_variables.qbk @@ -140,6 +140,7 @@ The options are split into these categories: * [link build_system.cmake_variables.HPX_WITH_MAX_CPU_COUNT HPX_WITH_MAX_CPU_COUNT] * [link build_system.cmake_variables.HPX_WITH_MORE_THAN_64_THREADS HPX_WITH_MORE_THAN_64_THREADS] * [link build_system.cmake_variables.HPX_WITH_SCHEDULER_LOCAL_STORAGE HPX_WITH_SCHEDULER_LOCAL_STORAGE] +* [link build_system.cmake_variables.HPX_WITH_SPINLOCK_DEADLOCK_DETECTION HPX_WITH_SPINLOCK_DEADLOCK_DETECTION] * [link build_system.cmake_variables.HPX_WITH_STACKTRACES HPX_WITH_STACKTRACES] * [link build_system.cmake_variables.HPX_WITH_SWAP_CONTEXT_EMULATION HPX_WITH_SWAP_CONTEXT_EMULATION] * [link build_system.cmake_variables.HPX_WITH_THREAD_BACKTRACE_DEPTH HPX_WITH_THREAD_BACKTRACE_DEPTH] @@ -159,6 +160,7 @@ The options are split into these categories: [[[#build_system.cmake_variables.HPX_WITH_MAX_CPU_COUNT] `HPX_WITH_MAX_CPU_COUNT:STRING`][HPX applications will not use more that this number of OS-Threads (default: 64)]] [[[#build_system.cmake_variables.HPX_WITH_MORE_THAN_64_THREADS] `HPX_WITH_MORE_THAN_64_THREADS:BOOL`][HPX applications will be able to run on more than 64 cores]] [[[#build_system.cmake_variables.HPX_WITH_SCHEDULER_LOCAL_STORAGE] `HPX_WITH_SCHEDULER_LOCAL_STORAGE:BOOL`][Enable scheduler local storage for all HPX schedulers (default: OFF)]] + [[[#build_system.cmake_variables.HPX_WITH_SPINLOCK_DEADLOCK_DETECTION] `HPX_WITH_SPINLOCK_DEADLOCK_DETECTION:BOOL`][Enable spinlock deadlock detection (default: OFF)]] [[[#build_system.cmake_variables.HPX_WITH_STACKTRACES] `HPX_WITH_STACKTRACES:BOOL`][Attach backtraces to HPX exceptions (default: ON)]] [[[#build_system.cmake_variables.HPX_WITH_SWAP_CONTEXT_EMULATION] `HPX_WITH_SWAP_CONTEXT_EMULATION:BOOL`][Emulate SwapContext API for coroutines (default: OFF)]] [[[#build_system.cmake_variables.HPX_WITH_THREAD_BACKTRACE_DEPTH] `HPX_WITH_THREAD_BACKTRACE_DEPTH:STRING`][Thread stack back trace depth being captured (default: 5)]] diff --git a/docs/manual/config_defaults.qbk b/docs/manual/config_defaults.qbk index c9dd95bb4bb2..d610d79dc81d 100644 --- a/docs/manual/config_defaults.qbk +++ b/docs/manual/config_defaults.qbk @@ -60,6 +60,8 @@ by section basis below. lock_detection = ${HPX_LOCK_DETECTION:0} throw_on_held_lock = ${HPX_THROW_ON_HELD_LOCK:1} minimal_deadlock_detection = + spinlock_deadlock_detection = + spinlock_deadlock_detection_limit = ${HPX_SPINLOCK_DEADLOCK_DETECTION_LIMIT:1000000} max_background_threads = ${HPX_MAX_BACKGROUND_THREADS:$[hpx.os_threads]} max_idle_loop_count = ${HPX_MAX_IDLE_LOOP_COUNT:} max_busy_loop_count = ${HPX_MAX_BUSY_LOOP_COUNT:} @@ -118,6 +120,17 @@ by section basis below. RelWithDebInfo, RelMinSize builds), this setting is effective only if `HPX_WITH_THREAD_DEADLOCK_DETECTION` is set during configuration in CMake.]] + [[`hpx.spinlock_deadlock_detection`] + [This setting verifies that spinlocks don't spin longer than specified using + the `hpx.spinlock_deadlock_detection_limit`. This setting is applicable only + if `HPX_WITH_SPINLOCK_DEADLOCK_DETECTION` is set during configuration in + CMake. By default this is set to `1` (for Debug builds) or to `0` (for Release, + RelWithDebInfo, RelMinSize builds).]] + [[`hpx.spinlock_deadlock_detection_limit`] + [This setting specifies the upper limit of allowed number of spins that + spinlocks are allowed to perform. This setting is applicable only + if `HPX_WITH_SPINLOCK_DEADLOCK_DETECTION` is set during configuration in + CMake. By default this is set to `1000000`.]] [[`hpx.max_background_threads`] [This setting defines the number of threads in the scheduler which are used to execute background work. By default this is the same as the number of diff --git a/src/util/runtime_configuration.cpp b/src/util/runtime_configuration.cpp index 13033bab4c1e..29dba76d1c56 100644 --- a/src/util/runtime_configuration.cpp +++ b/src/util/runtime_configuration.cpp @@ -166,11 +166,11 @@ namespace hpx { namespace util #endif #ifdef HPX_HAVE_SPINLOCK_DEADLOCK_DETECTION #ifdef HPX_DEBUG - "spinlick_deadlock_detection = ${HPX_SPINLOCK_DEADLOCK_DETECTION:1}", + "spinlock_deadlock_detection = ${HPX_SPINLOCK_DEADLOCK_DETECTION:1}", #else - "spinlick_deadlock_detection = ${HPX_SPINLOCK_DEADLOCK_DETECTION:0}", + "spinlock_deadlock_detection = ${HPX_SPINLOCK_DEADLOCK_DETECTION:0}", #endif - "spinlick_deadlock_detection_limit = " + "spinlock_deadlock_detection_limit = " "${HPX_SPINLOCK_DEADLOCK_DETECTION_LIMIT:1000000}", #endif "expect_connecting_localities = ${HPX_EXPECT_CONNECTING_LOCALITIES:0}", @@ -841,7 +841,7 @@ namespace hpx { namespace util util::section const* sec = get_section("hpx"); if (nullptr != sec) { return hpx::util::get_entry_as( - *sec, "spinlick_deadlock_detection_limit", "1000000"); + *sec, "spinlock_deadlock_detection_limit", "1000000"); } } return HPX_SPINLOCK_DEADLOCK_DETECTION_LIMIT;