From 832bc7ab3f0a67d817dddaffa5597135942367e6 Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Tue, 29 Nov 2011 18:03:09 +0000 Subject: [PATCH] [NTOSKRNL] - Revert part of r54530 - Try to rebalance RosMm's pages if we're low on memory in ARM3 - ROS runs with 48 MB RAM again (but setup is very slow due to horrendous paging caused by cache pollution) svn path=/trunk/; revision=54539 --- reactos/ntoskrnl/mm/ARM3/pfnlist.c | 14 ++++++++++---- reactos/ntoskrnl/mm/balance.c | 2 ++ 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/reactos/ntoskrnl/mm/ARM3/pfnlist.c b/reactos/ntoskrnl/mm/ARM3/pfnlist.c index 8cd5dacb50a..f8a4b3a3bc6 100644 --- a/reactos/ntoskrnl/mm/ARM3/pfnlist.c +++ b/reactos/ntoskrnl/mm/ARM3/pfnlist.c @@ -848,17 +848,23 @@ MiAllocatePfn(IN PMMPTE PointerPte, /* Make an empty software PTE */ MI_MAKE_SOFTWARE_PTE(&TempPte, MM_READWRITE); - - /* Lock the PFN database */ - OldIrql = KeAcquireQueuedSpinLock(LockQueuePfnLock); - + /* Check if we're running low on pages */ if (MmAvailablePages < 128) { DPRINT1("Warning, running low on memory: %d pages left\n", MmAvailablePages); + //MiEnsureAvailablePageOrWait(NULL, OldIrql); + + /* Call RosMm and see if it can release any pages for us */ + MmRebalanceMemoryConsumers(); + + DPRINT1("Rebalance complete: %d pages left\n", MmAvailablePages); } + /* Lock the PFN database */ + OldIrql = KeAcquireQueuedSpinLock(LockQueuePfnLock); + /* Grab a page */ ASSERT_LIST_INVARIANT(&MmFreePageListHead); ASSERT_LIST_INVARIANT(&MmZeroedPageListHead); diff --git a/reactos/ntoskrnl/mm/balance.c b/reactos/ntoskrnl/mm/balance.c index 2f33c418a65..c90d447547b 100644 --- a/reactos/ntoskrnl/mm/balance.c +++ b/reactos/ntoskrnl/mm/balance.c @@ -122,6 +122,7 @@ MmReleasePageMemoryConsumer(ULONG Consumer, PFN_NUMBER Page) Entry = RemoveHeadList(&AllocationListHead); Request = CONTAINING_RECORD(Entry, MM_ALLOCATION_REQUEST, ListEntry); KeReleaseSpinLock(&AllocationListLock, OldIrql); + if(Consumer == MC_USER) MmRemoveLRUUserPage(Page); MiZeroPhysicalPage(Page); Request->Page = Page; KeSetEvent(&Request->Event, IO_NO_INCREMENT, FALSE); @@ -310,6 +311,7 @@ MmRequestPageMemoryConsumer(ULONG Consumer, BOOLEAN CanWait, KeBugCheck(NO_PAGES_AVAILABLE); } + if(Consumer == MC_USER) MmInsertLRULastUserPage(Page); *AllocatedPage = Page; (void)InterlockedDecrementUL(&MiPagesRequired); -- 2.17.1