[NTOS:MM] Fix integer arithmetics

This commit is contained in:
Jérôme Gardou 2021-03-22 10:01:39 +01:00
parent 4cd92f0d01
commit d1d1260f5f

View file

@ -29,8 +29,6 @@
* 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
{
@ -1636,7 +1634,7 @@ Retry:
// which implies a massive number of concurrent big pool allocations.
//
ExpPoolBigEntriesInUse++;
if ((i >= 16) && (ExpPoolBigEntriesInUse > (TableSize * POOL_BIG_TABLE_HIGH_THRESHOLD)))
if ((i >= 16) && (ExpPoolBigEntriesInUse > (TableSize * (POOL_BIG_TABLE_USE_RATE - 1) / POOL_BIG_TABLE_USE_RATE)))
{
DPRINT("Attempting expansion since we now have %lu entries\n",
ExpPoolBigEntriesInUse);
@ -1750,7 +1748,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 / POOL_BIG_TABLE_LOW_THRESHOLD))
if (ExpPoolBigEntriesInUse < (PoolBigPageTableSize / (POOL_BIG_TABLE_USE_RATE * 2)))
{
/* Shrink the table. */
ExpReallocateBigPageTable(OldIrql, TRUE);