Skip to content

Commit 4f02556

Browse files
author
git apple-llvm automerger
committed
Merge commit '36e6a259c8fc' from llvm.org/main into next
2 parents b6d9377 + 36e6a25 commit 4f02556

File tree

9 files changed

+16
-47
lines changed

9 files changed

+16
-47
lines changed

compiler-rt/lib/asan/asan_allocator.cpp

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,6 @@ struct Allocator {
305305
QuarantineCache fallback_quarantine_cache;
306306

307307
uptr max_user_defined_malloc_size;
308-
atomic_uint8_t rss_limit_exceeded;
309308

310309
// ------------------- Options --------------------------
311310
atomic_uint16_t min_redzone;
@@ -345,14 +344,6 @@ struct Allocator {
345344
: kMaxAllowedMallocSize;
346345
}
347346

348-
bool IsRssLimitExceeded() {
349-
return atomic_load(&rss_limit_exceeded, memory_order_relaxed);
350-
}
351-
352-
void SetRssLimitExceeded(bool limit_exceeded) {
353-
atomic_store(&rss_limit_exceeded, limit_exceeded, memory_order_relaxed);
354-
}
355-
356347
void RePoisonChunk(uptr chunk) {
357348
// This could be a user-facing chunk (with redzones), or some internal
358349
// housekeeping chunk, like TransferBatch. Start by assuming the former.
@@ -1071,10 +1062,6 @@ void asan_mz_force_unlock() NO_THREAD_SAFETY_ANALYSIS {
10711062
instance.ForceUnlock();
10721063
}
10731064

1074-
void AsanSoftRssLimitExceededCallback(bool limit_exceeded) {
1075-
instance.SetRssLimitExceeded(limit_exceeded);
1076-
}
1077-
10781065
} // namespace __asan
10791066

10801067
// --- Implementation of LSan-specific functions --- {{{1

compiler-rt/lib/asan/asan_rtl.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -450,8 +450,6 @@ static void AsanInitInternal() {
450450
allocator_options.SetFrom(flags(), common_flags());
451451
InitializeAllocator(allocator_options);
452452

453-
SetSoftRssLimitExceededCallback(AsanSoftRssLimitExceededCallback);
454-
455453
// On Linux AsanThread::ThreadStart() calls malloc() that's why asan_inited
456454
// should be set to 1 prior to initializing the threads.
457455
asan_inited = 1;

compiler-rt/lib/memprof/memprof_allocator.cpp

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,6 @@ struct Allocator {
218218
AllocatorCache fallback_allocator_cache;
219219

220220
uptr max_user_defined_malloc_size;
221-
atomic_uint8_t rss_limit_exceeded;
222221

223222
// Holds the mapping of stack ids to MemInfoBlocks.
224223
MIBMapTy MIBMap;
@@ -301,14 +300,6 @@ struct Allocator {
301300
: kMaxAllowedMallocSize;
302301
}
303302

304-
bool IsRssLimitExceeded() {
305-
return atomic_load(&rss_limit_exceeded, memory_order_relaxed);
306-
}
307-
308-
void SetRssLimitExceeded(bool limit_exceeded) {
309-
atomic_store(&rss_limit_exceeded, limit_exceeded, memory_order_relaxed);
310-
}
311-
312303
// -------------------- Allocation/Deallocation routines ---------------
313304
void *Allocate(uptr size, uptr alignment, BufferedStackTrace *stack,
314305
AllocType alloc_type) {
@@ -662,10 +653,6 @@ uptr memprof_malloc_usable_size(const void *ptr, uptr pc, uptr bp) {
662653
return usable_size;
663654
}
664655

665-
void MemprofSoftRssLimitExceededCallback(bool limit_exceeded) {
666-
instance.SetRssLimitExceeded(limit_exceeded);
667-
}
668-
669656
} // namespace __memprof
670657

671658
// ---------------------- Interface ---------------- {{{1

compiler-rt/lib/memprof/memprof_allocator.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,6 @@ int memprof_posix_memalign(void **memptr, uptr alignment, uptr size,
9898
uptr memprof_malloc_usable_size(const void *ptr, uptr pc, uptr bp);
9999

100100
void PrintInternalAllocatorStats();
101-
void MemprofSoftRssLimitExceededCallback(bool exceeded);
102101

103102
} // namespace __memprof
104103
#endif // MEMPROF_ALLOCATOR_H

compiler-rt/lib/memprof/memprof_rtl.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,8 +135,6 @@ void PrintAddressSpaceLayout() {
135135

136136
static bool UNUSED __local_memprof_dyninit = [] {
137137
MaybeStartBackgroudThread();
138-
SetSoftRssLimitExceededCallback(MemprofSoftRssLimitExceededCallback);
139-
140138
return false;
141139
}();
142140

compiler-rt/lib/sanitizer_common/sanitizer_allocator.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,4 +195,14 @@ void PrintHintAllocatorCannotReturnNull() {
195195
"allocator_may_return_null=1\n");
196196
}
197197

198+
static atomic_uint8_t rss_limit_exceeded;
199+
200+
bool IsRssLimitExceeded() {
201+
return atomic_load(&rss_limit_exceeded, memory_order_relaxed);
202+
}
203+
204+
void SetRssLimitExceeded(bool limit_exceeded) {
205+
atomic_store(&rss_limit_exceeded, limit_exceeded, memory_order_relaxed);
206+
}
207+
198208
} // namespace __sanitizer

compiler-rt/lib/sanitizer_common/sanitizer_allocator.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,9 @@ inline void RandomShuffle(T *a, u32 n, u32 *rand_state) {
7070
#include "sanitizer_allocator_secondary.h"
7171
#include "sanitizer_allocator_combined.h"
7272

73+
bool IsRssLimitExceeded();
74+
void SetRssLimitExceeded(bool limit_exceeded);
75+
7376
} // namespace __sanitizer
7477

7578
#endif // SANITIZER_ALLOCATOR_H

compiler-rt/lib/sanitizer_common/sanitizer_common.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -326,12 +326,6 @@ void SetUserDieCallback(DieCallbackType callback);
326326

327327
void SetCheckUnwindCallback(void (*callback)());
328328

329-
// Callback will be called if soft_rss_limit_mb is given and the limit is
330-
// exceeded (exceeded==true) or if rss went down below the limit
331-
// (exceeded==false).
332-
// The callback should be registered once at the tool init time.
333-
void SetSoftRssLimitExceededCallback(void (*Callback)(bool exceeded));
334-
335329
// Functions related to signal handling.
336330
typedef void (*SignalHandlerType)(int, void *, void *);
337331
HandleSignalMode GetHandleSignalMode(int signum);

compiler-rt/lib/sanitizer_common/sanitizer_common_libcdep.cpp

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
// run-time libraries.
1111
//===----------------------------------------------------------------------===//
1212

13+
#include "sanitizer_allocator.h"
1314
#include "sanitizer_allocator_interface.h"
1415
#include "sanitizer_common.h"
1516
#include "sanitizer_flags.h"
@@ -18,12 +19,6 @@
1819

1920
namespace __sanitizer {
2021

21-
static void (*SoftRssLimitExceededCallback)(bool exceeded);
22-
void SetSoftRssLimitExceededCallback(void (*Callback)(bool exceeded)) {
23-
CHECK_EQ(SoftRssLimitExceededCallback, nullptr);
24-
SoftRssLimitExceededCallback = Callback;
25-
}
26-
2722
#if (SANITIZER_LINUX || SANITIZER_NETBSD) && !SANITIZER_GO
2823
// Weak default implementation for when sanitizer_stackdepot is not linked in.
2924
SANITIZER_WEAK_ATTRIBUTE StackDepotStats StackDepotGetStats() { return {}; }
@@ -67,13 +62,11 @@ void *BackgroundThread(void *arg) {
6762
reached_soft_rss_limit = true;
6863
Report("%s: soft rss limit exhausted (%zdMb vs %zdMb)\n",
6964
SanitizerToolName, soft_rss_limit_mb, current_rss_mb);
70-
if (SoftRssLimitExceededCallback)
71-
SoftRssLimitExceededCallback(true);
65+
SetRssLimitExceeded(true);
7266
} else if (soft_rss_limit_mb >= current_rss_mb &&
7367
reached_soft_rss_limit) {
7468
reached_soft_rss_limit = false;
75-
if (SoftRssLimitExceededCallback)
76-
SoftRssLimitExceededCallback(false);
69+
SetRssLimitExceeded(false);
7770
}
7871
}
7972
if (heap_profile &&

0 commit comments

Comments
 (0)