diff options
| author | Jason Evans <jasone@canonware.com> | 2017-02-13 01:03:46 (GMT) |
|---|---|---|
| committer | Jason Evans <jasone@canonware.com> | 2017-02-16 17:39:46 (GMT) |
| commit | fa2d64c94b07ee21a0f6f44b9fe6e3bbefa51c6c (patch) | |
| tree | 3b2e28716d705f3298c6bf7cd74ff0e9ff018bce /src | |
| parent | b779522b9b81f8a53a1f147968a890af8664b213 (diff) | |
| download | jemalloc-fa2d64c94b07ee21a0f6f44b9fe6e3bbefa51c6c.zip jemalloc-fa2d64c94b07ee21a0f6f44b9fe6e3bbefa51c6c.tar.gz jemalloc-fa2d64c94b07ee21a0f6f44b9fe6e3bbefa51c6c.tar.bz2 | |
Convert arena->prof_accumbytes synchronization to atomics.
Diffstat (limited to 'src')
| -rw-r--r-- | src/arena.c | 18 | ||||
| -rw-r--r-- | src/prof.c | 14 | ||||
| -rw-r--r-- | src/tcache.c | 2 |
3 files changed, 19 insertions, 15 deletions
diff --git a/src/arena.c b/src/arena.c index 345c57d..40db9d1 100644 --- a/src/arena.c +++ b/src/arena.c @@ -1148,19 +1148,7 @@ arena_prof_promote(tsdn_t *tsdn, extent_t *extent, const void *ptr, extent_usize_set(extent, usize); - /* - * Cancel out as much of the excessive prof_accumbytes increase as - * possible without underflowing. Interval-triggered dumps occur - * slightly more often than intended as a result of incomplete - * canceling. - */ - malloc_mutex_lock(tsdn, &arena->lock); - if (arena->prof_accumbytes >= LARGE_MINCLASS - usize) { - arena->prof_accumbytes -= LARGE_MINCLASS - usize; - } else { - arena->prof_accumbytes = 0; - } - malloc_mutex_unlock(tsdn, &arena->lock); + prof_accum_cancel(tsdn, &arena->prof_accum, usize); assert(isalloc(tsdn, extent, ptr) == usize); } @@ -1574,7 +1562,9 @@ arena_new(tsdn_t *tsdn, unsigned ind, extent_hooks_t *extent_hooks) { } if (config_prof) { - arena->prof_accumbytes = 0; + if (prof_accum_init(tsdn, &arena->prof_accum)) { + goto label_error; + } } if (config_cache_oblivious) { @@ -1753,6 +1753,20 @@ prof_fdump(void) { prof_dump(tsd, false, filename, opt_prof_leak); } +bool +prof_accum_init(tsdn_t *tsdn, prof_accum_t *prof_accum) { + cassert(config_prof); + +#ifndef JEMALLOC_ATOMIC_U64 + if (malloc_mutex_init(&prof_accum->mtx, "prof_accum", + WITNESS_RANK_PROF_ACCUM)) { + return true; + } +#endif + prof_accum->accumbytes = 0; + return false; +} + void prof_idump(tsdn_t *tsdn) { tsd_t *tsd; diff --git a/src/tcache.c b/src/tcache.c index 94c4570..f38c2d5 100644 --- a/src/tcache.c +++ b/src/tcache.c @@ -200,7 +200,7 @@ tcache_bin_flush_large(tsd_t *tsd, tcache_bin_t *tbin, szind_t binind, } if ((config_prof || config_stats) && locked_arena == arena) { if (config_prof) { - idump = arena_prof_accum_locked(arena, + idump = arena_prof_accum(tsd_tsdn(tsd), arena, tcache->prof_accumbytes); tcache->prof_accumbytes = 0; } |
