mirror of
https://github.com/reactos/reactos.git
synced 2025-01-05 22:12:46 +00:00
[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:
parent
41364b7c5a
commit
50e1500799
6 changed files with 28 additions and 100 deletions
12
reactos/ntoskrnl/cache/section/data.c
vendored
12
reactos/ntoskrnl/cache/section/data.c
vendored
|
@ -143,14 +143,6 @@ MiZeroFillSection
|
||||||
MmReferencePage(Page);
|
MmReferencePage(Page);
|
||||||
MmCreateVirtualMapping(NULL, Address, PAGE_READWRITE, &Page, 1);
|
MmCreateVirtualMapping(NULL, Address, PAGE_READWRITE, &Page, 1);
|
||||||
MmInsertRmap(Page, NULL, Address);
|
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
|
else
|
||||||
MmReleasePageMemoryConsumer(MC_CACHE, Page);
|
MmReleasePageMemoryConsumer(MC_CACHE, Page);
|
||||||
|
@ -676,10 +668,6 @@ MmFreeCacheSectionPage
|
||||||
MmDeleteRmap(Page, Process, Address);
|
MmDeleteRmap(Page, Process, Address);
|
||||||
MmDeleteVirtualMapping(Process, Address, FALSE, NULL, NULL);
|
MmDeleteVirtualMapping(Process, Address, FALSE, NULL, NULL);
|
||||||
MmReleasePageMemoryConsumer(MC_CACHE, Page);
|
MmReleasePageMemoryConsumer(MC_CACHE, Page);
|
||||||
#if (_MI_PAGING_LEVELS == 2)
|
|
||||||
if (Address < MmSystemRangeStart)
|
|
||||||
Process->Vm.VmWorkingSetList->UsedPageTableEntries[MiGetPdeOffset(Address)]--;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
if (SwapEntry != 0)
|
if (SwapEntry != 0)
|
||||||
{
|
{
|
||||||
|
|
7
reactos/ntoskrnl/cache/section/fault.c
vendored
7
reactos/ntoskrnl/cache/section/fault.c
vendored
|
@ -173,13 +173,6 @@ MmNotPresentFaultCachePage
|
||||||
MmReferencePage(Page);
|
MmReferencePage(Page);
|
||||||
|
|
||||||
Status = MmCreateVirtualMapping(Process, Address, Attributes, &Page, 1);
|
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))
|
if (NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
MmInsertRmap(Page, Process, Address);
|
MmInsertRmap(Page, Process, Address);
|
||||||
|
|
5
reactos/ntoskrnl/cache/section/swapout.c
vendored
5
reactos/ntoskrnl/cache/section/swapout.c
vendored
|
@ -215,11 +215,6 @@ MmPageOutCacheSection
|
||||||
|
|
||||||
MmReleasePageMemoryConsumer(MC_CACHE, Required->Page[0]);
|
MmReleasePageMemoryConsumer(MC_CACHE, Required->Page[0]);
|
||||||
|
|
||||||
#if (_MI_PAGING_LEVELS == 2)
|
|
||||||
if (Address < MmSystemRangeStart)
|
|
||||||
Process->Vm.VmWorkingSetList->UsedPageTableEntries[MiGetPdeOffset(Address)]--;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
MmUnlockSectionSegment(Segment);
|
MmUnlockSectionSegment(Segment);
|
||||||
MiSetPageEvent(Process, Address);
|
MiSetPageEvent(Process, Address);
|
||||||
return STATUS_SUCCESS;
|
return STATUS_SUCCESS;
|
||||||
|
|
|
@ -461,6 +461,13 @@ MmDeleteVirtualMapping(PEPROCESS Process, PVOID Address, BOOLEAN FreePage,
|
||||||
* are removed from the cache */
|
* are removed from the cache */
|
||||||
MiFlushTlb(Pt, Address);
|
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);
|
Pfn = PTE_TO_PFN(Pte);
|
||||||
|
|
||||||
if (FreePage)
|
if (FreePage)
|
||||||
|
@ -524,6 +531,13 @@ MmDeletePageFileMapping(PEPROCESS Process, PVOID Address,
|
||||||
*/
|
*/
|
||||||
Pte = InterlockedExchangePte(Pt, 0);
|
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
|
/* We don't need to flush here because page file entries
|
||||||
* are invalid translations, so the processor won't cache them */
|
* are invalid translations, so the processor won't cache them */
|
||||||
MmUnmapPageTable(Pt);
|
MmUnmapPageTable(Pt);
|
||||||
|
@ -717,6 +731,13 @@ MmCreatePageFileMapping(PEPROCESS Process,
|
||||||
KeBugCheck(MEMORY_MANAGEMENT);
|
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
|
/* We don't need to flush the TLB here because it
|
||||||
* only caches valid translations and a zero PTE
|
* only caches valid translations and a zero PTE
|
||||||
* is not a valid translation */
|
* 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
|
/* 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 */
|
* 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);
|
ASSERT(Addr > Address);
|
||||||
|
|
|
@ -750,8 +750,6 @@ MmFreeMemoryArea(
|
||||||
if((SwapEntry || Page) && ((PVOID)Address < MmSystemRangeStart))
|
if((SwapEntry || Page) && ((PVOID)Address < MmSystemRangeStart))
|
||||||
{
|
{
|
||||||
ASSERT(AddressSpace != MmGetKernelAddressSpace());
|
ASSERT(AddressSpace != MmGetKernelAddressSpace());
|
||||||
MmWorkingSetList->UsedPageTableEntries[MiGetPdeOffset(Address)]--;
|
|
||||||
ASSERT(MmWorkingSetList->UsedPageTableEntries[MiGetPdeOffset(Address)] < PTE_COUNT);
|
|
||||||
if(MmWorkingSetList->UsedPageTableEntries[MiGetPdeOffset(Address)] == 0)
|
if(MmWorkingSetList->UsedPageTableEntries[MiGetPdeOffset(Address)] == 0)
|
||||||
{
|
{
|
||||||
/* No PTE relies on this PDE. Release it */
|
/* No PTE relies on this PDE. Release it */
|
||||||
|
|
|
@ -1370,15 +1370,6 @@ MmNotPresentFaultSectionView(PMMSUPPORT AddressSpace,
|
||||||
Page = PFN_FROM_SSE(Entry);
|
Page = PFN_FROM_SSE(Entry);
|
||||||
|
|
||||||
MmSharePageEntrySectionSegment(Segment, &Offset);
|
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
|
/* FIXME: Should we call MmCreateVirtualMappingUnsafe if
|
||||||
* (Section->AllocationAttributes & SEC_PHYSICALMEMORY) is true?
|
* (Section->AllocationAttributes & SEC_PHYSICALMEMORY) is true?
|
||||||
|
@ -1469,15 +1460,6 @@ MmNotPresentFaultSectionView(PMMSUPPORT AddressSpace,
|
||||||
return(STATUS_SUCCESS);
|
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
|
* Satisfying a page fault on a map of /Device/PhysicalMemory is easy
|
||||||
*/
|
*/
|
||||||
|
@ -1598,13 +1580,6 @@ MmNotPresentFaultSectionView(PMMSUPPORT AddressSpace,
|
||||||
/*
|
/*
|
||||||
* Cleanup and release locks
|
* 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);
|
MmLockAddressSpace(AddressSpace);
|
||||||
PageOp->Status = Status;
|
PageOp->Status = Status;
|
||||||
MmspCompleteAndReleasePageOp(PageOp);
|
MmspCompleteAndReleasePageOp(PageOp);
|
||||||
|
@ -1974,15 +1949,6 @@ MmPageOutDeleteMapping(PVOID Context, PEPROCESS Process, PVOID Address)
|
||||||
MmReleasePageMemoryConsumer(MC_USER, Page);
|
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);
|
DPRINT("PhysicalAddress %x, Address %x\n", Page << PAGE_SHIFT, Address);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2154,14 +2120,6 @@ MmPageOutSectionView(PMMSUPPORT AddressSpace,
|
||||||
}
|
}
|
||||||
if (!Context.WasDirty && SwapEntry != 0)
|
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);
|
MmSetSavedSwapEntryPage(Page, 0);
|
||||||
MmLockSectionSegment(Context.Segment);
|
MmLockSectionSegment(Context.Segment);
|
||||||
MmSetPageEntrySectionSegment(Context.Segment, &Context.Offset, MAKE_SWAP_SSE(SwapEntry));
|
MmSetPageEntrySectionSegment(Context.Segment, &Context.Offset, MAKE_SWAP_SSE(SwapEntry));
|
||||||
|
@ -2182,14 +2140,6 @@ MmPageOutSectionView(PMMSUPPORT AddressSpace,
|
||||||
}
|
}
|
||||||
if (!Context.WasDirty || SwapEntry != 0)
|
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);
|
MmSetSavedSwapEntryPage(Page, 0);
|
||||||
if (SwapEntry != 0)
|
if (SwapEntry != 0)
|
||||||
{
|
{
|
||||||
|
@ -2205,14 +2155,6 @@ MmPageOutSectionView(PMMSUPPORT AddressSpace,
|
||||||
}
|
}
|
||||||
else if (!Context.Private && DirectMapped)
|
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)
|
if (SwapEntry != 0)
|
||||||
{
|
{
|
||||||
DPRINT1("Found a swapentry for a non private and direct mapped page (address %x)\n",
|
DPRINT1("Found a swapentry for a non private and direct mapped page (address %x)\n",
|
||||||
|
@ -2243,14 +2185,6 @@ MmPageOutSectionView(PMMSUPPORT AddressSpace,
|
||||||
Address);
|
Address);
|
||||||
KeBugCheckEx(MEMORY_MANAGEMENT, SwapEntry, Page, (ULONG_PTR)Process, (ULONG_PTR)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);
|
MmReleasePageMemoryConsumer(MC_USER, Page);
|
||||||
PageOp->Status = STATUS_SUCCESS;
|
PageOp->Status = STATUS_SUCCESS;
|
||||||
MmspCompleteAndReleasePageOp(PageOp);
|
MmspCompleteAndReleasePageOp(PageOp);
|
||||||
|
@ -2409,14 +2343,6 @@ MmPageOutSectionView(PMMSUPPORT AddressSpace,
|
||||||
}
|
}
|
||||||
else
|
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);
|
Entry = MAKE_SWAP_SSE(SwapEntry);
|
||||||
MmSetPageEntrySectionSegment(Context.Segment, &Context.Offset, Entry);
|
MmSetPageEntrySectionSegment(Context.Segment, &Context.Offset, Entry);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue