Skip to content
Draft
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
16 changes: 15 additions & 1 deletion tcmalloc/page_allocator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,21 @@ PageAllocator::PageAllocator() {
TC_CHECK_LE(part, std::size(choices_));
}

void PageAllocator::ShrinkToUsageLimitSlow(Length n) {
void PageAllocator::ShrinkToUsageLimit(Length n, bool may_have_grown) {
#ifdef TCMALLOC_INTERNAL_LEGACY_LOCKING
const bool check_stats = true;
#else
#ifndef NDEBUG
const bool check_stats = true;
#else
const bool check_stats = may_have_grown;
#endif // NDEBUG
#endif // TCMALLOC_INTERNAL_LEGACY_LOCKING

if (!check_stats) {
return;
}

BackingStats s = stats();
const size_t backed =
s.system_bytes - s.unmapped_bytes + tc_globals.metadata_bytes();
Expand Down
16 changes: 1 addition & 15 deletions tcmalloc/page_allocator.h
Original file line number Diff line number Diff line change
Expand Up @@ -141,19 +141,7 @@ class PageAllocator {
// If we have a usage limit set, ensure we're not violating it from our latest
// allocation.
void ShrinkToUsageLimit(Length n, bool may_have_grown)
ABSL_EXCLUSIVE_LOCKS_REQUIRED(pageheap_lock) {
#if defined(TCMALLOC_INTERNAL_LEGACY_LOCKING) || !defined(NDEBUG)
const bool check_stats = true;
#else
const bool check_stats = may_have_grown;
#endif

if (!check_stats) {
return;
}

ShrinkToUsageLimitSlow(n);
}
ABSL_EXCLUSIVE_LOCKS_REQUIRED(pageheap_lock);

void TreatHugepageTrackers(EnableCollapse enable_collapse)
ABSL_LOCKS_EXCLUDED(pageheap_lock);
Expand Down Expand Up @@ -207,8 +195,6 @@ class PageAllocator {
MemoryTag tag);
static void InvokeReleaseHookSlow(Length num_pages, Length released,
PageReleaseReason reason);
ABSL_ATTRIBUTE_NOINLINE void ShrinkToUsageLimitSlow(Length n)
ABSL_EXCLUSIVE_LOCKS_REQUIRED(pageheap_lock);
bool ShrinkHardBy(Length page, LimitKind limit_kind)
ABSL_EXCLUSIVE_LOCKS_REQUIRED(pageheap_lock);

Expand Down
Loading