llvm-project/llvm/lib
Dean Michael Berris 6ec72625f2 [XRay] Use optimistic logging model for FDR mode
Summary:
Before this change, the FDR mode implementation relied on at thread-exit
handling to return buffers back to the (global) buffer queue. This
introduces issues with the initialisation of the thread_local objects
which, even through the use of pthread_setspecific(...) may eventually
call into an allocation function. Similar to previous changes in this
line, we're finding that there is a huge potential for deadlocks when
initialising these thread-locals when the memory allocation
implementation is also xray-instrumented.

In this change, we limit the call to pthread_setspecific(...) to provide
a non-null value to associate to the key created with
pthread_key_create(...). While this doesn't completely eliminate the
potential for the deadlock(s), it does allow us to still clean up at
thread exit when we need to. The change is that we don't need to do more
work when starting and ending a thread's lifetime. We also have a test
to make sure that we actually can safely recycle the buffers in case we
end up re-using the buffer(s) available from the queue on multiple
thread entry/exits.

This change cuts across both LLVM and compiler-rt to allow us to update
both the XRay runtime implementation as well as the library support for
loading these new versions of the FDR mode logging. Version 2 of the FDR
logging implementation makes the following changes:

  * Introduction of a new 'BufferExtents' metadata record that's outside
    of the buffer's contents but are written before the actual buffer.
    This data is associated to the Buffer handed out by the BufferQueue
    rather than a record that occupies bytes in the actual buffer.

  * Removal of the "end of buffer" records. This is in-line with the
    changes we described above, to allow for optimistic logging without
    explicit record writing at thread exit.

The optimistic logging model operates under the following assumptions:

  * Threads writing to the buffers will potentially race with the thread
    attempting to flush the log. To avoid this situation from occuring,
    we make sure that when we've finalized the logging implementation,
    that threads will see this finalization state on the next write, and
    either choose to not write records the thread would have written or
    write the record(s) in two phases -- first write the record(s), then
    update the extents metadata.

  * We change the buffer queue implementation so that once it's handed
    out a buffer to a thread, that we assume that buffer is marked
    "used" to be able to capture partial writes. None of this will be
    safe to handle if threads are racing to write the extents records
    and the reader thread is attempting to flush the log. The optimism
    comes from the finalization routine being required to complete
    before we attempt to flush the log.

This is a fairly significant semantics change for the FDR
implementation. This is why we've decided to update the version number
for FDR mode logs. The tools, however, still need to be able to support
older versions of the log until we finally deprecate those earlier
versions.

Reviewers: dblaikie, pelikan, kpw

Subscribers: llvm-commits, hiraditya

Differential Revision: https://reviews.llvm.org/D39526

llvm-svn: 318733
2017-11-21 07:16:57 +00:00
..
Analysis [InstSimplify] fold and/or of fcmp ord/uno when operand is known nnan 2017-11-19 15:34:27 +00:00
AsmParser [IR] redefine 'UnsafeAlgebra' / 'reassoc' fast-math-flags and add 'trans' fast-math-flag 2017-11-06 16:27:15 +00:00
BinaryFormat Simplify. 2017-10-19 01:32:18 +00:00
Bitcode [WebAssembly] Explicily disable comdat support for wasm output 2017-11-14 00:49:16 +00:00
CodeGen Revert "[CGP] Enable complex addr mode (2nd attempt)" 2017-11-21 06:03:43 +00:00
DebugInfo Don't #include MemoryBuffer.h from Host.h. 2017-11-17 01:00:35 +00:00
Demangle [ItaniumDemangle] Fix a exponential string copying bug 2017-05-28 23:24:52 +00:00
ExecutionEngine Fix 'not all control paths return a value' warning on MSVC builds 2017-11-09 14:56:17 +00:00
FuzzMutate [FuzzMutate] Fix windows build after rL318407. 2017-11-16 16:17:32 +00:00
Fuzzer [libFuzzer] Delete llvm/lib/Fuzzer 2017-10-16 20:48:19 +00:00
IR Current implementation of Value::replaceUsesExceptBlockAddr() uses UseList 2017-11-17 00:30:24 +00:00
IRReader Move the stripping of invalid debug info from the Verifier to AutoUpgrade. 2017-10-02 18:31:29 +00:00
LTO Fix a bunch more layering of CodeGen headers that are in Target 2017-11-17 01:07:10 +00:00
LineEditor
Linker Linker: Create a function declaration when moving a non-prevailing alias of function type. 2017-08-10 01:07:44 +00:00
MC [MC] Fix regression tests on Windows when git “core.autocrlf” is set to true. 2017-11-17 21:59:43 +00:00
Object Use TempFile in llvm-ar. NFC. 2017-11-14 01:21:15 +00:00
ObjectYAML Add ELF dynamic symbol support to yaml2obj/obj2yaml 2017-11-16 18:10:15 +00:00
Option Reverting r315590; it did not include changes for llvm-tblgen, which is causing link errors for several people. 2017-10-15 14:32:27 +00:00
Passes [(new) Pass Manager] instantiate SimplifyCFG with the same options as the old PM 2017-11-15 16:33:11 +00:00
ProfileData [Coverage] Use the wrapped segment when a line has entry segments 2017-11-09 02:33:43 +00:00
Support move static function. NFC 2017-11-21 05:35:45 +00:00
TableGen [globalisel][regbank] Warn about MIR ambiguities when register bank/class names clash. 2017-11-01 22:13:05 +00:00
Target [X86] Simplify type constraints for AVX2 masked gather. 2017-11-21 06:28:15 +00:00
Testing Force #define GTEST_LANG_CXX11. 2017-10-27 21:12:28 +00:00
ToolDrivers [COFF] Improve the check for functions that should get an extra underscore 2017-10-23 09:08:13 +00:00
Transforms [SCCP] If we replace with a constant, we can't replace with a range. 2017-11-21 00:21:52 +00:00
WindowsManifest Fix bug 34608 by moving private header out of public header. 2017-09-14 23:01:13 +00:00
XRay [XRay] Use optimistic logging model for FDR mode 2017-11-21 07:16:57 +00:00
CMakeLists.txt Moving libFuzzer from LLVM to compiler-rt. 2017-08-21 23:25:12 +00:00
LLVMBuild.txt Re-apply "Introduce FuzzMutate library" 2017-08-21 22:57:06 +00:00