Skip to content

Commit cd2bac8

Browse files
authored
[nfc][tsan] Better name for locking functions (#96598)
These functions used only for `fork`. Unused parameter `child` will be used in followup patches.
1 parent 4c87212 commit cd2bac8

File tree

3 files changed

+10
-9
lines changed

3 files changed

+10
-9
lines changed

compiler-rt/lib/tsan/rtl/tsan_mman.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,12 +115,12 @@ ScopedGlobalProcessor::~ScopedGlobalProcessor() {
115115
gp->mtx.Unlock();
116116
}
117117

118-
void AllocatorLock() SANITIZER_NO_THREAD_SAFETY_ANALYSIS {
118+
void AllocatorLockBeforeFork() SANITIZER_NO_THREAD_SAFETY_ANALYSIS {
119119
global_proc()->internal_alloc_mtx.Lock();
120120
InternalAllocatorLock();
121121
}
122122

123-
void AllocatorUnlock() SANITIZER_NO_THREAD_SAFETY_ANALYSIS {
123+
void AllocatorUnlockAfterFork(bool child) SANITIZER_NO_THREAD_SAFETY_ANALYSIS {
124124
InternalAllocatorUnlock();
125125
global_proc()->internal_alloc_mtx.Unlock();
126126
}

compiler-rt/lib/tsan/rtl/tsan_mman.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ void ReplaceSystemMalloc();
2424
void AllocatorProcStart(Processor *proc);
2525
void AllocatorProcFinish(Processor *proc);
2626
void AllocatorPrintStats();
27-
void AllocatorLock();
28-
void AllocatorUnlock();
27+
void AllocatorLockBeforeFork();
28+
void AllocatorUnlockAfterFork(bool child);
2929
void GlobalProcessorLock();
3030
void GlobalProcessorUnlock();
3131

compiler-rt/lib/tsan/rtl/tsan_rtl.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -815,7 +815,7 @@ void ForkBefore(ThreadState* thr, uptr pc) SANITIZER_NO_THREAD_SAFETY_ANALYSIS {
815815
ctx->thread_registry.Lock();
816816
ctx->slot_mtx.Lock();
817817
ScopedErrorReportLock::Lock();
818-
AllocatorLock();
818+
AllocatorLockBeforeFork();
819819
// Suppress all reports in the pthread_atfork callbacks.
820820
// Reports will deadlock on the report_mtx.
821821
// We could ignore sync operations as well,
@@ -835,11 +835,12 @@ void ForkBefore(ThreadState* thr, uptr pc) SANITIZER_NO_THREAD_SAFETY_ANALYSIS {
835835
# endif
836836
}
837837

838-
static void ForkAfter(ThreadState* thr) SANITIZER_NO_THREAD_SAFETY_ANALYSIS {
838+
static void ForkAfter(ThreadState* thr,
839+
bool child) SANITIZER_NO_THREAD_SAFETY_ANALYSIS {
839840
thr->suppress_reports--; // Enabled in ForkBefore.
840841
thr->ignore_interceptors--;
841842
thr->ignore_reads_and_writes--;
842-
AllocatorUnlock();
843+
AllocatorUnlockAfterFork(child);
843844
ScopedErrorReportLock::Unlock();
844845
ctx->slot_mtx.Unlock();
845846
ctx->thread_registry.Unlock();
@@ -849,10 +850,10 @@ static void ForkAfter(ThreadState* thr) SANITIZER_NO_THREAD_SAFETY_ANALYSIS {
849850
GlobalProcessorUnlock();
850851
}
851852

852-
void ForkParentAfter(ThreadState* thr, uptr pc) { ForkAfter(thr); }
853+
void ForkParentAfter(ThreadState* thr, uptr pc) { ForkAfter(thr, false); }
853854

854855
void ForkChildAfter(ThreadState* thr, uptr pc, bool start_thread) {
855-
ForkAfter(thr);
856+
ForkAfter(thr, true);
856857
u32 nthread = ctx->thread_registry.OnFork(thr->tid);
857858
VPrintf(1,
858859
"ThreadSanitizer: forked new process with pid %d,"

0 commit comments

Comments
 (0)