diff options
author | Dean Michael Berris <dberris@google.com> | 2017-09-12 01:37:59 +0000 |
---|---|---|
committer | Dean Michael Berris <dberris@google.com> | 2017-09-12 01:37:59 +0000 |
commit | a16d671c83feef2f63925d62a581a2fc32a97d5e (patch) | |
tree | 522710702a3ae2a49d4a7cab396bd99b79ef942b /lib/xray | |
parent | 5b686ccf0939d3df103a16b429d5719889c2fdd5 (diff) |
[XRay][compiler-rt] Use a single global volatile recursion guard for FDR handlers
Summary:
Before this change, the recursion guard for the flight data recorder
(FDR) mode handlers were independent. This change makes it so that when
a handler is already in the process of running and somehow the same or
another handler starts running -- say in a signal handler, while the
XRay handler is executing -- then we can use the same thread-local
recursion guard to stop the second handler from running.
Reviewers: kpw, eizan
Subscribers: llvm-commits
Differential Revision: https://reviews.llvm.org/D37612
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@312992 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/xray')
-rw-r--r-- | lib/xray/xray_fdr_logging.cc | 7 | ||||
-rw-r--r-- | lib/xray/xray_fdr_logging_impl.h | 3 |
2 files changed, 6 insertions, 4 deletions
diff --git a/lib/xray/xray_fdr_logging.cc b/lib/xray/xray_fdr_logging.cc index dee0e23ee..6123c3e47 100644 --- a/lib/xray/xray_fdr_logging.cc +++ b/lib/xray/xray_fdr_logging.cc @@ -42,7 +42,7 @@ namespace __xray { // NOTE: This is a pointer to avoid having to do atomic operations at // initialization time. This is OK to leak as there will only be one bufferqueue // for the runtime, initialized once through the fdrInit(...) sequence. -std::shared_ptr<BufferQueue>* BQ = nullptr; +std::shared_ptr<BufferQueue> *BQ = nullptr; __sanitizer::atomic_sint32_t LogFlushStatus = { XRayLogFlushStatus::XRAY_LOG_NOT_FLUSHING}; @@ -207,7 +207,6 @@ void fdrLoggingHandleCustomEvent(void *Event, auto TSC_CPU = getTimestamp(); auto &TSC = std::get<0>(TSC_CPU); auto &CPU = std::get<1>(TSC_CPU); - thread_local bool Running = false; RecursionGuard Guard{Running}; if (!Guard) { assert(Running && "RecursionGuard is buggy!"); @@ -298,7 +297,9 @@ static auto UNUSED Unused = [] { using namespace __xray; if (flags()->xray_fdr_log) { XRayLogImpl Impl{ - fdrLoggingInit, fdrLoggingFinalize, fdrLoggingHandleArg0, + fdrLoggingInit, + fdrLoggingFinalize, + fdrLoggingHandleArg0, fdrLoggingFlush, }; __xray_set_log_impl(Impl); diff --git a/lib/xray/xray_fdr_logging_impl.h b/lib/xray/xray_fdr_logging_impl.h index ce81e4364..b2f7f3f23 100644 --- a/lib/xray/xray_fdr_logging_impl.h +++ b/lib/xray/xray_fdr_logging_impl.h @@ -571,6 +571,8 @@ inline void endBufferIfFull() XRAY_NEVER_INSTRUMENT { } } +thread_local volatile bool Running = false; + inline void processFunctionHook( int32_t FuncId, XRayEntryType Entry, uint64_t TSC, unsigned char CPU, int (*wall_clock_reader)(clockid_t, struct timespec *), @@ -581,7 +583,6 @@ inline void processFunctionHook( // don't want to be clobbering potentially partial writes already happening in // the thread. We use a simple thread_local latch to only allow one on-going // handleArg0 to happen at any given time. - thread_local volatile bool Running = false; RecursionGuard Guard{Running}; if (!Guard) { assert(Running == true && "RecursionGuard is buggy!"); |