Commit 628a42d7 authored by Wez's avatar Wez Committed by Commit Bot

[Fuchsia] Implement de-commit and discard for PageAllocator.

Some allocators (e.g. the Blink heap) call DecommitSystemPages() to
return pages in their free memory pools to the system, or
DiscardSystemPages() to make the pages available to the kernel
without necessarily de-committing them, rather than
actually freeing them.

At present Fuchsia does not implement page swapping, nor does it
provide a "mark discardable" API, so we implement both APIs using
vmar_op_range(DECOMMIT) for now.

Bug: 927411, 1022062
Change-Id: Icc61e7b46ebdc4d3fa5308e1b318a7685a6ceb19
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1892295Reviewed-by: default avatarAlbert J. Wong <ajwong@chromium.org>
Reviewed-by: default avatarChris Palmer <palmer@chromium.org>
Commit-Queue: Wez <wez@chromium.org>
Auto-Submit: Wez <wez@chromium.org>
Cr-Commit-Position: refs/heads/master@{#713238}
parent 446f2f6e
...@@ -169,8 +169,21 @@ void FreePagesInternal(void* address, size_t length) { ...@@ -169,8 +169,21 @@ void FreePagesInternal(void* address, size_t length) {
ZX_CHECK(status == ZX_OK, status); ZX_CHECK(status == ZX_OK, status);
} }
void DiscardSystemPagesInternal(void* address, size_t length) {
// TODO(https://crbug.com/1022062): Mark pages as discardable, rather than
// forcibly de-committing them immediately, when Fuchsia supports it.
uint64_t address_int = reinterpret_cast<uint64_t>(address);
zx_status_t status = zx::vmar::root_self()->op_range(
ZX_VMO_OP_DECOMMIT, address_int, length, nullptr, 0);
ZX_CHECK(status == ZX_OK, status);
}
void DecommitSystemPagesInternal(void* address, size_t length) { void DecommitSystemPagesInternal(void* address, size_t length) {
DiscardSystemPages(address, length); // TODO(https://crbug.com/1022062): Review whether this implementation is
// still appropriate once DiscardSystemPagesInternal() migrates to a "lazy"
// discardable API.
DiscardSystemPagesInternal(address, length);
SetSystemPagesAccessInternal(address, length, PageInaccessible); SetSystemPagesAccessInternal(address, length, PageInaccessible);
} }
...@@ -181,10 +194,6 @@ bool RecommitSystemPagesInternal(void* address, ...@@ -181,10 +194,6 @@ bool RecommitSystemPagesInternal(void* address,
return true; return true;
} }
void DiscardSystemPagesInternal(void* address, size_t length) {
NOTIMPLEMENTED_LOG_ONCE();
}
} // namespace base } // namespace base
#endif // BASE_ALLOCATOR_PARTITION_ALLOCATOR_PAGE_ALLOCATOR_INTERNALS_FUCHSIA_H_ #endif // BASE_ALLOCATOR_PARTITION_ALLOCATOR_PAGE_ALLOCATOR_INTERNALS_FUCHSIA_H_
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