[ros-diffs] [cgutman] 56050: [NTOSKRNL] - Fix incorrect placement of the PDE freeing code which caused a deadlock to occur if a low memory condition was indicated by ARM3

cgutman at svn.reactos.org cgutman at svn.reactos.org
Mon Mar 5 19:40:44 UTC 2012


Author: cgutman
Date: Mon Mar  5 19:40:44 2012
New Revision: 56050

URL: http://svn.reactos.org/svn/reactos?rev=56050&view=rev
Log:
[NTOSKRNL]
- Fix incorrect placement of the PDE freeing code which caused a deadlock to occur if a low memory condition was indicated by ARM3

Modified:
    trunk/reactos/ntoskrnl/mm/balance.c

Modified: trunk/reactos/ntoskrnl/mm/balance.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/mm/balance.c?rev=56050&r1=56049&r2=56050&view=diff
==============================================================================
--- trunk/reactos/ntoskrnl/mm/balance.c [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/mm/balance.c [iso-8859-1] Mon Mar  5 19:40:44 2012
@@ -245,33 +245,6 @@
 NTAPI
 MmRebalanceMemoryConsumers(VOID)
 {
-#if (_MI_PAGING_LEVELS == 2)
-    if(!MiIsBalancerThread())
-    {
-        /* Clean up the unused PDEs */
-        ULONG_PTR Address;
-        PEPROCESS Process = PsGetCurrentProcess();
-
-        /* Acquire PFN lock */
-        KIRQL OldIrql = KeAcquireQueuedSpinLock(LockQueuePfnLock);
-        PMMPDE pointerPde;
-        for(Address = (ULONG_PTR)MI_LOWEST_VAD_ADDRESS;
-            Address < (ULONG_PTR)MM_HIGHEST_VAD_ADDRESS;
-            Address += (PAGE_SIZE * PTE_COUNT))
-        {
-            if(MmWorkingSetList->UsedPageTableEntries[MiGetPdeOffset(Address)] == 0)
-            {
-                pointerPde = MiAddressToPde(Address);
-                if(pointerPde->u.Hard.Valid)
-                    MiDeletePte(pointerPde, MiPdeToPte(pointerPde), Process, NULL);
-                ASSERT(pointerPde->u.Hard.Valid == 0);
-            }
-        }
-        /* Release lock */
-        KeReleaseQueuedSpinLock(LockQueuePfnLock, OldIrql);
-    }
-#endif
-
     if (MiBalancerThreadHandle != NULL &&
         !MiIsBalancerThread())
     {
@@ -405,8 +378,34 @@
 
       if (Status == STATUS_WAIT_0 || Status == STATUS_WAIT_1)
       {
-          ULONG InitialTarget = 0;
-
+        ULONG InitialTarget = 0;
+
+#if (_MI_PAGING_LEVELS == 2)
+        if(!MiIsBalancerThread())
+        {
+            /* Clean up the unused PDEs */
+            ULONG_PTR Address;
+            PEPROCESS Process = PsGetCurrentProcess();
+
+            /* Acquire PFN lock */
+            KIRQL OldIrql = KeAcquireQueuedSpinLock(LockQueuePfnLock);
+            PMMPDE pointerPde;
+            for(Address = (ULONG_PTR)MI_LOWEST_VAD_ADDRESS;
+                Address < (ULONG_PTR)MM_HIGHEST_VAD_ADDRESS;
+                Address += (PAGE_SIZE * PTE_COUNT))
+            {
+                if(MmWorkingSetList->UsedPageTableEntries[MiGetPdeOffset(Address)] == 0)
+                {
+                    pointerPde = MiAddressToPde(Address);
+                    if(pointerPde->u.Hard.Valid)
+                        MiDeletePte(pointerPde, MiPdeToPte(pointerPde), Process, NULL);
+                    ASSERT(pointerPde->u.Hard.Valid == 0);
+                }
+            }
+            /* Release lock */
+            KeReleaseQueuedSpinLock(LockQueuePfnLock, OldIrql);
+        }
+#endif
           do
           {
               ULONG OldTarget = InitialTarget;




More information about the Ros-diffs mailing list