[compiler-rt] r177629 - tsan: flush symbolizer cache if not symbolized for more than 5 seconds
Dmitry Vyukov
dvyukov at google.com
Thu Mar 21 06:03:00 PDT 2013
Thanks!
Done r177638.
On Thu, Mar 21, 2013 at 4:04 PM, Alexander Potapenko <glider at google.com> wrote:
> I suggest to make the constant changeable from the command line (and
> perhaps include the option to disable this behavior). You know that
> better than me that hardcoded constants are evil :)
> I also suggest to make 1000 * 1000 a constant (e.g. kMillisecondsInSecond).
> Also, please put spaces around the "*" operator.
>
> On Thu, Mar 21, 2013 at 11:02 AM, Dmitry Vyukov <dvyukov at google.com> wrote:
>> Author: dvyukov
>> Date: Thu Mar 21 02:02:36 2013
>> New Revision: 177629
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=177629&view=rev
>> Log:
>> tsan: flush symbolizer cache if not symbolized for more than 5 seconds
>>
>>
>> Modified:
>> compiler-rt/trunk/lib/tsan/rtl/tsan_rtl.cc
>> compiler-rt/trunk/lib/tsan/rtl/tsan_rtl.h
>> compiler-rt/trunk/lib/tsan/rtl/tsan_rtl_report.cc
>>
>> 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=177629&r1=177628&r2=177629&view=diff
>> ==============================================================================
>> --- compiler-rt/trunk/lib/tsan/rtl/tsan_rtl.cc (original)
>> +++ compiler-rt/trunk/lib/tsan/rtl/tsan_rtl.cc Thu Mar 21 02:02:36 2013
>> @@ -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, i
>> , 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 f
>>
>> 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
>> }
>> }
>>
>>
>> Modified: compiler-rt/trunk/lib/tsan/rtl/tsan_rtl.h
>> URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/tsan/rtl/tsan_rtl.h?rev=177629&r1=177628&r2=177629&view=diff
>> ==============================================================================
>> --- compiler-rt/trunk/lib/tsan/rtl/tsan_rtl.h (original)
>> +++ compiler-rt/trunk/lib/tsan/rtl/tsan_rtl.h Thu Mar 21 02:02:36 2013
>> @@ -516,6 +516,7 @@ struct Context {
>> Mutex report_mtx;
>> int nreported;
>> int nmissed_expected;
>> + atomic_uint64_t last_symbolize_time_ns;
>>
>> ThreadRegistry *thread_registry;
>>
>>
>> Modified: compiler-rt/trunk/lib/tsan/rtl/tsan_rtl_report.cc
>> URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/tsan/rtl/tsan_rtl_report.cc?rev=177629&r1=177628&r2=177629&view=diff
>> ==============================================================================
>> --- compiler-rt/trunk/lib/tsan/rtl/tsan_rtl_report.cc (original)
>> +++ compiler-rt/trunk/lib/tsan/rtl/tsan_rtl_report.cc Thu Mar 21 02:02:36 2013
>> @@ -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)
>>
>>
>> _______________________________________________
>> llvm-commits mailing list
>> llvm-commits at cs.uiuc.edu
>> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>
>
>
> --
> Alexander Potapenko
> Software Engineer
> Google Moscow
More information about the llvm-commits
mailing list