Skip to content

[NFC][sanitizer] Rename to Lock{Before,After}Fork StackDepotBase locking #76303

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions compiler-rt/lib/dfsan/dfsan_chained_origin_depot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ static ChainedOriginDepot chainedOriginDepot;

ChainedOriginDepot* GetChainedOriginDepot() { return &chainedOriginDepot; }

void ChainedOriginDepotLockBeforeFork() { chainedOriginDepot.LockAll(); }
void ChainedOriginDepotLockBeforeFork() { chainedOriginDepot.LockBeforeFork(); }

void ChainedOriginDepotUnlockAfterFork(bool fork_child) {
chainedOriginDepot.UnlockAll();
chainedOriginDepot.UnlockAfterFork(fork_child);
}

} // namespace __dfsan
4 changes: 2 additions & 2 deletions compiler-rt/lib/msan/msan_chained_origin_depot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ u32 ChainedOriginDepotGet(u32 id, u32 *other) {
return chainedOriginDepot.Get(id, other);
}

void ChainedOriginDepotBeforeFork() { chainedOriginDepot.LockAll(); }
void ChainedOriginDepotBeforeFork() { chainedOriginDepot.LockBeforeFork(); }

void ChainedOriginDepotAfterFork(bool fork_child) {
chainedOriginDepot.UnlockAll();
chainedOriginDepot.UnlockAfterFork(fork_child);
}

} // namespace __msan
Original file line number Diff line number Diff line change
Expand Up @@ -139,9 +139,11 @@ u32 ChainedOriginDepot::Get(u32 id, u32 *other) {
return desc.here_id;
}

void ChainedOriginDepot::LockAll() { depot.LockAll(); }
void ChainedOriginDepot::LockBeforeFork() { depot.LockBeforeFork(); }

void ChainedOriginDepot::UnlockAll() { depot.UnlockAll(); }
void ChainedOriginDepot::UnlockAfterFork(bool fork_child) {
depot.UnlockAfterFork(fork_child);
}

void ChainedOriginDepot::TestOnlyUnmap() { depot.TestOnlyUnmap(); }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ class ChainedOriginDepot {
// Retrieves the stored StackDepot ID for the given origin ID.
u32 Get(u32 id, u32 *other);

void LockAll();
void UnlockAll();
void LockBeforeFork();
void UnlockAfterFork(bool fork_child);
void TestOnlyUnmap();

private:
Expand Down
4 changes: 2 additions & 2 deletions compiler-rt/lib/sanitizer_common/sanitizer_stackdepot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -216,15 +216,15 @@ StackTrace StackDepotGet(u32 id) {
}

void StackDepotLockBeforeFork() {
theDepot.LockAll();
theDepot.LockBeforeFork();
compress_thread.LockAndStop();
stackStore.LockAll();
}

void StackDepotUnlockAfterFork(bool fork_child) {
stackStore.UnlockAll();
compress_thread.Unlock();
theDepot.UnlockAll();
theDepot.UnlockAfterFork(fork_child);
}

void StackDepotPrintAll() {
Expand Down
9 changes: 5 additions & 4 deletions compiler-rt/lib/sanitizer_common/sanitizer_stackdepotbase.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ class StackDepotBase {
};
}

void LockAll();
void UnlockAll();
void LockBeforeFork();
void UnlockAfterFork(bool fork_child);
void PrintAll();

void TestOnlyUnmap() {
Expand Down Expand Up @@ -160,14 +160,15 @@ StackDepotBase<Node, kReservedBits, kTabSizeLog>::Get(u32 id) {
}

template <class Node, int kReservedBits, int kTabSizeLog>
void StackDepotBase<Node, kReservedBits, kTabSizeLog>::LockAll() {
void StackDepotBase<Node, kReservedBits, kTabSizeLog>::LockBeforeFork() {
for (int i = 0; i < kTabSize; ++i) {
lock(&tab[i]);
}
}

template <class Node, int kReservedBits, int kTabSizeLog>
void StackDepotBase<Node, kReservedBits, kTabSizeLog>::UnlockAll() {
void StackDepotBase<Node, kReservedBits, kTabSizeLog>::UnlockAfterFork(
bool fork_child) {
for (int i = 0; i < kTabSize; ++i) {
atomic_uint32_t *p = &tab[i];
uptr s = atomic_load(p, memory_order_relaxed);
Expand Down