summaryrefslogtreecommitdiffstats
path: root/include/jemalloc
diff options
context:
space:
mode:
authorJason Evans <jasone@canonware.com>2016-02-27 20:34:50 (GMT)
committerJason Evans <jasone@canonware.com>2016-02-27 23:35:52 (GMT)
commit40ee9aa9577ea5eb6616c10b9e6b0fa7e6796821 (patch)
treeac03f4a2b3b71583a158a3d2fb1dfed754b04a64 /include/jemalloc
parent14be4a7ccad0582ab0427e61273d81ff0a5822e7 (diff)
downloadjemalloc-40ee9aa9577ea5eb6616c10b9e6b0fa7e6796821.zip
jemalloc-40ee9aa9577ea5eb6616c10b9e6b0fa7e6796821.tar.gz
jemalloc-40ee9aa9577ea5eb6616c10b9e6b0fa7e6796821.tar.bz2
Fix stats.cactive accounting regression.
Fix stats.cactive accounting to always increase/decrease by multiples of the chunk size, even for huge size classes that are not multiples of the chunk size, e.g. {2.5, 3, 3.5, 5, 7} MiB with 2 MiB chunk size. This regression was introduced by 155bfa7da18cab0d21d87aa2dce4554166836f5d (Normalize size classes.) and first released in 4.0.0. This resolves #336.
Diffstat (limited to 'include/jemalloc')
-rw-r--r--include/jemalloc/internal/stats.h14
1 files changed, 12 insertions, 2 deletions
diff --git a/include/jemalloc/internal/stats.h b/include/jemalloc/internal/stats.h
index c91dba9..705903a 100644
--- a/include/jemalloc/internal/stats.h
+++ b/include/jemalloc/internal/stats.h
@@ -167,15 +167,25 @@ stats_cactive_get(void)
JEMALLOC_INLINE void
stats_cactive_add(size_t size)
{
+ UNUSED size_t cactive;
- atomic_add_z(&stats_cactive, size);
+ assert(size > 0);
+ assert((size & chunksize_mask) == 0);
+
+ cactive = atomic_add_z(&stats_cactive, size);
+ assert(cactive - size < cactive);
}
JEMALLOC_INLINE void
stats_cactive_sub(size_t size)
{
+ UNUSED size_t cactive;
+
+ assert(size > 0);
+ assert((size & chunksize_mask) == 0);
- atomic_sub_z(&stats_cactive, size);
+ cactive = atomic_sub_z(&stats_cactive, size);
+ assert(cactive + size > cactive);
}
#endif