[PATCH] D37612: [XRay][compiler-rt] Use a single global volatile recursion guard for FDR handlers
Dean Michael Berris via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Sep 8 01:18:08 PDT 2017
dberris created this revision.
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.
https://reviews.llvm.org/D37612
Files:
lib/xray/xray_fdr_logging.cc
lib/xray/xray_fdr_logging_impl.h
Index: lib/xray/xray_fdr_logging_impl.h
===================================================================
--- lib/xray/xray_fdr_logging_impl.h
+++ lib/xray/xray_fdr_logging_impl.h
@@ -571,6 +571,8 @@
}
}
+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 @@
// 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!");
Index: lib/xray/xray_fdr_logging.cc
===================================================================
--- lib/xray/xray_fdr_logging.cc
+++ lib/xray/xray_fdr_logging.cc
@@ -42,7 +42,7 @@
// 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 @@
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 @@
using namespace __xray;
if (flags()->xray_fdr_log) {
XRayLogImpl Impl{
- fdrLoggingInit, fdrLoggingFinalize, fdrLoggingHandleArg0,
+ fdrLoggingInit,
+ fdrLoggingFinalize,
+ fdrLoggingHandleArg0,
fdrLoggingFlush,
};
__xray_set_log_impl(Impl);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D37612.114312.patch
Type: text/x-patch
Size: 2008 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170908/29fbea35/attachment.bin>
More information about the llvm-commits
mailing list