[NTOSKRNL]

Move acquisition of PFN lock into MmAllocPage and MmDereferencePage

svn path=/trunk/; revision=64586
This commit is contained in:
Timo Kreuzer 2014-10-08 00:30:50 +00:00
parent ca00c95ea5
commit 2d22f6f372
2 changed files with 10 additions and 13 deletions

View file

@ -98,7 +98,6 @@ MmReleasePageMemoryConsumer(ULONG Consumer, PFN_NUMBER Page)
{
PMM_ALLOCATION_REQUEST Request;
PLIST_ENTRY Entry;
KIRQL OldIrql;
if (Page == 0)
{
@ -112,9 +111,7 @@ MmReleasePageMemoryConsumer(ULONG Consumer, PFN_NUMBER Page)
(void)InterlockedDecrementUL(&MiMemoryConsumers[Consumer].PagesUsed);
if ((Entry = ExInterlockedRemoveHeadList(&AllocationListHead, &AllocationListLock)) == NULL)
{
OldIrql = KeAcquireQueuedSpinLock(LockQueuePfnLock);
MmDereferencePage(Page);
KeReleaseQueuedSpinLock(LockQueuePfnLock, OldIrql);
}
else
{
@ -126,9 +123,7 @@ MmReleasePageMemoryConsumer(ULONG Consumer, PFN_NUMBER Page)
}
else
{
OldIrql = KeAcquireQueuedSpinLock(LockQueuePfnLock);
MmDereferencePage(Page);
KeReleaseQueuedSpinLock(LockQueuePfnLock, OldIrql);
}
return(STATUS_SUCCESS);
@ -259,7 +254,6 @@ MmRequestPageMemoryConsumer(ULONG Consumer, BOOLEAN CanWait,
{
ULONG PagesUsed;
PFN_NUMBER Page;
KIRQL OldIrql;
/*
* Make sure we don't exceed our individual target.
@ -276,9 +270,7 @@ MmRequestPageMemoryConsumer(ULONG Consumer, BOOLEAN CanWait,
*/
if ((Consumer == MC_SYSTEM) || MiIsBalancerThread())
{
OldIrql = KeAcquireQueuedSpinLock(LockQueuePfnLock);
Page = MmAllocPage(Consumer);
KeReleaseQueuedSpinLock(LockQueuePfnLock, OldIrql);
if (Page == 0)
{
KeBugCheck(NO_PAGES_AVAILABLE);
@ -337,9 +329,7 @@ MmRequestPageMemoryConsumer(ULONG Consumer, BOOLEAN CanWait,
/*
* Actually allocate the page.
*/
OldIrql = KeAcquireQueuedSpinLock(LockQueuePfnLock);
Page = MmAllocPage(Consumer);
KeReleaseQueuedSpinLock(LockQueuePfnLock, OldIrql);
if (Page == 0)
{
KeBugCheck(NO_PAGES_AVAILABLE);

View file

@ -532,8 +532,11 @@ NTAPI
MmDereferencePage(PFN_NUMBER Pfn)
{
PMMPFN Pfn1;
KIRQL OldIrql;
DPRINT("MmDereferencePage(PhysicalAddress %x)\n", Pfn << PAGE_SHIFT);
OldIrql = KeAcquireQueuedSpinLock(LockQueuePfnLock);
Pfn1 = MiGetPfnEntry(Pfn);
ASSERT(Pfn1);
ASSERT_IS_ROS_PFN(Pfn1);
@ -552,6 +555,8 @@ MmDereferencePage(PFN_NUMBER Pfn)
DPRINT("Legacy free: %lx\n", Pfn);
MiInsertPageInFreeList(Pfn);
}
KeReleaseQueuedSpinLock(LockQueuePfnLock, OldIrql);
}
PFN_NUMBER
@ -560,13 +565,14 @@ MmAllocPage(ULONG Type)
{
PFN_NUMBER PfnOffset;
PMMPFN Pfn1;
KIRQL OldIrql;
OldIrql = KeAcquireQueuedSpinLock(LockQueuePfnLock);
PfnOffset = MiRemoveZeroPage(MI_GET_NEXT_COLOR());
if (!PfnOffset)
{
DPRINT1("MmAllocPage(): Out of memory\n");
return 0;
KeBugCheck(NO_PAGES_AVAILABLE);
}
DPRINT("Legacy allocate: %lx\n", PfnOffset);
@ -581,6 +587,7 @@ MmAllocPage(ULONG Type)
Pfn1->u1.SwapEntry = 0;
Pfn1->RmapListHead = NULL;
KeReleaseQueuedSpinLock(LockQueuePfnLock, OldIrql);
return PfnOffset;
}