Commit 6a88b0d8 authored by Wez's avatar Wez Committed by Commit Bot

[Fuchsia] Use ZX_VMO_OP_DECOMMIT to purge discardable shared memory.

Optimize DiscardableSharedMemory::Purge() to discard pages immediately
using the "decommit" operation on the underlying VMO, to avoid discarded
pages remaining resident due to mappings/references to the VMO lingering
in other processes.

Bug: 904482
Change-Id: I96d760e4400a803a53cd85f49e208c28f65b74d4
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1648597
Auto-Submit: Wez <wez@chromium.org>
Reviewed-by: default avatarDavid Reveman <reveman@chromium.org>
Reviewed-by: default avatarDaniel Cheng <dcheng@chromium.org>
Commit-Queue: Daniel Cheng <dcheng@chromium.org>
Commit-Queue: Wez <wez@chromium.org>
Cr-Commit-Position: refs/heads/master@{#667366}
parent 9a8ec8bd
......@@ -32,6 +32,12 @@
#include "base/win/windows_version.h"
#endif
#if defined(OS_FUCHSIA)
#include <lib/zx/vmo.h>
#include <zircon/types.h>
#include "base/fuchsia/fuchsia_logging.h"
#endif
namespace base {
namespace {
......@@ -416,7 +422,13 @@ bool DiscardableSharedMemory::Purge(Time current_time) {
void* ptr = VirtualAlloc(address, length, MEM_RESET, PAGE_READWRITE);
CHECK(ptr);
}
#endif
#elif defined(OS_FUCHSIA)
zx::unowned_vmo vmo = shared_memory_region_.GetPlatformHandle();
zx_status_t status =
vmo->op_range(ZX_VMO_OP_DECOMMIT, AlignToPageSize(sizeof(SharedState)),
AlignToPageSize(mapped_size_), nullptr, 0);
ZX_DCHECK(status == ZX_OK, status) << "zx_vmo_op_range(ZX_VMO_OP_DECOMMIT)";
#endif // defined(OS_FUCHSIA)
last_known_usage_ = Time();
return true;
......
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