[NTOSKRNL]

- Consolidate most of the PDE reference counting code into the arch-specific RosMm folder where it belongs

svn path=/trunk/; revision=56018
This commit is contained in:
Cameron Gutman 2012-03-04 22:31:30 +00:00
parent 41364b7c5a
commit 50e1500799
6 changed files with 28 additions and 100 deletions

View file

@ -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)
{

View file

@ -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);

View file

@ -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;

View file

@ -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);

View file

@ -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 */

View file

@ -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);
}