forked from OSchip/llvm-project
tsan: add flag to control symbolizer flush frequency
llvm-svn: 177638
This commit is contained in:
parent
69c323d66f
commit
2c3b919ad3
|
@ -55,6 +55,7 @@ void InitializeFlags(Flags *f, const char *env) {
|
|||
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 char *env) {
|
|||
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");
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -111,6 +111,7 @@ static void MemoryProfiler(Context *ctx, fd_t fd, int i) {
|
|||
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
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue