[PATCH] malloc: Simplify _int_free_chunk
Rocket Ma
marocketbd@gmail.com
Thu Apr 2 17:03:56 GMT 2026
Wilco Dijkstra <Wilco.Dijkstra@arm.com> 于2026年4月2日周四 20:21写道:
> It's possible - but note realloc() doesn't use tcache on allocation (and hasn't
> historically). In general it seems like a bad idea to keep the arena lock while
> doing memcpy (or tagging) of large blocks since that can block other threads.
> If we moved the locking into _int_realloc(), we could unlock if we can't reuse
> the existing/next block, and then use __libc_malloc/__libc_free so that it can
> use tcache in both cases. We could even avoid locking by doing a speculative
> check.
>
> Do you see any performance issues with realloc()? There are lots of things
> that could be improved - for example it should not split off tiny blocks when
> shrinking, and similarly when growing, it should force a minimum percentage
> of growth.
Oh, that's the reason? Actually I didn't notice that realloc won't use
tcache, and I don't expect that memcpy may lead to lock holding. Sorry
for my ignorance.
I don't run into performance issues, I just wonder why realloc don't
use tcache. Thanks for answering.
Cheers,
Rocket
More information about the Libc-alpha
mailing list