Removing dirty page table hack.

This commit is contained in:
Ben Vanik
2014-12-19 17:29:27 -08:00
parent 71fab4bbb7
commit 756cfbb484
11 changed files with 5 additions and 113 deletions

View File

@@ -76,7 +76,7 @@ public:
}
virtual bool Equals(const void* info_ptr, size_t info_length) = 0;
bool is_dirty() const { return dirtied_; }
bool is_dirty() const { return true; }
void MarkDirty(uint32_t lo_address, uint32_t hi_address);
protected:

View File

@@ -114,60 +114,7 @@ uint64_t ResourceCache::HashRange(const MemoryRange& memory_range) {
void ResourceCache::SyncRange(uint32_t address, int length) {
SCOPE_profile_cpu_f("gpu");
// Scan the page table in sync with our resource list. This means
// we have O(n) complexity for updates, though we could definitely
// make this faster/cleaner.
// TODO(benvanik): actually do this right.
// For now we assume the page table in the range of our resources
// will not be changing, which allows us to do a foreach(res) and reload
// and then clear the table.
// total bytes = (512 * 1024 * 1024) / (16 * 1024) = 32768
// each byte = 1 page
// Walk as qwords so we can clear things up faster.
uint64_t* page_table = reinterpret_cast<uint64_t*>(
memory_->Translate(memory_->page_table()));
uint32_t page_size = 16 * 1024; // 16KB pages
uint32_t lo_address = address % 0x20000000;
uint32_t hi_address = lo_address + length;
hi_address = (hi_address / page_size) * page_size + page_size;
int start_page = lo_address / page_size;
int end_page = hi_address / page_size;
{
SCOPE_profile_cpu_i("gpu", "SyncRange:mark");
auto it = lo_address > page_size ?
paged_resources_.upper_bound(lo_address - page_size) :
paged_resources_.begin();
auto end_it = paged_resources_.lower_bound(hi_address + page_size);
while (it != end_it) {
const auto& memory_range = it->second->memory_range();
int lo_page = (memory_range.guest_base % 0x20000000) / page_size;
int hi_page = lo_page + (memory_range.length / page_size);
lo_page = std::max(lo_page, start_page);
hi_page = std::min(hi_page, end_page);
if (lo_page > hi_page) {
++it;
continue;
}
for (int i = lo_page / 8; i <= hi_page / 8; ++i) {
uint64_t page_flags = page_table[i];
if (page_flags) {
// Dirty!
it->second->MarkDirty(i * 8 * page_size, (i * 8 + 7) * page_size);
}
}
++it;
}
}
// Reset page table.
{
SCOPE_profile_cpu_i("gpu", "SyncRange:reset");
for (auto i = start_page / 8; i <= end_page / 8; ++i) {
page_table[i] = 0;
}
}
// TODO(benvanik): something interesting?
//uint32_t lo_address = address % 0x20000000;
//uint32_t hi_address = lo_address + length;
}

View File

@@ -114,8 +114,7 @@ class xe::MemoryHeap {
};
uint32_t MemoryHeap::next_heap_id_ = 1;
Memory::Memory()
: alloy::Memory(), mapping_(0), mapping_base_(0), page_table_(0) {
Memory::Memory() : mapping_(0), mapping_base_(nullptr) {
virtual_heap_ = new MemoryHeap(this, false);
physical_heap_ = new MemoryHeap(this, true);
}
@@ -202,12 +201,6 @@ int Memory::Initialize() {
return 1;
}
// Allocate dirty page table.
// This must live within our low heap. Ideally we'd hardcode the address but
// this is more flexible.
page_table_ = physical_heap_->Alloc(0, (512 * 1024 * 1024) / (16 * 1024),
X_MEM_COMMIT, 16 * 1024);
return 0;
}

View File

@@ -49,9 +49,6 @@ class Memory : public alloy::Memory {
int Initialize() override;
// TODO(benvanik): remove with GPU refactor.
uint64_t page_table() const override { return page_table_; }
bool AddMappedRange(uint64_t address, uint64_t mask, uint64_t size,
void* context, cpu::MMIOReadCallback read_callback,
cpu::MMIOWriteCallback write_callback);
@@ -102,8 +99,6 @@ class Memory : public alloy::Memory {
MemoryHeap* virtual_heap_;
MemoryHeap* physical_heap_;
uint64_t page_table_;
friend class MemoryHeap;
};