[NTOSKRNL]
authorCameron Gutman <aicommander@gmail.com>
Tue, 29 Nov 2011 18:03:09 +0000 (18:03 +0000)
committerCameron Gutman <aicommander@gmail.com>
Tue, 29 Nov 2011 18:03:09 +0000 (18:03 +0000)
- 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
reactos/ntoskrnl/mm/balance.c

index 8cd5dac..f8a4b3a 100644 (file)
@@ -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);
index 2f33c41..c90d447 100644 (file)
@@ -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);