summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDmitry Vyukov <dvyukov@google.com>2013-03-21 07:02:36 +0000
committerDmitry Vyukov <dvyukov@google.com>2013-03-21 07:02:36 +0000
commit48e5d4a2d3a53a189fd97715e75f22ce34684282 (patch)
tree5a3966da768caaf105880aa468f680bec2ed0ed6
parent5e797a8e57b1d492e0a6c892aefef5a5c8860841 (diff)
downloadbcm5719-llvm-48e5d4a2d3a53a189fd97715e75f22ce34684282.tar.gz
bcm5719-llvm-48e5d4a2d3a53a189fd97715e75f22ce34684282.zip
tsan: flush symbolizer cache if not symbolized for more than 5 seconds
llvm-svn: 177629
-rw-r--r--compiler-rt/lib/tsan/rtl/tsan_rtl.cc21
-rw-r--r--compiler-rt/lib/tsan/rtl/tsan_rtl.h1
-rw-r--r--compiler-rt/lib/tsan/rtl/tsan_rtl_report.cc1
3 files changed, 19 insertions, 4 deletions
diff --git a/compiler-rt/lib/tsan/rtl/tsan_rtl.cc b/compiler-rt/lib/tsan/rtl/tsan_rtl.cc
index b39b836234c..7c73289dc22 100644
--- a/compiler-rt/lib/tsan/rtl/tsan_rtl.cc
+++ b/compiler-rt/lib/tsan/rtl/tsan_rtl.cc
@@ -23,6 +23,7 @@
#include "tsan_rtl.h"
#include "tsan_mman.h"
#include "tsan_suppressions.h"
+#include "tsan_symbolize.h"
volatile int __tsan_resumed = 0;
@@ -95,12 +96,11 @@ ThreadState::ThreadState(Context *ctx, int tid, int unique_id, u64 epoch,
, tls_size(tls_size) {
}
-static void MemoryProfiler(int i, fd_t fd) {
- Context *ctx = CTX();
- InternalScopedBuffer<char> buf(4096);
+static void MemoryProfiler(Context *ctx, fd_t fd, int i) {
uptr n_threads;
uptr n_running_threads;
ctx->thread_registry->GetNumberOfThreads(&n_threads, &n_running_threads);
+ InternalScopedBuffer<char> buf(4096);
internal_snprintf(buf.data(), buf.size(), "%d: nthr=%d nlive=%d\n",
i, n_threads, n_running_threads);
internal_write(fd, buf.data(), internal_strlen(buf.data()));
@@ -110,6 +110,7 @@ static void MemoryProfiler(int i, fd_t fd) {
static void BackgroundThread(void *arg) {
ScopedInRtl in_rtl;
+ Context *ctx = CTX();
fd_t mprof_fd = kInvalidFd;
if (flags()->profile_memory && flags()->profile_memory[0]) {
@@ -128,6 +129,7 @@ static void BackgroundThread(void *arg) {
SleepForSeconds(1);
u64 now = NanoTime();
+ // Flush memory if requested.
if (flags()->flush_memory_ms) {
if (last_flush + flags()->flush_memory_ms * 1000*1000 > now) {
FlushShadowMemory();
@@ -135,8 +137,19 @@ static void BackgroundThread(void *arg) {
}
}
+ // Write memory profile if requested.
if (mprof_fd != kInvalidFd)
- MemoryProfiler(i, mprof_fd);
+ MemoryProfiler(ctx, mprof_fd, i);
+
+#ifndef TSAN_GO
+ // Flush symbolizer cache if not symbolized for more than 5 seconds.
+ u64 last = atomic_load(&ctx->last_symbolize_time_ns, memory_order_relaxed);
+ if (last != 0 && last + 5*1000*1000 > now) {
+ Lock l(&ctx->report_mtx);
+ SymbolizeFlush();
+ atomic_store(&ctx->last_symbolize_time_ns, 0, memory_order_relaxed);
+ }
+#endif
}
}
diff --git a/compiler-rt/lib/tsan/rtl/tsan_rtl.h b/compiler-rt/lib/tsan/rtl/tsan_rtl.h
index 2b9aaf4ef0b..e57fcc735d1 100644
--- a/compiler-rt/lib/tsan/rtl/tsan_rtl.h
+++ b/compiler-rt/lib/tsan/rtl/tsan_rtl.h
@@ -516,6 +516,7 @@ struct Context {
Mutex report_mtx;
int nreported;
int nmissed_expected;
+ atomic_uint64_t last_symbolize_time_ns;
ThreadRegistry *thread_registry;
diff --git a/compiler-rt/lib/tsan/rtl/tsan_rtl_report.cc b/compiler-rt/lib/tsan/rtl/tsan_rtl_report.cc
index b343ff3d582..18ab18e0cbf 100644
--- a/compiler-rt/lib/tsan/rtl/tsan_rtl_report.cc
+++ b/compiler-rt/lib/tsan/rtl/tsan_rtl_report.cc
@@ -495,6 +495,7 @@ bool OutputReport(Context *ctx,
const ScopedReport &srep,
const ReportStack *suppress_stack1,
const ReportStack *suppress_stack2) {
+ atomic_store(&ctx->last_symbolize_time_ns, NanoTime(), memory_order_relaxed);
const ReportDesc *rep = srep.GetReport();
uptr suppress_pc = IsSuppressed(rep->typ, suppress_stack1);
if (suppress_pc == 0)
OpenPOWER on IntegriCloud