Author: cgutman
Date: Tue Nov 29 18:03:09 2011
New Revision: 54539
URL: 
http://svn.reactos.org/svn/reactos?rev=54539&view=rev
Log:
[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)
Modified:
    trunk/reactos/ntoskrnl/mm/ARM3/pfnlist.c
    trunk/reactos/ntoskrnl/mm/balance.c
Modified: trunk/reactos/ntoskrnl/mm/ARM3/pfnlist.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/mm/ARM3/pfnlist.c…
==============================================================================
--- trunk/reactos/ntoskrnl/mm/ARM3/pfnlist.c [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/mm/ARM3/pfnlist.c [iso-8859-1] Tue Nov 29 18:03:09 2011
@@ -848,16 +848,22 @@
     /* Make an empty software PTE */
     MI_MAKE_SOFTWARE_PTE(&TempPte, MM_READWRITE);
+
+    /* 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);
-
-    /* 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);
-    }
     /* Grab a page */
     ASSERT_LIST_INVARIANT(&MmFreePageListHead);
Modified: trunk/reactos/ntoskrnl/mm/balance.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/mm/balance.c?rev=…
==============================================================================
--- trunk/reactos/ntoskrnl/mm/balance.c [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/mm/balance.c [iso-8859-1] Tue Nov 29 18:03:09 2011
@@ -122,6 +122,7 @@
          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 @@
          KeBugCheck(NO_PAGES_AVAILABLE);
       }
+      if(Consumer == MC_USER) MmInsertLRULastUserPage(Page);
       *AllocatedPage = Page;
       (void)InterlockedDecrementUL(&MiPagesRequired);