aboutsummaryrefslogtreecommitdiff
path: root/src/tcache.c
diff options
context:
space:
mode:
authorJason Evans <je@fb.com>2012-11-13 12:56:27 -0800
committerJason Evans <je@fb.com>2012-11-13 13:47:53 -0800
commita3b3386ddde8048b9d6b54c397bb93da5e806cef (patch)
tree3c5e10d49e9eb914af8e1edcab69fbda1f8d4d0c /src/tcache.c
parent556ddc7fa94f13c388ec6c9d2d54ace250540f2c (diff)
downloadjemalloc-a3b3386ddde8048b9d6b54c397bb93da5e806cef.tar.gz
Avoid arena_prof_accum()-related locking when possible.
Refactor arena_prof_accum() and its callers to avoid arena locking when prof_interval is 0 (as when profiling is disabled). Reported by Ben Maurer.
Diffstat (limited to 'src/tcache.c')
-rw-r--r--src/tcache.c9
1 files changed, 2 insertions, 7 deletions
diff --git a/src/tcache.c b/src/tcache.c
index 47e14f3..7befdc8 100644
--- a/src/tcache.c
+++ b/src/tcache.c
@@ -97,9 +97,7 @@ tcache_bin_flush_small(tcache_bin_t *tbin, size_t binind, unsigned rem,
arena_bin_t *bin = &arena->bins[binind];
if (config_prof && arena == tcache->arena) {
- malloc_mutex_lock(&arena->lock);
arena_prof_accum(arena, tcache->prof_accumbytes);
- malloc_mutex_unlock(&arena->lock);
tcache->prof_accumbytes = 0;
}
@@ -180,7 +178,7 @@ tcache_bin_flush_large(tcache_bin_t *tbin, size_t binind, unsigned rem,
malloc_mutex_lock(&arena->lock);
if ((config_prof || config_stats) && arena == tcache->arena) {
if (config_prof) {
- arena_prof_accum(arena,
+ arena_prof_accum_locked(arena,
tcache->prof_accumbytes);
tcache->prof_accumbytes = 0;
}
@@ -343,11 +341,8 @@ tcache_destroy(tcache_t *tcache)
}
}
- if (config_prof && tcache->prof_accumbytes > 0) {
- malloc_mutex_lock(&tcache->arena->lock);
+ if (config_prof && tcache->prof_accumbytes > 0)
arena_prof_accum(tcache->arena, tcache->prof_accumbytes);
- malloc_mutex_unlock(&tcache->arena->lock);
- }
tcache_size = arena_salloc(tcache, false);
if (tcache_size <= SMALL_MAXCLASS) {