Skip to content

Commit 884d290

Browse files
committed
[sanitizer] Remove SpinMutexLock from stat function
Mapped size is more appropriate for most users. Depends on D111605. Reviewed By: dvyukov Differential Revision: https://reviews.llvm.org/D111607
1 parent b4b9f9b commit 884d290

File tree

2 files changed

+7
-9
lines changed

2 files changed

+7
-9
lines changed

compiler-rt/lib/sanitizer_common/sanitizer_persistent_allocator.h

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,7 @@ template <typename T>
2424
class PersistentAllocator {
2525
public:
2626
T *alloc(uptr count = 1);
27-
uptr allocated() const {
28-
SpinMutexLock l(&mtx);
29-
return atomic_load_relaxed(&mapped_size) +
30-
atomic_load_relaxed(&region_pos) - atomic_load_relaxed(&region_end);
31-
}
27+
uptr allocated() const { return atomic_load_relaxed(&mapped_size); }
3228

3329
private:
3430
T *tryAlloc(uptr count);

compiler-rt/lib/sanitizer_common/tests/sanitizer_chained_origin_depot_test.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,10 +81,12 @@ TEST(SanitizerCommon, ChainedOriginDepotStats) {
8181
EXPECT_EQ(stats2.n_uniq_ids, stats1.n_uniq_ids);
8282
EXPECT_EQ(stats2.allocated, stats1.allocated);
8383

84-
EXPECT_TRUE(chainedOriginDepot.Put(35, 36, &new_id));
85-
StackDepotStats stats3 = chainedOriginDepot.GetStats();
86-
EXPECT_EQ(stats3.n_uniq_ids, stats2.n_uniq_ids + 1);
87-
EXPECT_GT(stats3.allocated, stats2.allocated);
84+
for (int i = 0; i < 100000; ++i) {
85+
ASSERT_TRUE(chainedOriginDepot.Put(35, i, &new_id));
86+
StackDepotStats stats3 = chainedOriginDepot.GetStats();
87+
ASSERT_EQ(stats3.n_uniq_ids, stats2.n_uniq_ids + 1 + i);
88+
}
89+
EXPECT_GT(chainedOriginDepot.GetStats().allocated, stats2.allocated);
8890
}
8991

9092
} // namespace __sanitizer

0 commit comments

Comments
 (0)