Convert remaining arena_stats_t fields to atomics

These were all size_ts, so we have atomics support for them on all platforms, so
the conversion is straightforward.

Left non-atomic is curlextents, which AFAICT is not used atomically anywhere.
This commit is contained in:
David Goldblatt
2017-03-13 16:18:40 -07:00
committed by David Goldblatt
parent 4fc2acf5ae
commit ee202efc79
4 changed files with 93 additions and 57 deletions

View File

@@ -19,17 +19,17 @@ arena_ind_get(const arena_t *arena) {
JEMALLOC_INLINE void
arena_internal_add(arena_t *arena, size_t size) {
atomic_add_zu(&arena->stats.internal, size);
atomic_fetch_add_zu(&arena->stats.internal, size, ATOMIC_RELAXED);
}
JEMALLOC_INLINE void
arena_internal_sub(arena_t *arena, size_t size) {
atomic_sub_zu(&arena->stats.internal, size);
atomic_fetch_sub_zu(&arena->stats.internal, size, ATOMIC_RELAXED);
}
JEMALLOC_INLINE size_t
arena_internal_get(arena_t *arena) {
return atomic_read_zu(&arena->stats.internal);
return atomic_load_zu(&arena->stats.internal, ATOMIC_RELAXED);
}
JEMALLOC_INLINE bool

View File

@@ -88,7 +88,7 @@ struct arena_stats_s {
#endif
/* Number of bytes currently mapped, excluding retained memory. */
size_t mapped; /* Partially derived. */
atomic_zu_t mapped; /* Partially derived. */
/*
* Number of bytes currently retained as a side effect of munmap() being
@@ -96,7 +96,7 @@ struct arena_stats_s {
* always decommitted or purged), but they are excluded from the mapped
* statistic (above).
*/
size_t retained; /* Derived. */
atomic_zu_t retained; /* Derived. */
/*
* Total number of purge sweeps, total number of madvise calls made,
@@ -107,17 +107,17 @@ struct arena_stats_s {
arena_stats_u64_t nmadvise;
arena_stats_u64_t purged;
size_t base; /* Derived. */
size_t internal;
size_t resident; /* Derived. */
atomic_zu_t base; /* Derived. */
atomic_zu_t internal;
atomic_zu_t resident; /* Derived. */
size_t allocated_large; /* Derived. */
atomic_zu_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. */
atomic_zu_t tcache_bytes; /* Derived. */
/* One element for each large size class. */
malloc_large_stats_t lstats[NSIZES - NBINS];