diff --git a/src/snmalloc/backend/backend.h b/src/snmalloc/backend/backend.h
index 04a0fd0..be498f4 100644
--- a/src/snmalloc/backend/backend.h
+++ b/src/snmalloc/backend/backend.h
@@ -117,24 +117,39 @@ namespace snmalloc
}
// Global range of memory
- using StatsR = StatsRange<
+ using GlobalR = GlobalRange<
LargeBuddyRange>;
- using GlobalR = GlobalRange;
#ifdef SNMALLOC_META_PROTECTED
+ // Introduce two global ranges, so we don't mix Object and Meta
+ using CentralObectRange = GlobalRange<
+ LargeBuddyRange>;
+ using CentralMetaRange = GlobalRange, // Use SubRange to introduce guard pages.
+ 24,
+ bits::BITS - 1,
+ Pagemap,
+ MinBaseSizeBits()>>;
+
// Source for object allocations
- using ObjectRange =
- LargeBuddyRange, 21, 21, Pagemap>;
- // Set up protected range for metadata
- using SubR = CommitRange, PAL>;
- using MetaRange =
- SmallBuddyRange>;
- using GlobalMetaRange = GlobalRange;
+ using StatsObject = StatsRange>;
+ using ObjectRange = LargeBuddyRange;
+ using StatsR = StatsObject;
+
+ using StatsRMeta = StatsRange>;
+
+ using MetaRange = SmallBuddyRange<
+ LargeBuddyRange>;
+ // Create global range that can service small meta-data requests.
+ // Don't want to add this to the CentralMetaRange to move Commit outside the
+ // lock on the common case.
+ using GlobalMetaRange = GlobalRange>;
#else
// Source for object allocations and metadata
// No separation between the two
+ using StatsR = StatsRange;
using ObjectRange = SmallBuddyRange<
- LargeBuddyRange, 21, 21, Pagemap>>;
+ LargeBuddyRange, 21, 21, Pagemap>>;
using GlobalMetaRange = GlobalRange;
#endif
@@ -307,13 +322,23 @@ namespace snmalloc
static size_t get_current_usage()
{
StatsR stats_state;
- return stats_state.get_current_usage();
+ auto result = stats_state.get_current_usage();
+#ifdef SNMALLOC_PROTECT_METADATA
+ StatsRMeta stats_state_meta;
+ result += stats_state_meta.get_current_usage();
+#endif
+ return result;
}
static size_t get_peak_usage()
{
StatsR stats_state;
- return stats_state.get_peak_usage();
+ auto result = stats_state.get_peak_usage();
+#ifdef SNMALLOC_PROTECT_METADATA
+ StatsRMeta stats_state_meta;
+ result += stats_state_meta.get_peak_usage();
+#endif
+ return result;
}
};
} // namespace snmalloc