diff options
author | Jason Evans <je@fb.com> | 2011-03-14 16:42:26 -0700 |
---|---|---|
committer | Jason Evans <je@fb.com> | 2011-03-14 16:42:26 -0700 |
commit | ad11ee6a3416e8d234c35670f20687d17545c09f (patch) | |
tree | 40ca578d2c0e1597d17caf0ca7ea6a552d64e1da /jemalloc/src | |
parent | e27d134efc8609e3f95e4ec13f605ddcb5eb6ca6 (diff) | |
parent | 0e4d0d13f9beb8857bb377f41b4fbd327d3a0cbd (diff) | |
download | jemalloc-2.1.3.tar.gz |
Merge branch 'dev'2.1.3
Diffstat (limited to 'jemalloc/src')
-rw-r--r-- | jemalloc/src/ctl.c | 4 | ||||
-rw-r--r-- | jemalloc/src/tcache.c | 19 |
2 files changed, 21 insertions, 2 deletions
diff --git a/jemalloc/src/ctl.c b/jemalloc/src/ctl.c index c37b4e75..1b28da47 100644 --- a/jemalloc/src/ctl.c +++ b/jemalloc/src/ctl.c @@ -1114,8 +1114,8 @@ thread_arena_ctl(const size_t *mib, size_t miblen, void *oldp, size_t *oldlenp, unsigned newind, oldind; newind = oldind = choose_arena()->ind; - WRITE(oldind, unsigned); - READ(newind, unsigned); + WRITE(newind, unsigned); + READ(oldind, unsigned); if (newind != oldind) { arena_t *arena; diff --git a/jemalloc/src/tcache.c b/jemalloc/src/tcache.c index cbbe7a11..e9b067d4 100644 --- a/jemalloc/src/tcache.c +++ b/jemalloc/src/tcache.c @@ -58,6 +58,9 @@ tcache_bin_flush_small(tcache_bin_t *tbin, size_t binind, unsigned rem void *flush, *deferred, *ptr; unsigned i, nflush, ndeferred; bool first_pass; +#ifdef JEMALLOC_STATS + bool merged_stats = false; +#endif assert(binind < nbins); assert(rem <= tbin->ncached); @@ -82,6 +85,8 @@ tcache_bin_flush_small(tcache_bin_t *tbin, size_t binind, unsigned rem malloc_mutex_lock(&bin->lock); #ifdef JEMALLOC_STATS if (arena == tcache->arena) { + assert(merged_stats == false); + merged_stats = true; bin->stats.nflushes++; bin->stats.nrequests += tbin->tstats.nrequests; tbin->tstats.nrequests = 0; @@ -119,6 +124,20 @@ tcache_bin_flush_small(tcache_bin_t *tbin, size_t binind, unsigned rem first_pass = false; } } +#ifdef JEMALLOC_STATS + if (merged_stats == false) { + /* + * The flush loop didn't happen to flush to this thread's + * arena, so the stats didn't get merged. Manually do so now. + */ + arena_bin_t *bin = &tcache->arena->bins[binind]; + malloc_mutex_lock(&bin->lock); + bin->stats.nflushes++; + bin->stats.nrequests += tbin->tstats.nrequests; + tbin->tstats.nrequests = 0; + malloc_mutex_unlock(&bin->lock); + } +#endif tbin->ncached = rem; if (tbin->ncached < tbin->low_water) |