From 88b6bb656f7607f3af4e4c1e3c5c0267d2f87ebd Mon Sep 17 00:00:00 2001 From: Hartmut Kaiser Date: Sat, 11 Feb 2017 11:32:10 -0600 Subject: [PATCH] Fixing configuration options for spinlock-deadlock detection - exposing `HPX_WITH_SPINLOCK_DEADLOCK_DETECTION` at configuration time (default is OFF) - flyby: adding missing documentation --- CMakeLists.txt | 8 ++++++++ docs/manual/build_system/cmake_variables.qbk | 2 ++ docs/manual/config_defaults.qbk | 14 ++++++++++++++ src/util/runtime_configuration.cpp | 8 ++++---- 4 files changed, 28 insertions(+), 4 deletions(-) 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 289636f9224d..49ef8292440e 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} [hpx.stacks] small_size = ${HPX_SMALL_STACK_SIZE:} @@ -115,6 +117,18 @@ 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.stacks.small_size`] [This is initialized to the small stack size to be used by __hpx__-threads. Set by default to the value of the compile time preprocessor constant diff --git a/src/util/runtime_configuration.cpp b/src/util/runtime_configuration.cpp index 82e5500e447b..f5d3c6e70cba 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}", @@ -835,7 +835,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;