Author: tkreuzer
Date: Sat Feb 8 15:54:38 2014
New Revision: 62042
URL:
http://svn.reactos.org/svn/reactos?rev=62042&view=rev
Log:
[NTOSKRNL]
Move the remaining 2 ROSPFN fields into the MMPFN structure instead of allocating ROSPFNs
from non-paged pool.
Modified:
trunk/reactos/ntoskrnl/include/internal/mm.h
trunk/reactos/ntoskrnl/mm/ARM3/miarm.h
trunk/reactos/ntoskrnl/mm/freelist.c
Modified: trunk/reactos/ntoskrnl/include/internal/mm.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/include/internal/…
==============================================================================
--- trunk/reactos/ntoskrnl/include/internal/mm.h [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/include/internal/mm.h [iso-8859-1] Sat Feb 8 15:54:38 2014
@@ -339,10 +339,13 @@
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 @@
{
struct
{
- USHORT ReferenceCount; // ReferenceCount
+ USHORT ReferenceCount;
MMPFNENTRY e1;
};
struct
@@ -366,7 +369,10 @@
union
{
MMPTE OriginalPte;
- LONG AweReferenceCount; // RmapListHead
+ LONG AweReferenceCount;
+
+ // HACK for ROSPFN
+ PMM_RMAP_ENTRY RmapListHead;
};
union
{
Modified: trunk/reactos/ntoskrnl/mm/ARM3/miarm.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/mm/ARM3/miarm.h?r…
==============================================================================
--- trunk/reactos/ntoskrnl/mm/ARM3/miarm.h [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/mm/ARM3/miarm.h [iso-8859-1] Sat Feb 8 15:54:38 2014
@@ -1121,23 +1121,7 @@
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
Modified: trunk/reactos/ntoskrnl/mm/freelist.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/mm/freelist.c?rev…
==============================================================================
--- trunk/reactos/ntoskrnl/mm/freelist.c [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/mm/freelist.c [iso-8859-1] Sat Feb 8 15:54:38 2014
@@ -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 @@
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 @@
ASSERT(MiIsPfnInUse(Pfn1) == TRUE);
/* Set the list head address */
- MI_GET_ROS_DATA(Pfn1)->RmapListHead = ListHead;
+ Pfn1->RmapListHead = ListHead;
}
else
{
@@ -415,7 +413,7 @@
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 @@
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 @@
MmSetSavedSwapEntryPage(PFN_NUMBER Pfn, SWAPENTRY SwapEntry)
{
KIRQL oldIrql;
- PPHYSICAL_PAGE Page;
-
- Page = MiGetPfnEntry(Pfn);
- ASSERT(Page);
- ASSERT_IS_ROS_PFN(Page);
+ PMMPFN Pfn1;
+
+ 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 @@
{
SWAPENTRY SwapEntry;
KIRQL oldIrql;
- PPHYSICAL_PAGE Page;
-
- Page = MiGetPfnEntry(Pfn);
- ASSERT(Page);
- ASSERT_IS_ROS_PFN(Page);
+ PMMPFN Pfn1;
+
+ 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 @@
NTAPI
MmReferencePage(PFN_NUMBER Pfn)
{
- PPHYSICAL_PAGE Page;
+ PMMPFN Pfn1;
DPRINT("MmReferencePage(PysicalAddress %x)\n", Pfn << PAGE_SHIFT);
@@ -497,12 +495,12 @@
ASSERT(Pfn != 0);
ASSERT(Pfn <= MmHighestPhysicalPage);
- Page = MiGetPfnEntry(Pfn);
- ASSERT(Page);
- ASSERT_IS_ROS_PFN(Page);
-
- ASSERT(Page->u3.e2.ReferenceCount != 0);
- Page->u3.e2.ReferenceCount++;
+ Pfn1 = MiGetPfnEntry(Pfn);
+ ASSERT(Pfn1);
+ ASSERT_IS_ROS_PFN(Pfn1);
+
+ ASSERT(Pfn1->u3.e2.ReferenceCount != 0);
+ Pfn1->u3.e2.ReferenceCount++;
}
ULONG
@@ -511,16 +509,16 @@
{
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);
-
- RCount = Page->u3.e2.ReferenceCount;
+ Pfn1 = MiGetPfnEntry(Pfn);
+ ASSERT(Pfn1);
+ ASSERT_IS_ROS_PFN(Pfn1);
+
+ RCount = Pfn1->u3.e2.ReferenceCount;
KeReleaseQueuedSpinLock(LockQueuePfnLock, oldIrql);
return(RCount);
@@ -537,24 +535,22 @@
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);
-
- ASSERT(Page->u3.e2.ReferenceCount != 0);
- Page->u3.e2.ReferenceCount--;
- if (Page->u3.e2.ReferenceCount == 0)
+ Pfn1 = MiGetPfnEntry(Pfn);
+ ASSERT(Pfn1);
+ ASSERT_IS_ROS_PFN(Pfn1);
+
+ 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 @@
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;
}