diff --git a/reactos/ntoskrnl/mm/ARM3/pfnlist.c b/reactos/ntoskrnl/mm/ARM3/pfnlist.c index 025aa7cddf4..843adc758f5 100644 --- a/reactos/ntoskrnl/mm/ARM3/pfnlist.c +++ b/reactos/ntoskrnl/mm/ARM3/pfnlist.c @@ -156,8 +156,8 @@ MiInsertZeroListAtBack(IN PFN_NUMBER EntryIndex) /* Update the page location */ Pfn1->u3.e1.PageLocation = ZeroedPageList; - /* FIXME: NOT YET Due to caller semantics: Update the available page count */ - //MmAvailablePages++; + /* Update the available page count */ + MmAvailablePages++; /* Check if we've reached the configured low memory threshold */ if (MmAvailablePages == MmLowMemoryThreshold) diff --git a/reactos/ntoskrnl/mm/freelist.c b/reactos/ntoskrnl/mm/freelist.c index aea3f0e35f8..aae59fb65fb 100644 --- a/reactos/ntoskrnl/mm/freelist.c +++ b/reactos/ntoskrnl/mm/freelist.c @@ -631,8 +631,8 @@ MmZeroPageThreadMain(PVOID Ignored) { NTSTATUS Status; KIRQL oldIrql; - PPHYSICAL_PAGE PageDescriptor; - PFN_NUMBER Pfn; + PMMPFN Pfn1; + PFN_NUMBER PageIndex, FreePage; ULONG Count; PVOID ZeroAddress; @@ -660,21 +660,30 @@ MmZeroPageThreadMain(PVOID Ignored) oldIrql = KeAcquireQueuedSpinLock(LockQueuePfnLock); while (MmFreePageListHead.Total) { - PageDescriptor = MiRemoveHeadList(&MmFreePageListHead); - Pfn = MiGetPfnEntryIndex(PageDescriptor); - KeReleaseQueuedSpinLock(LockQueuePfnLock, oldIrql); - - PageDescriptor->u1.Flink = LIST_HEAD; - ZeroAddress = MiMapPagesToZeroInHyperSpace(PageDescriptor, 1); - ASSERT(ZeroAddress); - RtlZeroMemory(ZeroAddress, PAGE_SIZE); - MiUnmapPagesInZeroSpace(ZeroAddress, 1); - - oldIrql = KeAcquireQueuedSpinLock(LockQueuePfnLock); + PageIndex = MmFreePageListHead.Flink; + Pfn1 = MiGetPfnEntry(PageIndex); + FreePage = MiRemoveAnyPage(0); // FIXME: Use real color + if (FreePage != PageIndex) + { + KeBugCheckEx(PFN_LIST_CORRUPT, + 0x8F, + FreePage, + PageIndex, + 0); + } + + Pfn1->u1.Flink = LIST_HEAD; + KeReleaseQueuedSpinLock(LockQueuePfnLock, oldIrql); + + ZeroAddress = MiMapPagesToZeroInHyperSpace(Pfn1, 1); + ASSERT(ZeroAddress); + RtlZeroMemory(ZeroAddress, PAGE_SIZE); + MiUnmapPagesInZeroSpace(ZeroAddress, 1); + + oldIrql = KeAcquireQueuedSpinLock(LockQueuePfnLock); - MiInsertZeroListAtBack(Pfn); - Count++; - + MiInsertZeroListAtBack(PageIndex); + Count++; } DPRINT("Zeroed %d pages.\n", Count); KeResetEvent(&ZeroPageThreadEvent);