[NTOSKRNL]

Move the remaining 2 ROSPFN fields into the MMPFN structure instead of allocating ROSPFNs from non-paged pool.

svn path=/trunk/; revision=62042
This commit is contained in:
Timo Kreuzer 2014-02-08 15:54:38 +00:00
parent ab2d86c6a7
commit e3c21af5dd
3 changed files with 49 additions and 66 deletions

View file

@ -339,10 +339,13 @@ typedef struct _MMPFN
union
{
PFN_NUMBER Flink;
ULONG WsIndex; // SavedSwapEntry
ULONG WsIndex;
PKEVENT Event;
NTSTATUS ReadStatus;
SINGLE_LIST_ENTRY NextStackPfn;
// HACK for ROSPFN
SWAPENTRY SwapEntry;
} u1;
PMMPTE PteAddress;
union
@ -354,7 +357,7 @@ typedef struct _MMPFN
{
struct
{
USHORT ReferenceCount; // ReferenceCount
USHORT ReferenceCount;
MMPFNENTRY e1;
};
struct
@ -366,7 +369,10 @@ typedef struct _MMPFN
union
{
MMPTE OriginalPte;
LONG AweReferenceCount; // RmapListHead
LONG AweReferenceCount;
// HACK for ROSPFN
PMM_RMAP_ENTRY RmapListHead;
};
union
{

View file

@ -1121,23 +1121,7 @@ MiIsRosSectionObject(IN PVOID Section)
return FALSE;
}
#ifdef _WIN64
// HACK ON TOP OF HACK ALERT!!!
#define MI_GET_ROS_DATA(x) \
(((x)->RosMmData == 0) ? NULL : ((PMMROSPFN)((ULONG64)(ULONG)((x)->RosMmData) | \
((ULONG64)MmNonPagedPoolStart & 0xffffffff00000000ULL))))
#else
#define MI_GET_ROS_DATA(x) ((PMMROSPFN)(x->RosMmData))
#endif
#define MI_IS_ROS_PFN(x) (((x)->u4.AweAllocation == TRUE) && (MI_GET_ROS_DATA(x) != NULL))
#define ASSERT_IS_ROS_PFN(x) ASSERT(MI_IS_ROS_PFN(x) == TRUE);
typedef struct _MMROSPFN
{
PMM_RMAP_ENTRY RmapListHead;
SWAPENTRY SwapEntry;
} MMROSPFN, *PMMROSPFN;
#define RosMmData AweReferenceCount
#define MI_IS_ROS_PFN(x) ((x)->u4.AweAllocation == TRUE)
VOID
NTAPI

View file

@ -21,13 +21,11 @@
#define MODULE_INVOLVED_IN_ARM3
#include "ARM3/miarm.h"
#define ASSERT_IS_ROS_PFN(x) ASSERT(MI_IS_ROS_PFN(x) == TRUE);
/* GLOBALS ****************************************************************/
// ReactOS to NT Physical Page Descriptor Entry Legacy Mapping Definitions
#define PHYSICAL_PAGE MMPFN
#define PPHYSICAL_PAGE PMMPFN
PPHYSICAL_PAGE MmPfnDatabase;
PMMPFN MmPfnDatabase;
PFN_NUMBER MmAvailablePages;
PFN_NUMBER MmResidentAvailablePages;
@ -164,7 +162,7 @@ MiAllocatePagesForMdl(IN PHYSICAL_ADDRESS LowAddress,
PFN_NUMBER PageCount, LowPage, HighPage, SkipPages, PagesFound = 0, Page;
PPFN_NUMBER MdlPage, LastMdlPage;
KIRQL OldIrql;
PPHYSICAL_PAGE Pfn1;
PMMPFN Pfn1;
INT LookForZeroedPages;
ASSERT(KeGetCurrentIrql() <= APC_LEVEL);
DPRINT1("ARM3-DEBUG: Being called with %I64x %I64x %I64x %lx %d %lu\n", LowAddress, HighAddress, SkipBytes, TotalBytes, CacheAttribute, MdlFlags);
@ -407,7 +405,7 @@ MmSetRmapListHeadPage(PFN_NUMBER Pfn, PMM_RMAP_ENTRY ListHead)
ASSERT(MiIsPfnInUse(Pfn1) == TRUE);
/* Set the list head address */
MI_GET_ROS_DATA(Pfn1)->RmapListHead = ListHead;
Pfn1->RmapListHead = ListHead;
}
else
{
@ -415,7 +413,7 @@ MmSetRmapListHeadPage(PFN_NUMBER Pfn, PMM_RMAP_ENTRY ListHead)
ASSERT(MiIsPfnInUse(Pfn1) == TRUE);
/* In this case, the RMAP is actually being removed, so clear field */
MI_GET_ROS_DATA(Pfn1)->RmapListHead = NULL;
Pfn1->RmapListHead = NULL;
/* ReactOS semantics will now release the page, which will make it free and enter a colored list */
}
@ -440,7 +438,7 @@ MmGetRmapListHeadPage(PFN_NUMBER Pfn)
ASSERT_IS_ROS_PFN(Pfn1);
/* Get the list head */
ListHead = MI_GET_ROS_DATA(Pfn1)->RmapListHead;
ListHead = Pfn1->RmapListHead;
/* Should not have an RMAP for a non-active page */
ASSERT(MiIsPfnInUse(Pfn1) == TRUE);
@ -455,14 +453,14 @@ NTAPI
MmSetSavedSwapEntryPage(PFN_NUMBER Pfn, SWAPENTRY SwapEntry)
{
KIRQL oldIrql;
PPHYSICAL_PAGE Page;
PMMPFN Pfn1;
Page = MiGetPfnEntry(Pfn);
ASSERT(Page);
ASSERT_IS_ROS_PFN(Page);
Pfn1 = MiGetPfnEntry(Pfn);
ASSERT(Pfn1);
ASSERT_IS_ROS_PFN(Pfn1);
oldIrql = KeAcquireQueuedSpinLock(LockQueuePfnLock);
MI_GET_ROS_DATA(Page)->SwapEntry = SwapEntry;
Pfn1->u1.SwapEntry = SwapEntry;
KeReleaseQueuedSpinLock(LockQueuePfnLock, oldIrql);
}
@ -472,14 +470,14 @@ MmGetSavedSwapEntryPage(PFN_NUMBER Pfn)
{
SWAPENTRY SwapEntry;
KIRQL oldIrql;
PPHYSICAL_PAGE Page;
PMMPFN Pfn1;
Page = MiGetPfnEntry(Pfn);
ASSERT(Page);
ASSERT_IS_ROS_PFN(Page);
Pfn1 = MiGetPfnEntry(Pfn);
ASSERT(Pfn1);
ASSERT_IS_ROS_PFN(Pfn1);
oldIrql = KeAcquireQueuedSpinLock(LockQueuePfnLock);
SwapEntry = MI_GET_ROS_DATA(Page)->SwapEntry;
SwapEntry = Pfn1->u1.SwapEntry;
KeReleaseQueuedSpinLock(LockQueuePfnLock, oldIrql);
return(SwapEntry);
@ -489,7 +487,7 @@ VOID
NTAPI
MmReferencePage(PFN_NUMBER Pfn)
{
PPHYSICAL_PAGE Page;
PMMPFN Pfn1;
DPRINT("MmReferencePage(PysicalAddress %x)\n", Pfn << PAGE_SHIFT);
@ -497,12 +495,12 @@ MmReferencePage(PFN_NUMBER Pfn)
ASSERT(Pfn != 0);
ASSERT(Pfn <= MmHighestPhysicalPage);
Page = MiGetPfnEntry(Pfn);
ASSERT(Page);
ASSERT_IS_ROS_PFN(Page);
Pfn1 = MiGetPfnEntry(Pfn);
ASSERT(Pfn1);
ASSERT_IS_ROS_PFN(Pfn1);
ASSERT(Page->u3.e2.ReferenceCount != 0);
Page->u3.e2.ReferenceCount++;
ASSERT(Pfn1->u3.e2.ReferenceCount != 0);
Pfn1->u3.e2.ReferenceCount++;
}
ULONG
@ -511,16 +509,16 @@ MmGetReferenceCountPage(PFN_NUMBER Pfn)
{
KIRQL oldIrql;
ULONG RCount;
PPHYSICAL_PAGE Page;
PMMPFN Pfn1;
DPRINT("MmGetReferenceCountPage(PhysicalAddress %x)\n", Pfn << PAGE_SHIFT);
oldIrql = KeAcquireQueuedSpinLock(LockQueuePfnLock);
Page = MiGetPfnEntry(Pfn);
ASSERT(Page);
ASSERT_IS_ROS_PFN(Page);
Pfn1 = MiGetPfnEntry(Pfn);
ASSERT(Pfn1);
ASSERT_IS_ROS_PFN(Pfn1);
RCount = Page->u3.e2.ReferenceCount;
RCount = Pfn1->u3.e2.ReferenceCount;
KeReleaseQueuedSpinLock(LockQueuePfnLock, oldIrql);
return(RCount);
@ -537,24 +535,22 @@ VOID
NTAPI
MmDereferencePage(PFN_NUMBER Pfn)
{
PPHYSICAL_PAGE Page;
PMMPFN Pfn1;
DPRINT("MmDereferencePage(PhysicalAddress %x)\n", Pfn << PAGE_SHIFT);
Page = MiGetPfnEntry(Pfn);
ASSERT(Page);
ASSERT_IS_ROS_PFN(Page);
Pfn1 = MiGetPfnEntry(Pfn);
ASSERT(Pfn1);
ASSERT_IS_ROS_PFN(Pfn1);
ASSERT(Page->u3.e2.ReferenceCount != 0);
Page->u3.e2.ReferenceCount--;
if (Page->u3.e2.ReferenceCount == 0)
ASSERT(Pfn1->u3.e2.ReferenceCount != 0);
Pfn1->u3.e2.ReferenceCount--;
if (Pfn1->u3.e2.ReferenceCount == 0)
{
/* Mark the page temporarily as valid, we're going to make it free soon */
Page->u3.e1.PageLocation = ActiveAndValid;
Pfn1->u3.e1.PageLocation = ActiveAndValid;
/* It's not a ROS PFN anymore */
Page->u4.AweAllocation = FALSE;
ExFreePoolWithTag(MI_GET_ROS_DATA(Page), 'RsPf');
Page->RosMmData = 0;
Pfn1->u4.AweAllocation = FALSE;
/* Bring it back into the free list */
DPRINT("Legacy free: %lx\n", Pfn);
@ -586,11 +582,8 @@ MmAllocPage(ULONG Type)
Pfn1->u4.AweAllocation = TRUE;
/* Allocate the extra ReactOS Data and zero it out */
Pfn1->RosMmData = (LONG)ExAllocatePoolWithTag(NonPagedPool, sizeof(MMROSPFN), 'RsPf');
ASSERT(MI_GET_ROS_DATA(Pfn1) != NULL);
ASSERT_IS_ROS_PFN(Pfn1);
MI_GET_ROS_DATA(Pfn1)->SwapEntry = 0;
MI_GET_ROS_DATA(Pfn1)->RmapListHead = NULL;
Pfn1->u1.SwapEntry = 0;
Pfn1->RmapListHead = NULL;
return PfnOffset;
}