From f38a5a63d56400d2c6dedd035c2af0e5245b6c9c Mon Sep 17 00:00:00 2001 From: Matthew Parkinson Date: Fri, 13 Aug 2021 12:04:19 +0100 Subject: [PATCH] Make threshold for waking always a percentage The threshold for waking is used to ensure that we only use a slab when it has sufficient space that we won't hit the slow path to soon after using this slab. In the checked version, this is also used to give some entropy in layout. Changing this to always be a pertcentage in the checked case increases the effectiveness of the free list to detect OOB write. --- src/mem/sizeclasstable.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/mem/sizeclasstable.h b/src/mem/sizeclasstable.h index 13c3f69..97f224d 100644 --- a/src/mem/sizeclasstable.h +++ b/src/mem/sizeclasstable.h @@ -100,7 +100,11 @@ namespace snmalloc static_cast((slab_mask[sizeclass] + 1) / rsize); waking[sizeclass] = +#ifdef SNMALLOC_CHECK_CLIENT + static_cast(capacity[sizeclass] / 4); +#else static_cast(bits::min((capacity[sizeclass] / 4), 32)); +#endif } for (sizeclass_compress_t sizeclass = NUM_SIZECLASSES;