summaryrefslogtreecommitdiffstats
path: root/include/jemalloc
diff options
context:
space:
mode:
authorDavid Goldblatt <davidgoldblatt@fb.com>2017-03-08 01:57:48 (GMT)
committerDavid Goldblatt <davidtgoldblatt@gmail.com>2017-03-09 05:27:09 (GMT)
commit8adab269721b0271399027d45a8aa6b425e53fd9 (patch)
tree97ab7c5efbd09c5ad0ab60cef13e5e80806eabc0 /include/jemalloc
parentdafadce62205bddac7da1c595c956a69367810ec (diff)
downloadjemalloc-8adab269721b0271399027d45a8aa6b425e53fd9.zip
jemalloc-8adab269721b0271399027d45a8aa6b425e53fd9.tar.gz
jemalloc-8adab269721b0271399027d45a8aa6b425e53fd9.tar.bz2
Convert extents_t's npages field to use C11-style atomics
In the process, we can do some strength reduction, changing the fetch-adds and fetch-subs to be simple loads followed by stores, since the modifications all occur while holding the mutex.
Diffstat (limited to 'include/jemalloc')
-rw-r--r--include/jemalloc/internal/extent_structs.h7
1 files changed, 5 insertions, 2 deletions
diff --git a/include/jemalloc/internal/extent_structs.h b/include/jemalloc/internal/extent_structs.h
index 9ea6972..c14aef8 100644
--- a/include/jemalloc/internal/extent_structs.h
+++ b/include/jemalloc/internal/extent_structs.h
@@ -109,9 +109,12 @@ struct extents_s {
/*
* Page sum for all extents in heaps.
*
- * Synchronization: atomic.
+ * The synchronization here is a little tricky. Modifications to npages
+ * must hold mtx, but reads need not (though, a reader who sees npages
+ * without holding the mutex can't assume anything about the rest of the
+ * state of the extents_t).
*/
- size_t npages;
+ atomic_zu_t npages;
/* All stored extents must be in the same state. */
extent_state_t state;