Author: cgutman
Date: Sun Mar 4 22:31:30 2012
New Revision: 56018
URL:
http://svn.reactos.org/svn/reactos?rev=56018&view=rev
Log:
[NTOSKRNL]
- Consolidate most of the PDE reference counting code into the arch-specific RosMm folder
where it belongs
Modified:
trunk/reactos/ntoskrnl/cache/section/data.c
trunk/reactos/ntoskrnl/cache/section/fault.c
trunk/reactos/ntoskrnl/cache/section/swapout.c
trunk/reactos/ntoskrnl/mm/i386/page.c
trunk/reactos/ntoskrnl/mm/marea.c
trunk/reactos/ntoskrnl/mm/section.c
Modified: trunk/reactos/ntoskrnl/cache/section/data.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/cache/section/dat…
==============================================================================
--- trunk/reactos/ntoskrnl/cache/section/data.c [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/cache/section/data.c [iso-8859-1] Sun Mar 4 22:31:30 2012
@@ -143,14 +143,6 @@
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 @@
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)
{
Modified: trunk/reactos/ntoskrnl/cache/section/fault.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/cache/section/fau…
==============================================================================
--- trunk/reactos/ntoskrnl/cache/section/fault.c [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/cache/section/fault.c [iso-8859-1] Sun Mar 4 22:31:30 2012
@@ -173,13 +173,6 @@
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);
Modified: trunk/reactos/ntoskrnl/cache/section/swapout.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/cache/section/swa…
==============================================================================
--- trunk/reactos/ntoskrnl/cache/section/swapout.c [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/cache/section/swapout.c [iso-8859-1] Sun Mar 4 22:31:30 2012
@@ -215,11 +215,6 @@
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;
Modified: trunk/reactos/ntoskrnl/mm/i386/page.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/mm/i386/page.c?re…
==============================================================================
--- trunk/reactos/ntoskrnl/mm/i386/page.c [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/mm/i386/page.c [iso-8859-1] Sun Mar 4 22:31:30 2012
@@ -461,6 +461,13 @@
* 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 @@
*/
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);
@@ -716,6 +730,13 @@
{
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
@@ -826,6 +847,13 @@
/* 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);
Modified: trunk/reactos/ntoskrnl/mm/marea.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/mm/marea.c?rev=56…
==============================================================================
--- trunk/reactos/ntoskrnl/mm/marea.c [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/mm/marea.c [iso-8859-1] Sun Mar 4 22:31:30 2012
@@ -750,8 +750,6 @@
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 */
Modified: trunk/reactos/ntoskrnl/mm/section.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/mm/section.c?rev=…
==============================================================================
--- trunk/reactos/ntoskrnl/mm/section.c [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/mm/section.c [iso-8859-1] Sun Mar 4 22:31:30 2012
@@ -1370,15 +1370,6 @@
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 @@
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 @@
/*
* 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);
@@ -1973,15 +1948,6 @@
{
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 @@
}
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 @@
}
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 @@
}
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 @@
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 @@
}
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);
}