[NTOS:MM] Use a define for the big pool table occupation rate

This commit is contained in:
Jérôme Gardou 2021-03-18 09:15:48 +01:00 committed by Jérôme Gardou
parent 8494688eeb
commit 4ff5d39edb

View file

@ -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);