Fix irallocx_prof() sample logic.

Fix irallocx_prof() sample logic to only update the threshold counter
after it knows what size the allocation ended up being.  This regression
was caused by 6e73dc194e (Fix a profile
sampling race.), which did not make it into any releases prior to this
fix.
This commit is contained in:
Jason Evans 2014-09-11 17:04:03 -07:00
parent 9c640bfdd4
commit c3e9e7b041

View File

@ -1582,7 +1582,7 @@ irallocx_prof(void *oldptr, size_t old_usize, size_t size, size_t alignment,
prof_tctx_t *old_tctx, *tctx; prof_tctx_t *old_tctx, *tctx;
old_tctx = prof_tctx_get(oldptr); old_tctx = prof_tctx_get(oldptr);
tctx = prof_alloc_prep(*usize, true); tctx = prof_alloc_prep(*usize, false);
if (unlikely((uintptr_t)tctx != (uintptr_t)1U)) { if (unlikely((uintptr_t)tctx != (uintptr_t)1U)) {
p = irallocx_prof_sample(oldptr, size, alignment, *usize, zero, p = irallocx_prof_sample(oldptr, size, alignment, *usize, zero,
try_tcache_alloc, try_tcache_dalloc, arena, tctx); try_tcache_alloc, try_tcache_dalloc, arena, tctx);
@ -1591,7 +1591,7 @@ irallocx_prof(void *oldptr, size_t old_usize, size_t size, size_t alignment,
try_tcache_dalloc, arena); try_tcache_dalloc, arena);
} }
if (unlikely(p == NULL)) { if (unlikely(p == NULL)) {
prof_alloc_rollback(tctx, true); prof_alloc_rollback(tctx, false);
return (NULL); return (NULL);
} }
@ -1606,7 +1606,7 @@ irallocx_prof(void *oldptr, size_t old_usize, size_t size, size_t alignment,
*/ */
*usize = isalloc(p, config_prof); *usize = isalloc(p, config_prof);
} }
prof_realloc(p, *usize, tctx, true, old_usize, old_tctx); prof_realloc(p, *usize, tctx, false, old_usize, old_tctx);
return (p); return (p);
} }