Commit 345e4747 authored by Michael Lippautz's avatar Michael Lippautz Committed by Commit Bot

PCScan: Move bitmap committing into PCScan initialization

Scan should know what it needs for book keeping.

Bug: 11297512
Change-Id: Ie73d362a9632f5b5eb365c0ce1fba72c62887f44
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2541864Reviewed-by: default avatarBartek Nowierski <bartekn@chromium.org>
Reviewed-by: default avatarKentaro Hara <haraken@chromium.org>
Commit-Queue: Michael Lippautz <mlippautz@chromium.org>
Cr-Commit-Position: refs/heads/master@{#828108}
parent 842373f4
...@@ -303,27 +303,11 @@ struct BASE_EXPORT PartitionRoot { ...@@ -303,27 +303,11 @@ struct BASE_EXPORT PartitionRoot {
void EnablePCScan() { void EnablePCScan() {
PA_CHECK(scannable && !pcscan.has_value()); PA_CHECK(scannable && !pcscan.has_value());
// Setting |pcscan| and committing bitmaps has to be done under the lock to
{ // avoid racing with PartitionBucket::AllocNewSlotSpan and avoid racing on
// Setting |pcscan| and committing bitmaps has to be done under the lock // |pcscan| ifself during free calls.
// to avoid racing with PartitionBucket::AllocNewSlotSpan. internal::ScopedGuard<thread_safe> guard{lock_};
internal::ScopedGuard<thread_safe> guard{lock_}; pcscan.emplace(this);
size_t quarantine_bitmaps_size_to_commit =
internal::CommittedQuarantineBitmapsSize();
for (auto* super_page_extent = first_extent; super_page_extent;
super_page_extent = super_page_extent->next) {
for (char* super_page = super_page_extent->super_page_base;
super_page != super_page_extent->super_pages_end;
super_page += kSuperPageSize) {
SetSystemPagesAccess(internal::SuperPageQuarantineBitmaps(super_page),
quarantine_bitmaps_size_to_commit,
PageReadWrite);
}
}
pcscan.emplace(this);
}
} }
static PAGE_ALLOCATOR_CONSTANTS_DECLARE_CONSTEXPR ALWAYS_INLINE size_t static PAGE_ALLOCATOR_CONSTANTS_DECLARE_CONSTEXPR ALWAYS_INLINE size_t
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
#include <atomic> #include <atomic>
#include "base/allocator/partition_allocator/object_bitmap.h" #include "base/allocator/partition_allocator/object_bitmap.h"
#include "base/allocator/partition_allocator/page_allocator.h"
#include "base/allocator/partition_allocator/partition_alloc_forward.h" #include "base/allocator/partition_allocator/partition_alloc_forward.h"
#include "base/allocator/partition_allocator/partition_direct_map_extent.h" #include "base/allocator/partition_allocator/partition_direct_map_extent.h"
#include "base/allocator/partition_allocator/partition_page.h" #include "base/allocator/partition_allocator/partition_page.h"
...@@ -38,7 +39,7 @@ class BASE_EXPORT PCScan final { ...@@ -38,7 +39,7 @@ class BASE_EXPORT PCScan final {
using Root = PartitionRoot<thread_safe>; using Root = PartitionRoot<thread_safe>;
using SlotSpan = SlotSpanMetadata<thread_safe>; using SlotSpan = SlotSpanMetadata<thread_safe>;
explicit PCScan(Root* root) : root_(root) {} explicit PCScan(Root* root);
PCScan(const PCScan&) = delete; PCScan(const PCScan&) = delete;
PCScan& operator=(const PCScan&) = delete; PCScan& operator=(const PCScan&) = delete;
...@@ -85,6 +86,22 @@ class BASE_EXPORT PCScan final { ...@@ -85,6 +86,22 @@ class BASE_EXPORT PCScan final {
template <bool thread_safe> template <bool thread_safe>
constexpr size_t PCScan<thread_safe>::QuarantineData::kQuarantineSizeMinLimit; constexpr size_t PCScan<thread_safe>::QuarantineData::kQuarantineSizeMinLimit;
template <bool thread_safe>
PCScan<thread_safe>::PCScan(Root* root) : root_(root) {
root->lock_.AssertAcquired();
// Commit quarantine bitmaps.
size_t quarantine_bitmaps_size_to_commit = CommittedQuarantineBitmapsSize();
for (auto* super_page_extent = root->first_extent; super_page_extent;
super_page_extent = super_page_extent->next) {
for (char* super_page = super_page_extent->super_page_base;
super_page != super_page_extent->super_pages_end;
super_page += kSuperPageSize) {
SetSystemPagesAccess(internal::SuperPageQuarantineBitmaps(super_page),
quarantine_bitmaps_size_to_commit, PageReadWrite);
}
}
}
template <bool thread_safe> template <bool thread_safe>
bool PCScan<thread_safe>::QuarantineData::Account(size_t size) { bool PCScan<thread_safe>::QuarantineData::Account(size_t size) {
size_t size_before = current_size_.fetch_add(size, std::memory_order_relaxed); size_t size_before = current_size_.fetch_add(size, std::memory_order_relaxed);
......
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