mirror of
https://github.com/reactos/reactos.git
synced 2025-08-02 12:55:43 +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 KEVENT MiBalancerEvent;
|
||||||
static KTIMER MiBalancerTimer;
|
static KTIMER MiBalancerTimer;
|
||||||
|
|
||||||
|
static LONG PageOutThreadActive;
|
||||||
|
|
||||||
/* FUNCTIONS ****************************************************************/
|
/* FUNCTIONS ****************************************************************/
|
||||||
|
|
||||||
CODE_SEG("INIT")
|
CODE_SEG("INIT")
|
||||||
|
@ -102,19 +104,16 @@ MiTrimMemoryConsumer(ULONG Consumer, ULONG InitialTarget)
|
||||||
return 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)
|
if (MmAvailablePages < MiMinimumAvailablePages)
|
||||||
{
|
{
|
||||||
/* Global page limit exceeded */
|
/* Global page limit exceeded */
|
||||||
Target = (ULONG)max(Target, MiMinimumAvailablePages - MmAvailablePages);
|
Target = (ULONG)max(Target, MiMinimumAvailablePages - MmAvailablePages);
|
||||||
}
|
}
|
||||||
|
else if (MiMemoryConsumers[Consumer].PagesUsed > MiMemoryConsumers[Consumer].PagesTarget)
|
||||||
/* Don't be too greedy in one run */
|
{
|
||||||
Target = min(Target, 256);
|
/* Consumer page limit exceeded */
|
||||||
|
Target = max(Target, MiMemoryConsumers[Consumer].PagesUsed - MiMemoryConsumers[Consumer].PagesTarget);
|
||||||
|
}
|
||||||
|
|
||||||
if (Target)
|
if (Target)
|
||||||
{
|
{
|
||||||
|
@ -265,8 +264,7 @@ VOID
|
||||||
NTAPI
|
NTAPI
|
||||||
MmRebalanceMemoryConsumers(VOID)
|
MmRebalanceMemoryConsumers(VOID)
|
||||||
{
|
{
|
||||||
if (MiBalancerThreadHandle != NULL &&
|
if (InterlockedCompareExchange(&PageOutThreadActive, 0, 1) == 0)
|
||||||
!MiIsBalancerThread())
|
|
||||||
{
|
{
|
||||||
KeSetEvent(&MiBalancerEvent, IO_NO_INCREMENT, FALSE);
|
KeSetEvent(&MiBalancerEvent, IO_NO_INCREMENT, FALSE);
|
||||||
}
|
}
|
||||||
|
@ -366,6 +364,9 @@ MiBalancerThread(PVOID Unused)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
while (InitialTarget != 0);
|
while (InitialTarget != 0);
|
||||||
|
|
||||||
|
if (Status == STATUS_WAIT_0)
|
||||||
|
InterlockedDecrement(&PageOutThreadActive);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -68,16 +68,6 @@ GetEntry:
|
||||||
while (entry && RMAP_IS_SEGMENT(entry->Address))
|
while (entry && RMAP_IS_SEGMENT(entry->Address))
|
||||||
entry = entry->Next;
|
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)
|
if (entry == NULL)
|
||||||
{
|
{
|
||||||
MiReleasePfnLock(OldIrql);
|
MiReleasePfnLock(OldIrql);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue