Commit in reactos/ntoskrnl on MAIN
mm/balance.c+10-171.29 -> 1.30
ex/sysinfo.c+2-21.42 -> 1.43
include/internal/mm.h-11.82 -> 1.83
+12-20
3 modified files
- Used MmStats.NrFreePages instead of MiNrAvailablePages.

reactos/ntoskrnl/mm
balance.c 1.29 -> 1.30
diff -u -r1.29 -r1.30
--- balance.c	22 Apr 2004 01:57:49 -0000	1.29
+++ balance.c	31 Jul 2004 09:44:35 -0000	1.30
@@ -16,7 +16,7 @@
  *  along with this program; if not, write to the Free Software
  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  */
-/* $Id: balance.c,v 1.29 2004/04/22 01:57:49 jimtabor Exp $
+/* $Id: balance.c,v 1.30 2004/07/31 09:44:35 hbirr Exp $
  *
  * PROJECT:     ReactOS kernel 
  * FILE:        ntoskrnl/mm/balance.c
@@ -48,7 +48,6 @@
 
 MM_MEMORY_CONSUMER MiMemoryConsumers[MC_MAXIMUM];
 static ULONG MiMinimumAvailablePages;
-ULONG MiNrAvailablePages;
 static ULONG MiNrTotalPages;
 static LIST_ENTRY AllocationListHead;
 static KSPIN_LOCK AllocationListLock;
@@ -65,10 +64,10 @@
 
 VOID MmPrintMemoryStatistic(VOID)
 {
-   DbgPrint("MC_CACHE %d, MC_USER %d, MC_PPOOL %d, MC_NPPOOL %d, MiNrAvailablePages %d\n",
+   DbgPrint("MC_CACHE %d, MC_USER %d, MC_PPOOL %d, MC_NPPOOL %d, MmStats.NrFreePages %d\n",
             MiMemoryConsumers[MC_CACHE].PagesUsed, MiMemoryConsumers[MC_USER].PagesUsed,
             MiMemoryConsumers[MC_PPOOL].PagesUsed, MiMemoryConsumers[MC_NPPOOL].PagesUsed,
-            MiNrAvailablePages);
+            MmStats.NrFreePages);
 }
 
 VOID INIT_FUNCTION
@@ -78,7 +77,7 @@
    InitializeListHead(&AllocationListHead);
    KeInitializeSpinLock(&AllocationListLock);
 
-   MiNrAvailablePages = MiNrTotalPages = NrAvailablePages;
+   MiNrTotalPages = NrAvailablePages;
 
    /* Set up targets. */
    MiMinimumAvailablePages = 64;
@@ -104,7 +103,6 @@
    PMM_ALLOCATION_REQUEST Request;
    PLIST_ENTRY Entry;
    KIRQL oldIrql;
-   ULONG OldAvailable;
 
 #if defined(__GNUC__)
 
@@ -113,7 +111,6 @@
 
    if (Page.QuadPart == 0)
 #endif
-
    {
       DPRINT1("Tried to release page zero.\n");
       KEBUGCHECK(0);
@@ -123,8 +120,7 @@
    if (MmGetReferenceCountPage(Page) == 1)
    {
       InterlockedDecrement((LONG *)&MiMemoryConsumers[Consumer].PagesUsed);
-      OldAvailable = InterlockedIncrement((LONG *)&MiNrAvailablePages);
-      if (IsListEmpty(&AllocationListHead) || OldAvailable + 1 < MiMinimumAvailablePages)
+      if (IsListEmpty(&AllocationListHead) || MmStats.NrFreePages < MiMinimumAvailablePages)
       {
          KeReleaseSpinLock(&AllocationListLock, oldIrql);
          MmDereferencePage(Page);
@@ -174,7 +170,7 @@
    ULONG NrFreedPages;
    NTSTATUS Status;
 
-   Target = (MiMinimumAvailablePages - MiNrAvailablePages) + MiPagesRequired;
+   Target = (MiMinimumAvailablePages - MmStats.NrFreePages) + MiPagesRequired;
    Target = max(Target, (LONG) MiMinimumPagesPerRun);
 
    for (i = 0; i < MC_MAXIMUM && Target > 0; i++)
@@ -203,7 +199,6 @@
                             PHYSICAL_ADDRESS* AllocatedPage)
 {
    ULONG OldUsed;
-   ULONG OldAvailable;
    PHYSICAL_ADDRESS Page;
    KIRQL oldIrql;
 
@@ -222,7 +217,6 @@
       MiTrimMemoryConsumer(Consumer);
    }
 
-   OldAvailable = InterlockedDecrement((LONG *)&MiNrAvailablePages);
    /*
     * Allocate always memory for the non paged pool and for the pager thread. 
     */
@@ -241,7 +235,7 @@
          KEBUGCHECK(0);
       }
       *AllocatedPage = Page;
-      if (OldAvailable < MiMinimumAvailablePages &&
+      if (MmStats.NrFreePages <= MiMinimumAvailablePages &&
             MiBalancerThreadHandle != NULL)
       {
          KeSetEvent(&MiBalancerEvent, IO_NO_INCREMENT, FALSE);
@@ -252,13 +246,12 @@
    /*
     * Make sure we don't exceed global targets.
     */
-   if (OldAvailable < MiMinimumAvailablePages)
+   if (MmStats.NrFreePages <= MiMinimumAvailablePages)
    {
       MM_ALLOCATION_REQUEST Request;
 
       if (!CanWait)
       {
-         InterlockedIncrement((LONG *)&MiNrAvailablePages);
          InterlockedDecrement((LONG *)&MiMemoryConsumers[Consumer].PagesUsed);
          return(STATUS_NO_MEMORY);
       }
@@ -357,7 +350,7 @@
       {
          /* MiBalancerEvent */
          CHECKPOINT;
-         while (MiNrAvailablePages < MiMinimumAvailablePages + 5)
+         while (MmStats.NrFreePages < MiMinimumAvailablePages + 5)
          {
             for (i = 0; i < MC_MAXIMUM; i++)
             {
@@ -378,7 +371,7 @@
       else if (Status == STATUS_SUCCESS + 1)
       {
          /* MiBalancerTimer */
-         ShouldRun = MiNrAvailablePages < MiMinimumAvailablePages + 5 ? TRUE : FALSE;
+         ShouldRun = MmStats.NrFreePages < MiMinimumAvailablePages + 5 ? TRUE : FALSE;
          for (i = 0; i < MC_MAXIMUM; i++)
          {
             if (MiMemoryConsumers[i].Trim != NULL)

reactos/ntoskrnl/ex
sysinfo.c 1.42 -> 1.43
diff -u -r1.42 -r1.43
--- sysinfo.c	31 Jul 2004 00:14:39 -0000	1.42
+++ sysinfo.c	31 Jul 2004 09:44:36 -0000	1.43
@@ -1,4 +1,4 @@
-/* $Id: sysinfo.c,v 1.42 2004/07/31 00:14:39 jimtabor Exp $
+/* $Id: sysinfo.c,v 1.43 2004/07/31 09:44:36 hbirr Exp $
  *
  * COPYRIGHT:       See COPYING in the top level directory
  * PROJECT:         ReactOS kernel
@@ -409,7 +409,7 @@
 	Spi->WriteOperationCount = IoWriteOperationCount;
 	Spi->OtherOperationCount = IoOtherOperationCount;
 
-	Spi->AvailablePages = MiNrAvailablePages;
+	Spi->AvailablePages = MmStats.NrFreePages;
 /*
         Add up all the used "Commitied" memory + pagefile.
         Not sure this is right. 8^\

reactos/ntoskrnl/include/internal
mm.h 1.82 -> 1.83
diff -u -r1.82 -r1.83
--- mm.h	10 Jul 2004 17:00:59 -0000	1.82
+++ mm.h	31 Jul 2004 09:44:36 -0000	1.83
@@ -13,7 +13,6 @@
 extern ULONG MiFreeSwapPages;
 extern ULONG MiUsedSwapPages;
 extern ULONG MmPagedPoolSize;
-extern ULONG MiNrAvailablePages;
 
 struct _EPROCESS;
 
CVSspam 0.2.8