[compiler-rt] r177638 - tsan: add flag to control symbolizer flush frequency
Dmitry Vyukov
dvyukov at google.com
Thu Mar 21 06:01:50 PDT 2013
Author: dvyukov
Date: Thu Mar 21 08:01:50 2013
New Revision: 177638
URL: http://llvm.org/viewvc/llvm-project?rev=177638&view=rev
Log:
tsan: add flag to control symbolizer flush frequency
Modified:
compiler-rt/trunk/lib/tsan/rtl/tsan_flags.cc
compiler-rt/trunk/lib/tsan/rtl/tsan_flags.h
compiler-rt/trunk/lib/tsan/rtl/tsan_rtl.cc
Modified: compiler-rt/trunk/lib/tsan/rtl/tsan_flags.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/tsan/rtl/tsan_flags.cc?rev=177638&r1=177637&r2=177638&view=diff
==============================================================================
--- compiler-rt/trunk/lib/tsan/rtl/tsan_flags.cc (original)
+++ compiler-rt/trunk/lib/tsan/rtl/tsan_flags.cc Thu Mar 21 08:01:50 2013
@@ -55,6 +55,7 @@ void InitializeFlags(Flags *f, const cha
f->verbosity = 0;
f->profile_memory = "";
f->flush_memory_ms = 0;
+ f->flush_symbolizer_ms = 5000;
f->stop_on_start = false;
f->running_on_valgrind = false;
f->external_symbolizer_path = "";
@@ -83,6 +84,7 @@ void InitializeFlags(Flags *f, const cha
ParseFlag(env, &f->verbosity, "verbosity");
ParseFlag(env, &f->profile_memory, "profile_memory");
ParseFlag(env, &f->flush_memory_ms, "flush_memory_ms");
+ ParseFlag(env, &f->flush_symbolizer_ms, "flush_symbolizer_ms");
ParseFlag(env, &f->stop_on_start, "stop_on_start");
ParseFlag(env, &f->external_symbolizer_path, "external_symbolizer_path");
ParseFlag(env, &f->history_size, "history_size");
Modified: compiler-rt/trunk/lib/tsan/rtl/tsan_flags.h
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/tsan/rtl/tsan_flags.h?rev=177638&r1=177637&r2=177638&view=diff
==============================================================================
--- compiler-rt/trunk/lib/tsan/rtl/tsan_flags.h (original)
+++ compiler-rt/trunk/lib/tsan/rtl/tsan_flags.h Thu Mar 21 08:01:50 2013
@@ -67,6 +67,8 @@ struct Flags {
const char *profile_memory;
// Flush shadow memory every X ms.
int flush_memory_ms;
+ // Flush symbolizer caches every X ms.
+ int flush_symbolizer_ms;
// Stops on start until __tsan_resume() is called (for debugging).
bool stop_on_start;
// Controls whether RunningOnValgrind() returns true or false.
Modified: compiler-rt/trunk/lib/tsan/rtl/tsan_rtl.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/tsan/rtl/tsan_rtl.cc?rev=177638&r1=177637&r2=177638&view=diff
==============================================================================
--- compiler-rt/trunk/lib/tsan/rtl/tsan_rtl.cc (original)
+++ compiler-rt/trunk/lib/tsan/rtl/tsan_rtl.cc Thu Mar 21 08:01:50 2013
@@ -111,6 +111,7 @@ static void MemoryProfiler(Context *ctx,
static void BackgroundThread(void *arg) {
ScopedInRtl in_rtl;
Context *ctx = CTX();
+ const u64 kMs2Ns = 1000 * 1000;
fd_t mprof_fd = kInvalidFd;
if (flags()->profile_memory && flags()->profile_memory[0]) {
@@ -131,7 +132,7 @@ static void BackgroundThread(void *arg)
// Flush memory if requested.
if (flags()->flush_memory_ms) {
- if (last_flush + flags()->flush_memory_ms * 1000*1000 > now) {
+ if (last_flush + flags()->flush_memory_ms * kMs2Ns < now) {
FlushShadowMemory();
last_flush = NanoTime();
}
@@ -142,12 +143,15 @@ static void BackgroundThread(void *arg)
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);
+ // Flush symbolizer cache if requested.
+ if (flags()->flush_symbolizer_ms > 0) {
+ u64 last = atomic_load(&ctx->last_symbolize_time_ns,
+ memory_order_relaxed);
+ if (last != 0 && last + flags()->flush_symbolizer_ms * kMs2Ns < now) {
+ Lock l(&ctx->report_mtx);
+ SymbolizeFlush();
+ atomic_store(&ctx->last_symbolize_time_ns, 0, memory_order_relaxed);
+ }
}
#endif
}
More information about the llvm-commits
mailing list