Merge pull request #12358 from liamwhite/optimized-alloc
common: use memory holepunching when clearing memory
This commit is contained in:
commit
fde8dc1652
4 changed files with 42 additions and 17 deletions
|
@ -421,8 +421,9 @@ Result KMemoryManager::AllocateForProcess(KPageGroup* out, size_t num_pages, u32
|
|||
} else {
|
||||
// Set all the allocated memory.
|
||||
for (const auto& block : *out) {
|
||||
std::memset(m_system.DeviceMemory().GetPointer<void>(block.GetAddress()), fill_pattern,
|
||||
block.GetSize());
|
||||
m_system.DeviceMemory().buffer.ClearBackingRegion(GetInteger(block.GetAddress()) -
|
||||
Core::DramMemoryMap::Base,
|
||||
block.GetSize(), fill_pattern);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -81,6 +81,11 @@ void InvalidateInstructionCache(KernelCore& kernel, AddressType addr, u64 size)
|
|||
}
|
||||
}
|
||||
|
||||
void ClearBackingRegion(Core::System& system, KPhysicalAddress addr, u64 size, u32 fill_value) {
|
||||
system.DeviceMemory().buffer.ClearBackingRegion(GetInteger(addr) - Core::DramMemoryMap::Base,
|
||||
size, fill_value);
|
||||
}
|
||||
|
||||
template <typename AddressType>
|
||||
Result InvalidateDataCache(AddressType addr, u64 size) {
|
||||
R_SUCCEED();
|
||||
|
@ -1363,8 +1368,7 @@ Result KPageTableBase::MapInsecureMemory(KProcessAddress address, size_t size) {
|
|||
|
||||
// Clear all the newly allocated pages.
|
||||
for (const auto& it : pg) {
|
||||
std::memset(GetHeapVirtualPointer(m_kernel, it.GetAddress()),
|
||||
static_cast<u32>(m_heap_fill_value), it.GetSize());
|
||||
ClearBackingRegion(m_system, it.GetAddress(), it.GetSize(), m_heap_fill_value);
|
||||
}
|
||||
|
||||
// Lock the table.
|
||||
|
@ -1570,8 +1574,7 @@ Result KPageTableBase::AllocateAndMapPagesImpl(PageLinkedList* page_list, KProce
|
|||
|
||||
// Clear all pages.
|
||||
for (const auto& it : pg) {
|
||||
std::memset(GetHeapVirtualPointer(m_kernel, it.GetAddress()),
|
||||
static_cast<u32>(m_heap_fill_value), it.GetSize());
|
||||
ClearBackingRegion(m_system, it.GetAddress(), it.GetSize(), m_heap_fill_value);
|
||||
}
|
||||
|
||||
// Map the pages.
|
||||
|
@ -2159,8 +2162,7 @@ Result KPageTableBase::SetHeapSize(KProcessAddress* out, size_t size) {
|
|||
|
||||
// Clear all the newly allocated pages.
|
||||
for (const auto& it : pg) {
|
||||
std::memset(GetHeapVirtualPointer(m_kernel, it.GetAddress()), m_heap_fill_value,
|
||||
it.GetSize());
|
||||
ClearBackingRegion(m_system, it.GetAddress(), it.GetSize(), m_heap_fill_value);
|
||||
}
|
||||
|
||||
// Map the pages.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue