mirror of
https://github.com/reactos/reactos.git
synced 2024-12-28 10:04:49 +00:00
[NTOS:MM] In page zeroing thread, zero more than one page at a time.
This commit is contained in:
parent
e98de5ef1f
commit
98e62b9bca
1 changed files with 47 additions and 30 deletions
|
@ -38,10 +38,6 @@ MmZeroPageThread(VOID)
|
|||
PKTHREAD Thread = KeGetCurrentThread();
|
||||
PVOID StartAddress, EndAddress;
|
||||
PVOID WaitObjects[2];
|
||||
KIRQL OldIrql;
|
||||
PVOID ZeroAddress;
|
||||
PFN_NUMBER PageIndex, FreePage;
|
||||
PMMPFN Pfn1;
|
||||
|
||||
/* Get the discardable sections to free them */
|
||||
MiFindInitializationCode(&StartAddress, &EndAddress);
|
||||
|
@ -58,6 +54,8 @@ MmZeroPageThread(VOID)
|
|||
|
||||
while (TRUE)
|
||||
{
|
||||
KIRQL OldIrql;
|
||||
|
||||
KeWaitForMultipleObjects(1, // 2
|
||||
WaitObjects,
|
||||
WaitAny,
|
||||
|
@ -70,16 +68,20 @@ MmZeroPageThread(VOID)
|
|||
|
||||
while (TRUE)
|
||||
{
|
||||
if (!MmFreePageListHead.Total)
|
||||
ULONG PageCount = 0;
|
||||
PMMPFN Pfn1 = (PMMPFN)LIST_HEAD;
|
||||
PVOID ZeroAddress;
|
||||
PFN_NUMBER PageIndex, FreePage;
|
||||
|
||||
while (PageCount < MI_ZERO_PTES)
|
||||
{
|
||||
KeClearEvent(&MmZeroingPageEvent);
|
||||
MiReleasePfnLock(OldIrql);
|
||||
PMMPFN Pfn2;
|
||||
|
||||
if (!MmFreePageListHead.Total)
|
||||
break;
|
||||
}
|
||||
|
||||
PageIndex = MmFreePageListHead.Flink;
|
||||
ASSERT(PageIndex != LIST_HEAD);
|
||||
Pfn1 = MiGetPfnEntry(PageIndex);
|
||||
MI_SET_USAGE(MI_USAGE_ZERO_LOOP);
|
||||
MI_SET_PROCESS2("Kernel 0 Loop");
|
||||
FreePage = MiRemoveAnyPage(MI_GET_PAGE_COLOR(PageIndex));
|
||||
|
@ -94,19 +96,34 @@ MmZeroPageThread(VOID)
|
|||
0);
|
||||
}
|
||||
|
||||
Pfn1->u1.Flink = LIST_HEAD;
|
||||
Pfn2 = MiGetPfnEntry(PageIndex);
|
||||
Pfn2->u1.Flink = (PFN_NUMBER)Pfn1;
|
||||
Pfn1 = Pfn2;
|
||||
PageCount++;
|
||||
}
|
||||
MiReleasePfnLock(OldIrql);
|
||||
|
||||
ZeroAddress = MiMapPagesInZeroSpace(Pfn1, 1);
|
||||
if (PageCount == 0)
|
||||
{
|
||||
KeClearEvent(&MmZeroingPageEvent);
|
||||
break;
|
||||
}
|
||||
|
||||
ZeroAddress = MiMapPagesInZeroSpace(Pfn1, PageCount);
|
||||
ASSERT(ZeroAddress);
|
||||
KeZeroPages(ZeroAddress, PAGE_SIZE);
|
||||
MiUnmapPagesInZeroSpace(ZeroAddress, 1);
|
||||
KeZeroPages(ZeroAddress, PageCount * PAGE_SIZE);
|
||||
MiUnmapPagesInZeroSpace(ZeroAddress, PageCount);
|
||||
|
||||
OldIrql = MiAcquirePfnLock();
|
||||
|
||||
while (Pfn1 != (PMMPFN)LIST_HEAD)
|
||||
{
|
||||
PageIndex = MiGetPfnEntryIndex(Pfn1);
|
||||
Pfn1 = (PMMPFN)Pfn1->u1.Flink;
|
||||
MiInsertPageInList(&MmZeroedPageListHead, PageIndex);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* EOF */
|
||||
|
|
Loading…
Reference in a new issue