Commit 6ae88d9a authored by Chris Palmer's avatar Chris Palmer Committed by Commit Bot

Enable only 1 `PartitionAllocZeroFill` optimization.

`SlowPathAlloc` has 3 tactics for getting new memory. Of these, only the 1st
(calling `PartitionDirectMap`) seems to most obviously get a fresh, zeroed page
from the OS. I think it is safe to optimize in that branch. It might be safe on
some platforms to optimize in the other 2 branches, but it's less obviously
safe, and we've had trouble on at least macOS. This CL enables the 1st branch
but turns off the optimization in the 2nd 2 branches.

Bug: 890752
Cq-Include-Trybots: luci.chromium.try:mac_optional_gpu_tests_rel
Change-Id: Ibd9ff599ba78aeab47c2369c472af71a4f71d600
Reviewed-on: https://chromium-review.googlesource.com/1256211Reviewed-by: default avatarAlbert J. Wong <ajwong@chromium.org>
Commit-Queue: Chris Palmer <palmer@chromium.org>
Cr-Commit-Position: refs/heads/master@{#596297}
parent d40bd88e
...@@ -478,11 +478,7 @@ void* PartitionBucket::SlowPathAlloc(PartitionRootBase* root, ...@@ -478,11 +478,7 @@ void* PartitionBucket::SlowPathAlloc(PartitionRootBase* root,
PartitionExcessiveAllocationSize(); PartitionExcessiveAllocationSize();
} }
new_page = PartitionDirectMap(root, flags, size); new_page = PartitionDirectMap(root, flags, size);
#if !defined(OS_MACOSX)
// TODO(https://crbug.com/890752): Remove this when we figure out and fix
// whatever is breaking on macOS.
*is_already_zeroed = true; *is_already_zeroed = true;
#endif
} else if (LIKELY(this->SetNewActivePage())) { } else if (LIKELY(this->SetNewActivePage())) {
// First, did we find an active page in the active pages list? // First, did we find an active page in the active pages list?
new_page = this->active_pages_head; new_page = this->active_pages_head;
...@@ -514,11 +510,9 @@ void* PartitionBucket::SlowPathAlloc(PartitionRootBase* root, ...@@ -514,11 +510,9 @@ void* PartitionBucket::SlowPathAlloc(PartitionRootBase* root,
void* addr = PartitionPage::ToPointer(new_page); void* addr = PartitionPage::ToPointer(new_page);
root->RecommitSystemPages(addr, new_page->bucket->get_bytes_per_span()); root->RecommitSystemPages(addr, new_page->bucket->get_bytes_per_span());
new_page->Reset(); new_page->Reset();
#if !defined(OS_MACOSX) // TODO(https://crbug.com/890752): Optimizing here might cause pages to
// TODO(https://crbug.com/890752): Remove this when we figure out and fix // not be zeroed.
// whatever is breaking on macOS. // *is_already_zeroed = true;
*is_already_zeroed = true;
#endif
} }
DCHECK(new_page); DCHECK(new_page);
} else { } else {
...@@ -528,11 +522,9 @@ void* PartitionBucket::SlowPathAlloc(PartitionRootBase* root, ...@@ -528,11 +522,9 @@ void* PartitionBucket::SlowPathAlloc(PartitionRootBase* root,
if (LIKELY(raw_pages != nullptr)) { if (LIKELY(raw_pages != nullptr)) {
new_page = PartitionPage::FromPointerNoAlignmentCheck(raw_pages); new_page = PartitionPage::FromPointerNoAlignmentCheck(raw_pages);
InitializeSlotSpan(new_page); InitializeSlotSpan(new_page);
#if !defined(OS_MACOSX) // TODO(https://crbug.com/890752): Optimizing here causes pages to not be
// TODO(https://crbug.com/890752): Remove this when we figure out and fix // zeroed on at least macOS.
// whatever is breaking on macOS. // *is_already_zeroed = true;
*is_already_zeroed = true;
#endif
} }
} }
......
...@@ -142,11 +142,6 @@ ALWAYS_INLINE void* PartitionRootBase::AllocFromBucket(PartitionBucket* bucket, ...@@ -142,11 +142,6 @@ ALWAYS_INLINE void* PartitionRootBase::AllocFromBucket(PartitionBucket* bucket,
} }
PartitionCookieWriteValue(char_ret + kCookieSize + no_cookie_size); PartitionCookieWriteValue(char_ret + kCookieSize + no_cookie_size);
#else #else
#if defined(OS_MACOSX)
// TODO(https://crbug.com/890752): Remove this when we figure out and fix
// whatever is breaking on macOS.
is_already_zeroed = false;
#endif
if (ret && zero_fill && !is_already_zeroed) { if (ret && zero_fill && !is_already_zeroed) {
memset(ret, 0, size); memset(ret, 0, size);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment