diff options
author | David Goldblatt <davidgoldblatt@fb.com> | 2017-03-08 23:56:31 (GMT) |
---|---|---|
committer | David Goldblatt <davidtgoldblatt@gmail.com> | 2017-03-14 01:22:33 (GMT) |
commit | 4fc2acf5aef9ea8fe7e2dd39ee8b6a5050c5ff7f (patch) | |
tree | a36fa8713ab2e251b83ca787f30daeeb30454f66 /include/jemalloc | |
parent | 26d23da6cd91e4d7d6210c89de5194dedf0f0f60 (diff) | |
download | jemalloc-4fc2acf5aef9ea8fe7e2dd39ee8b6a5050c5ff7f.zip jemalloc-4fc2acf5aef9ea8fe7e2dd39ee8b6a5050c5ff7f.tar.gz jemalloc-4fc2acf5aef9ea8fe7e2dd39ee8b6a5050c5ff7f.tar.bz2 |
Switch atomic uint64_ts in arena_stats_t to C11 atomics
I expect this to be the trickiest conversion we will see, since we want atomics
on 64-bit platforms, but are also always able to piggyback on some sort of
external synchronization on non-64 bit platforms.
Diffstat (limited to 'include/jemalloc')
-rw-r--r-- | include/jemalloc/internal/stats_structs.h | 37 |
1 files changed, 22 insertions, 15 deletions
diff --git a/include/jemalloc/internal/stats_structs.h b/include/jemalloc/internal/stats_structs.h index 06ba95f..b64ba2d 100644 --- a/include/jemalloc/internal/stats_structs.h +++ b/include/jemalloc/internal/stats_structs.h @@ -1,6 +1,13 @@ #ifndef JEMALLOC_INTERNAL_STATS_STRUCTS_H #define JEMALLOC_INTERNAL_STATS_STRUCTS_H +#ifdef JEMALLOC_ATOMIC_U64 +typedef atomic_u64_t arena_stats_u64_t; +#else +/* Must hold the arena stats mutex while reading atomically. */ +typedef uint64_t arena_stats_u64_t; +#endif + struct tcache_bin_stats_s { /* * Number of allocation requests that corresponded to the size of this @@ -56,15 +63,15 @@ struct malloc_large_stats_s { * Total number of allocation/deallocation requests served directly by * the arena. */ - uint64_t nmalloc; - uint64_t ndalloc; + arena_stats_u64_t nmalloc; + arena_stats_u64_t ndalloc; /* * Number of allocation requests that correspond to this size class. * This includes requests served by tcache, though tcache only * periodically merges into this counter. */ - uint64_t nrequests; /* Partially derived. */ + arena_stats_u64_t nrequests; /* Partially derived. */ /* Current number of allocations of this size class. */ size_t curlextents; /* Derived. */ @@ -96,18 +103,18 @@ struct arena_stats_s { * and total pages purged in order to keep dirty unused memory under * control. */ - uint64_t npurge; - uint64_t nmadvise; - uint64_t purged; - - size_t base; /* Derived. */ - size_t internal; - size_t resident; /* Derived. */ - - size_t allocated_large; /* Derived. */ - uint64_t nmalloc_large; /* Derived. */ - uint64_t ndalloc_large; /* Derived. */ - uint64_t nrequests_large; /* Derived. */ + arena_stats_u64_t npurge; + arena_stats_u64_t nmadvise; + arena_stats_u64_t purged; + + size_t base; /* Derived. */ + size_t internal; + size_t resident; /* Derived. */ + + size_t allocated_large; /* Derived. */ + arena_stats_u64_t nmalloc_large; /* Derived. */ + arena_stats_u64_t ndalloc_large; /* Derived. */ + arena_stats_u64_t nrequests_large; /* Derived. */ /* Number of bytes cached in tcache associated with this arena. */ size_t tcache_bytes; /* Derived. */ |