https://git.reactos.org/?p=reactos.git;a=commitdiff;h=4ff5d39edb2b9bf59ed78789b736cb276a6a249b

commit 4ff5d39edb2b9bf59ed78789b736cb276a6a249b
Author:     Jérôme Gardou <[email protected]>
AuthorDate: Thu Mar 18 09:15:48 2021 +0100
Commit:     Jérôme Gardou <[email protected]>
CommitDate: Thu Mar 18 12:24:21 2021 +0100

    [NTOS:MM] Use a define for the big pool table occupation rate
---
 ntoskrnl/mm/ARM3/expool.c | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/ntoskrnl/mm/ARM3/expool.c b/ntoskrnl/mm/ARM3/expool.c
index 95bc21ad822..25ad64c62ae 100644
--- a/ntoskrnl/mm/ARM3/expool.c
+++ b/ntoskrnl/mm/ARM3/expool.c
@@ -22,6 +22,16 @@
 
 #define POOL_BIG_TABLE_ENTRY_FREE 0x1
 
+/*
+ * This defines when we shrink or expand the table.
+ * 3 --> keep the number of used entries in the 33%-66% of the table capacity.
+ * 4 --> 25% - 75%
+ * etc.
+ */
+#define POOL_BIG_TABLE_USE_RATE 4
+#define POOL_BIG_TABLE_LOW_THRESHOLD (POOL_BIG_TABLE_USE_RATE * 2)
+#define POOL_BIG_TABLE_HIGH_THRESHOLD ((POOL_BIG_TABLE_USE_RATE - 1) / 
POOL_BIG_TABLE_USE_RATE)
+
 typedef struct _POOL_DPC_CONTEXT
 {
     PPOOL_TRACKER_TABLE PoolTrackTable;
@@ -1626,7 +1636,7 @@ Retry:
             // which implies a massive number of concurrent big pool 
allocations.
             //
             ExpPoolBigEntriesInUse++;
-            if ((i >= 16) && (ExpPoolBigEntriesInUse > (TableSize * 3 / 4)))
+            if ((i >= 16) && (ExpPoolBigEntriesInUse > (TableSize * 
POOL_BIG_TABLE_HIGH_THRESHOLD)))
             {
                 DPRINT("Attempting expansion since we now have %lu entries\n",
                         ExpPoolBigEntriesInUse);
@@ -1740,7 +1750,7 @@ ExpFindAndRemoveTagBigPages(IN PVOID Va,
 
     /* If reaching 12.5% of the size (or whatever integer rounding gets us to),
      * halve the allocation size, which will get us to 25% of space used. */
-    if (ExpPoolBigEntriesInUse < (PoolBigPageTableSize / 8))
+    if (ExpPoolBigEntriesInUse < (PoolBigPageTableSize / 
POOL_BIG_TABLE_LOW_THRESHOLD))
     {
         /* Shrink the table. */
         ExpReallocateBigPageTable(OldIrql, TRUE);

Reply via email to