mirror of
https://github.com/reactos/reactos.git
synced 2025-02-22 16:36:33 +00:00
[NTOS:MM] More fine-tuning of the memory balancer
This commit is contained in:
parent
41475dfcd7
commit
625f273361
2 changed files with 11 additions and 20 deletions
|
@ -37,6 +37,8 @@ static HANDLE MiBalancerThreadHandle = NULL;
|
|||
static KEVENT MiBalancerEvent;
|
||||
static KTIMER MiBalancerTimer;
|
||||
|
||||
static LONG PageOutThreadActive;
|
||||
|
||||
/* FUNCTIONS ****************************************************************/
|
||||
|
||||
CODE_SEG("INIT")
|
||||
|
@ -102,19 +104,16 @@ MiTrimMemoryConsumer(ULONG Consumer, ULONG InitialTarget)
|
|||
return InitialTarget;
|
||||
}
|
||||
|
||||
if (MiMemoryConsumers[Consumer].PagesUsed > MiMemoryConsumers[Consumer].PagesTarget)
|
||||
{
|
||||
/* Consumer page limit exceeded */
|
||||
Target = max(Target, MiMemoryConsumers[Consumer].PagesUsed - MiMemoryConsumers[Consumer].PagesTarget);
|
||||
}
|
||||
if (MmAvailablePages < MiMinimumAvailablePages)
|
||||
{
|
||||
/* Global page limit exceeded */
|
||||
Target = (ULONG)max(Target, MiMinimumAvailablePages - MmAvailablePages);
|
||||
}
|
||||
|
||||
/* Don't be too greedy in one run */
|
||||
Target = min(Target, 256);
|
||||
else if (MiMemoryConsumers[Consumer].PagesUsed > MiMemoryConsumers[Consumer].PagesTarget)
|
||||
{
|
||||
/* Consumer page limit exceeded */
|
||||
Target = max(Target, MiMemoryConsumers[Consumer].PagesUsed - MiMemoryConsumers[Consumer].PagesTarget);
|
||||
}
|
||||
|
||||
if (Target)
|
||||
{
|
||||
|
@ -265,8 +264,7 @@ VOID
|
|||
NTAPI
|
||||
MmRebalanceMemoryConsumers(VOID)
|
||||
{
|
||||
if (MiBalancerThreadHandle != NULL &&
|
||||
!MiIsBalancerThread())
|
||||
if (InterlockedCompareExchange(&PageOutThreadActive, 0, 1) == 0)
|
||||
{
|
||||
KeSetEvent(&MiBalancerEvent, IO_NO_INCREMENT, FALSE);
|
||||
}
|
||||
|
@ -366,6 +364,9 @@ MiBalancerThread(PVOID Unused)
|
|||
}
|
||||
}
|
||||
while (InitialTarget != 0);
|
||||
|
||||
if (Status == STATUS_WAIT_0)
|
||||
InterlockedDecrement(&PageOutThreadActive);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -68,16 +68,6 @@ GetEntry:
|
|||
while (entry && RMAP_IS_SEGMENT(entry->Address))
|
||||
entry = entry->Next;
|
||||
|
||||
/* See if we are retrying because the page is actively used */
|
||||
while (entry && ((entry->Address < Address) || RMAP_IS_SEGMENT(entry->Address)))
|
||||
entry = entry->Next;
|
||||
|
||||
if (entry && (entry->Address == Address))
|
||||
{
|
||||
while (entry && ((entry->Process <= Process) || RMAP_IS_SEGMENT(entry->Address)))
|
||||
entry = entry->Next;
|
||||
}
|
||||
|
||||
if (entry == NULL)
|
||||
{
|
||||
MiReleasePfnLock(OldIrql);
|
||||
|
|
Loading…
Reference in a new issue