diff --git a/reactos/ntoskrnl/cache/section/data.c b/reactos/ntoskrnl/cache/section/data.c index 1f93eec494d..6d2451d03a7 100644 --- a/reactos/ntoskrnl/cache/section/data.c +++ b/reactos/ntoskrnl/cache/section/data.c @@ -143,14 +143,6 @@ MiZeroFillSection MmReferencePage(Page); MmCreateVirtualMapping(NULL, Address, PAGE_READWRITE, &Page, 1); MmInsertRmap(Page, NULL, Address); -#if (_MI_PAGING_LEVELS == 2) - /* Reference Page Directory Entry */ - if(Address < MmSystemRangeStart) - { - MmWorkingSetList->UsedPageTableEntries[MiGetPdeOffset(Address)]++; - ASSERT(MmWorkingSetList->UsedPageTableEntries[MiGetPdeOffset(Address)] <= PTE_COUNT); - } -#endif } else MmReleasePageMemoryConsumer(MC_CACHE, Page); @@ -676,10 +668,6 @@ MmFreeCacheSectionPage MmDeleteRmap(Page, Process, Address); MmDeleteVirtualMapping(Process, Address, FALSE, NULL, NULL); MmReleasePageMemoryConsumer(MC_CACHE, Page); -#if (_MI_PAGING_LEVELS == 2) - if (Address < MmSystemRangeStart) - Process->Vm.VmWorkingSetList->UsedPageTableEntries[MiGetPdeOffset(Address)]--; -#endif } if (SwapEntry != 0) { diff --git a/reactos/ntoskrnl/cache/section/fault.c b/reactos/ntoskrnl/cache/section/fault.c index c9b24238515..4faddc88f7b 100644 --- a/reactos/ntoskrnl/cache/section/fault.c +++ b/reactos/ntoskrnl/cache/section/fault.c @@ -173,13 +173,6 @@ MmNotPresentFaultCachePage MmReferencePage(Page); Status = MmCreateVirtualMapping(Process, Address, Attributes, &Page, 1); -#if (_MI_PAGING_LEVELS == 2) - if (Address < MmSystemRangeStart) - { - Process->Vm.VmWorkingSetList->UsedPageTableEntries[MiGetPdeOffset(Address)]++; - ASSERT(Process->Vm.VmWorkingSetList->UsedPageTableEntries[MiGetPdeOffset(Address)] <= PTE_COUNT); - } -#endif if (NT_SUCCESS(Status)) { MmInsertRmap(Page, Process, Address); diff --git a/reactos/ntoskrnl/cache/section/swapout.c b/reactos/ntoskrnl/cache/section/swapout.c index 8e236cbda09..8de81208097 100644 --- a/reactos/ntoskrnl/cache/section/swapout.c +++ b/reactos/ntoskrnl/cache/section/swapout.c @@ -215,11 +215,6 @@ MmPageOutCacheSection MmReleasePageMemoryConsumer(MC_CACHE, Required->Page[0]); -#if (_MI_PAGING_LEVELS == 2) - if (Address < MmSystemRangeStart) - Process->Vm.VmWorkingSetList->UsedPageTableEntries[MiGetPdeOffset(Address)]--; -#endif - MmUnlockSectionSegment(Segment); MiSetPageEvent(Process, Address); return STATUS_SUCCESS; diff --git a/reactos/ntoskrnl/mm/i386/page.c b/reactos/ntoskrnl/mm/i386/page.c index c999af51c97..b0961f1307b 100644 --- a/reactos/ntoskrnl/mm/i386/page.c +++ b/reactos/ntoskrnl/mm/i386/page.c @@ -461,6 +461,13 @@ MmDeleteVirtualMapping(PEPROCESS Process, PVOID Address, BOOLEAN FreePage, * are removed from the cache */ MiFlushTlb(Pt, Address); + if (Address < MmSystemRangeStart) + { + /* Remove PDE reference */ + Process->Vm.VmWorkingSetList->UsedPageTableEntries[MiGetPdeOffset(Address)]--; + ASSERT(Process->Vm.VmWorkingSetList->UsedPageTableEntries[MiGetPdeOffset(Address)] < PTE_COUNT); + } + Pfn = PTE_TO_PFN(Pte); if (FreePage) @@ -524,6 +531,13 @@ MmDeletePageFileMapping(PEPROCESS Process, PVOID Address, */ Pte = InterlockedExchangePte(Pt, 0); + if (Address < MmSystemRangeStart) + { + /* Remove PDE reference */ + Process->Vm.VmWorkingSetList->UsedPageTableEntries[MiGetPdeOffset(Address)]--; + ASSERT(Process->Vm.VmWorkingSetList->UsedPageTableEntries[MiGetPdeOffset(Address)] < PTE_COUNT); + } + /* We don't need to flush here because page file entries * are invalid translations, so the processor won't cache them */ MmUnmapPageTable(Pt); @@ -717,6 +731,13 @@ MmCreatePageFileMapping(PEPROCESS Process, KeBugCheck(MEMORY_MANAGEMENT); } + if (Address < MmSystemRangeStart) + { + /* Add PDE reference */ + Process->Vm.VmWorkingSetList->UsedPageTableEntries[MiGetPdeOffset(Address)]++; + ASSERT(Process->Vm.VmWorkingSetList->UsedPageTableEntries[MiGetPdeOffset(Address)] <= PTE_COUNT); + } + /* We don't need to flush the TLB here because it * only caches valid translations and a zero PTE * is not a valid translation */ @@ -826,6 +847,13 @@ MmCreateVirtualMappingUnsafe(PEPROCESS Process, /* We don't need to flush the TLB here because it only caches valid translations * and we're moving this PTE from invalid to valid so it can't be cached right now */ + + if (Addr < MmSystemRangeStart) + { + /* Add PDE reference */ + Process->Vm.VmWorkingSetList->UsedPageTableEntries[MiGetPdeOffset(Addr)]++; + ASSERT(Process->Vm.VmWorkingSetList->UsedPageTableEntries[MiGetPdeOffset(Addr)] <= PTE_COUNT); + } } ASSERT(Addr > Address); diff --git a/reactos/ntoskrnl/mm/marea.c b/reactos/ntoskrnl/mm/marea.c index 8c75d33daa8..86b83d8f2d2 100644 --- a/reactos/ntoskrnl/mm/marea.c +++ b/reactos/ntoskrnl/mm/marea.c @@ -750,8 +750,6 @@ MmFreeMemoryArea( if((SwapEntry || Page) && ((PVOID)Address < MmSystemRangeStart)) { ASSERT(AddressSpace != MmGetKernelAddressSpace()); - MmWorkingSetList->UsedPageTableEntries[MiGetPdeOffset(Address)]--; - ASSERT(MmWorkingSetList->UsedPageTableEntries[MiGetPdeOffset(Address)] < PTE_COUNT); if(MmWorkingSetList->UsedPageTableEntries[MiGetPdeOffset(Address)] == 0) { /* No PTE relies on this PDE. Release it */ diff --git a/reactos/ntoskrnl/mm/section.c b/reactos/ntoskrnl/mm/section.c index c9e9d0e2c42..930dbd0d738 100644 --- a/reactos/ntoskrnl/mm/section.c +++ b/reactos/ntoskrnl/mm/section.c @@ -1370,15 +1370,6 @@ MmNotPresentFaultSectionView(PMMSUPPORT AddressSpace, Page = PFN_FROM_SSE(Entry); MmSharePageEntrySectionSegment(Segment, &Offset); - - #if (_MI_PAGING_LEVELS == 2) - /* Reference Page Directory Entry */ - if(Address < MmSystemRangeStart) - { - MmWorkingSetList->UsedPageTableEntries[MiGetPdeOffset(Address)]++; - ASSERT(MmWorkingSetList->UsedPageTableEntries[MiGetPdeOffset(Address)] <= PTE_COUNT); - } -#endif /* FIXME: Should we call MmCreateVirtualMappingUnsafe if * (Section->AllocationAttributes & SEC_PHYSICALMEMORY) is true? @@ -1469,15 +1460,6 @@ MmNotPresentFaultSectionView(PMMSUPPORT AddressSpace, return(STATUS_SUCCESS); } -#if (_MI_PAGING_LEVELS == 2) - /* Reference Page Directory Entry */ - if(Address < MmSystemRangeStart) - { - MmWorkingSetList->UsedPageTableEntries[MiGetPdeOffset(Address)]++; - ASSERT(MmWorkingSetList->UsedPageTableEntries[MiGetPdeOffset(Address)] <= PTE_COUNT); - } -#endif - /* * Satisfying a page fault on a map of /Device/PhysicalMemory is easy */ @@ -1598,13 +1580,6 @@ MmNotPresentFaultSectionView(PMMSUPPORT AddressSpace, /* * Cleanup and release locks */ -#if (_MI_PAGING_LEVELS == 2) - if(Address < MmSystemRangeStart) - { - MmWorkingSetList->UsedPageTableEntries[MiGetPdeOffset(Address)]--; - ASSERT(MmWorkingSetList->UsedPageTableEntries[MiGetPdeOffset(Address)] < PTE_COUNT); - } -#endif MmLockAddressSpace(AddressSpace); PageOp->Status = Status; MmspCompleteAndReleasePageOp(PageOp); @@ -1974,15 +1949,6 @@ MmPageOutDeleteMapping(PVOID Context, PEPROCESS Process, PVOID Address) MmReleasePageMemoryConsumer(MC_USER, Page); } -#if (_MI_PAGING_LEVELS == 2) - /* If this is for the calling process, we take care of te reference in the main function */ - if((Address < MmSystemRangeStart) && (Process != PageOutContext->CallingProcess)) - { - Process->Vm.VmWorkingSetList->UsedPageTableEntries[MiGetPdeOffset(Address)]--; - ASSERT(Process->Vm.VmWorkingSetList->UsedPageTableEntries[MiGetPdeOffset(Address)] < PTE_COUNT); - } -#endif - DPRINT("PhysicalAddress %x, Address %x\n", Page << PAGE_SHIFT, Address); } @@ -2154,14 +2120,6 @@ MmPageOutSectionView(PMMSUPPORT AddressSpace, } if (!Context.WasDirty && SwapEntry != 0) { -#if (_MI_PAGING_LEVELS == 2) - /* We keep the pagefile index global to the segment, not in the PTE */ - if(Address < MmSystemRangeStart) - { - Process->Vm.VmWorkingSetList->UsedPageTableEntries[MiGetPdeOffset(Address)]--; - ASSERT(Process->Vm.VmWorkingSetList->UsedPageTableEntries[MiGetPdeOffset(Address)] < PTE_COUNT); - } -#endif MmSetSavedSwapEntryPage(Page, 0); MmLockSectionSegment(Context.Segment); MmSetPageEntrySectionSegment(Context.Segment, &Context.Offset, MAKE_SWAP_SSE(SwapEntry)); @@ -2182,14 +2140,6 @@ MmPageOutSectionView(PMMSUPPORT AddressSpace, } if (!Context.WasDirty || SwapEntry != 0) { -#if (_MI_PAGING_LEVELS == 2) - /* We keep the pagefile index global to the segment, not in the PTE */ - if(Address < MmSystemRangeStart) - { - Process->Vm.VmWorkingSetList->UsedPageTableEntries[MiGetPdeOffset(Address)]--; - ASSERT(Process->Vm.VmWorkingSetList->UsedPageTableEntries[MiGetPdeOffset(Address)] < PTE_COUNT); - } -#endif MmSetSavedSwapEntryPage(Page, 0); if (SwapEntry != 0) { @@ -2205,14 +2155,6 @@ MmPageOutSectionView(PMMSUPPORT AddressSpace, } else if (!Context.Private && DirectMapped) { -#if (_MI_PAGING_LEVELS == 2) - /* Read only page, no need for a pagefile entry -> PDE-- */ - if(Address < MmSystemRangeStart) - { - Process->Vm.VmWorkingSetList->UsedPageTableEntries[MiGetPdeOffset(Address)]--; - ASSERT(Process->Vm.VmWorkingSetList->UsedPageTableEntries[MiGetPdeOffset(Address)] <= PTE_COUNT); - } -#endif if (SwapEntry != 0) { DPRINT1("Found a swapentry for a non private and direct mapped page (address %x)\n", @@ -2243,14 +2185,6 @@ MmPageOutSectionView(PMMSUPPORT AddressSpace, Address); KeBugCheckEx(MEMORY_MANAGEMENT, SwapEntry, Page, (ULONG_PTR)Process, (ULONG_PTR)Address); } -#if (_MI_PAGING_LEVELS == 2) - /* Non dirty, non private, non direct-mapped -> PDE-- */ - if(Address < MmSystemRangeStart) - { - Process->Vm.VmWorkingSetList->UsedPageTableEntries[MiGetPdeOffset(Address)]--; - ASSERT(Process->Vm.VmWorkingSetList->UsedPageTableEntries[MiGetPdeOffset(Address)] < PTE_COUNT); - } -#endif MmReleasePageMemoryConsumer(MC_USER, Page); PageOp->Status = STATUS_SUCCESS; MmspCompleteAndReleasePageOp(PageOp); @@ -2409,14 +2343,6 @@ MmPageOutSectionView(PMMSUPPORT AddressSpace, } else { -#if (_MI_PAGING_LEVELS == 2) - /* We keep the pagefile index global to the segment, not in the PTE */ - if(Address < MmSystemRangeStart) - { - Process->Vm.VmWorkingSetList->UsedPageTableEntries[MiGetPdeOffset(Address)]--; - ASSERT(Process->Vm.VmWorkingSetList->UsedPageTableEntries[MiGetPdeOffset(Address)] < PTE_COUNT); - } -#endif Entry = MAKE_SWAP_SSE(SwapEntry); MmSetPageEntrySectionSegment(Context.Segment, &Context.Offset, Entry); }