From d6e89b7c60eecfe40a6325c911d4c311795c5ede Mon Sep 17 00:00:00 2001 From: David Chisnall Date: Mon, 25 Feb 2019 10:42:22 +0000 Subject: [PATCH] Fix Matt's code review comments. --- src/mem/allocconfig.h | 2 +- src/mem/largealloc.h | 12 +++++++++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/mem/allocconfig.h b/src/mem/allocconfig.h index d97d7cf..f80690b 100644 --- a/src/mem/allocconfig.h +++ b/src/mem/allocconfig.h @@ -65,7 +65,7 @@ namespace snmalloc */ DecommitNone, /** - * Decommit superslabs when they are no entirely empty. + * Decommit superslabs when they are entirely empty. */ DecommitSuper, /** diff --git a/src/mem/largealloc.h b/src/mem/largealloc.h index 5ca8cd7..3bc2359 100644 --- a/src/mem/largealloc.h +++ b/src/mem/largealloc.h @@ -91,6 +91,10 @@ namespace snmalloc for (size_t large_class = 0; large_class < NUM_LARGE_CLASSES; large_class++) { + if (!PAL::expensive_low_memory_check()) + { + break; + } size_t rsize = ((size_t)1 << SUPERSLAB_BITS) << large_class; size_t decommit_size = rsize - OS_PAGE_SIZE; // Grab all of the chunks of this size class. @@ -112,7 +116,6 @@ namespace snmalloc slab = next; } } - lazy_decommit_guard.clear(); } @@ -218,9 +221,12 @@ namespace snmalloc // update) let them win. do { - last_low_memory_epoch.compare_exchange_strong(old_epoch, new_epoch); + if (last_low_memory_epoch.compare_exchange_strong( + old_epoch, new_epoch)) + { + lazy_decommit(); + } } while (old_epoch <= new_epoch); - lazy_decommit(); } } #endif