mirror of
https://github.com/Atmosphere-NX/Atmosphere.git
synced 2024-11-15 03:27:49 +01:00
kern: General system stability improvements to enhance the user's experience.
This commit is contained in:
parent
2ad9927a88
commit
583899ede3
@ -176,6 +176,7 @@ namespace ams::kern {
|
|||||||
NOINLINE void Initialize(KVirtualAddress metadata_region, size_t metadata_region_size);
|
NOINLINE void Initialize(KVirtualAddress metadata_region, size_t metadata_region_size);
|
||||||
|
|
||||||
NOINLINE Result InitializeOptimizedMemory(u64 process_id, Pool pool);
|
NOINLINE Result InitializeOptimizedMemory(u64 process_id, Pool pool);
|
||||||
|
NOINLINE void FinalizeOptimizedMemory(u64 process_id, Pool pool);
|
||||||
|
|
||||||
NOINLINE KVirtualAddress AllocateContinuous(size_t num_pages, size_t align_pages, u32 option);
|
NOINLINE KVirtualAddress AllocateContinuous(size_t num_pages, size_t align_pages, u32 option);
|
||||||
NOINLINE Result Allocate(KPageGroup *out, size_t num_pages, u32 option);
|
NOINLINE Result Allocate(KPageGroup *out, size_t num_pages, u32 option);
|
||||||
|
@ -498,6 +498,7 @@ namespace ams::kern::arch::arm64 {
|
|||||||
const size_t cur_size = std::min(next_entry.block_size - (GetInteger(virt_addr) & (next_entry.block_size - 1)), remaining_pages * PageSize);
|
const size_t cur_size = std::min(next_entry.block_size - (GetInteger(virt_addr) & (next_entry.block_size - 1)), remaining_pages * PageSize);
|
||||||
remaining_pages -= cur_size / PageSize;
|
remaining_pages -= cur_size / PageSize;
|
||||||
virt_addr += cur_size;
|
virt_addr += cur_size;
|
||||||
|
next_valid = impl.ContinueTraversal(std::addressof(next_entry), std::addressof(context));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -106,6 +106,16 @@ namespace ams::kern {
|
|||||||
return ResultSuccess();
|
return ResultSuccess();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void KMemoryManager::FinalizeOptimizedMemory(u64 process_id, Pool pool) {
|
||||||
|
/* Lock the pool. */
|
||||||
|
KScopedLightLock lk(this->pool_locks[pool]);
|
||||||
|
|
||||||
|
/* If the process was optimized, clear it. */
|
||||||
|
if (this->has_optimized_process[pool] && this->optimized_process_ids[pool] == process_id) {
|
||||||
|
this->has_optimized_process[pool] = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
KVirtualAddress KMemoryManager::AllocateContinuous(size_t num_pages, size_t align_pages, u32 option) {
|
KVirtualAddress KMemoryManager::AllocateContinuous(size_t num_pages, size_t align_pages, u32 option) {
|
||||||
/* Early return if we're allocating no pages. */
|
/* Early return if we're allocating no pages. */
|
||||||
|
@ -3419,6 +3419,7 @@ namespace ams::kern {
|
|||||||
bool next_valid;
|
bool next_valid;
|
||||||
size_t tot_size = 0;
|
size_t tot_size = 0;
|
||||||
|
|
||||||
|
cur_address = address;
|
||||||
next_valid = impl.BeginTraversal(std::addressof(next_entry), std::addressof(context), cur_address);
|
next_valid = impl.BeginTraversal(std::addressof(next_entry), std::addressof(context), cur_address);
|
||||||
next_entry.block_size = (next_entry.block_size - (GetInteger(next_entry.phys_addr) & (next_entry.block_size - 1)));
|
next_entry.block_size = (next_entry.block_size - (GetInteger(next_entry.phys_addr) & (next_entry.block_size - 1)));
|
||||||
|
|
||||||
|
@ -105,6 +105,9 @@ namespace ams::kern {
|
|||||||
/* Clear our tracking variables. */
|
/* Clear our tracking variables. */
|
||||||
this->system_resource_address = Null<KVirtualAddress>;
|
this->system_resource_address = Null<KVirtualAddress>;
|
||||||
this->system_resource_num_pages = 0;
|
this->system_resource_num_pages = 0;
|
||||||
|
|
||||||
|
/* Finalize optimized memory. If memory wasn't optimized, this is a no-op. */
|
||||||
|
Kernel::GetMemoryManager().FinalizeOptimizedMemory(this->GetId(), this->memory_pool);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Release memory to the resource limit. */
|
/* Release memory to the resource limit. */
|
||||||
@ -359,7 +362,7 @@ namespace ams::kern {
|
|||||||
MESOSPHERE_ABORT_UNLESS(this->process_id <= ProcessIdMax);
|
MESOSPHERE_ABORT_UNLESS(this->process_id <= ProcessIdMax);
|
||||||
|
|
||||||
/* If we should optimize memory allocations, do so. */
|
/* If we should optimize memory allocations, do so. */
|
||||||
if (this->system_resource_address != Null<KVirtualAddress>) {
|
if (this->system_resource_address != Null<KVirtualAddress> && (params.flags & ams::svc::CreateProcessFlag_OptimizeMemoryAllocation) != 0) {
|
||||||
R_TRY(Kernel::GetMemoryManager().InitializeOptimizedMemory(this->process_id, pool));
|
R_TRY(Kernel::GetMemoryManager().InitializeOptimizedMemory(this->process_id, pool));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user