Fix rallocx() sampling code to not eagerly commit sampler update.
rallocx() for an alignment-constrained request may end up with a smaller-than-worst-case size if in-place reallocation succeeds due to serendipitous alignment. In such cases, sampling may not happen.
This commit is contained in:
parent
20cd2de5ef
commit
fa09fe798a
@ -2222,7 +2222,7 @@ irallocx_prof(tsd_t *tsd, void *old_ptr, size_t old_usize, size_t size,
|
|||||||
|
|
||||||
prof_active = prof_active_get_unlocked();
|
prof_active = prof_active_get_unlocked();
|
||||||
old_tctx = prof_tctx_get(tsd_tsdn(tsd), old_ptr);
|
old_tctx = prof_tctx_get(tsd_tsdn(tsd), old_ptr);
|
||||||
tctx = prof_alloc_prep(tsd, *usize, prof_active, true);
|
tctx = prof_alloc_prep(tsd, *usize, prof_active, false);
|
||||||
if (unlikely((uintptr_t)tctx != (uintptr_t)1U)) {
|
if (unlikely((uintptr_t)tctx != (uintptr_t)1U)) {
|
||||||
p = irallocx_prof_sample(tsd, old_ptr, old_usize, *usize,
|
p = irallocx_prof_sample(tsd, old_ptr, old_usize, *usize,
|
||||||
alignment, zero, tcache, arena, tctx);
|
alignment, zero, tcache, arena, tctx);
|
||||||
@ -2231,7 +2231,7 @@ irallocx_prof(tsd_t *tsd, void *old_ptr, size_t old_usize, size_t size,
|
|||||||
tcache, arena);
|
tcache, arena);
|
||||||
}
|
}
|
||||||
if (unlikely(p == NULL)) {
|
if (unlikely(p == NULL)) {
|
||||||
prof_alloc_rollback(tsd, tctx, true);
|
prof_alloc_rollback(tsd, tctx, false);
|
||||||
return (NULL);
|
return (NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2246,7 +2246,7 @@ irallocx_prof(tsd_t *tsd, void *old_ptr, size_t old_usize, size_t size,
|
|||||||
*/
|
*/
|
||||||
*usize = isalloc(tsd_tsdn(tsd), p, config_prof);
|
*usize = isalloc(tsd_tsdn(tsd), p, config_prof);
|
||||||
}
|
}
|
||||||
prof_realloc(tsd, p, *usize, tctx, prof_active, true, old_ptr,
|
prof_realloc(tsd, p, *usize, tctx, prof_active, false, old_ptr,
|
||||||
old_usize, old_tctx);
|
old_usize, old_tctx);
|
||||||
|
|
||||||
return (p);
|
return (p);
|
||||||
|
Loading…
Reference in New Issue
Block a user