[PATCH] malloc: Move mmap code out of __libc_free hotpath

Wilco Dijkstra Wilco.Dijkstra@arm.com
Wed Mar 26 17:06:54 GMT 2025


Hi DJ,

> Wilco Dijkstra <Wilco.Dijkstra@arm.com> writes:
>>> ... the rest of this looks ok, but it leaves _libc_free and _int_free as
>>> being very small functions.  Do we need them?  Or are we relying on the
>>> inlining to make them efficient?
>>
>> No we don't need them - the next step is move _int_free-* into __libc_free,
>> simplify the code and use a similar tailcall approach as __libc_malloc. This
>> gives similar speedups as malloc!
>
> Does this imply that the tcache stuff will only live in __libc_free and
> nothing else will populate tcache from internally?

Yes, for free there doesn't seem to be a need for another interface that frees into
tcache besides __libc_free. On current trunk the _int_free functions are used once.
So basically there is no need to use _int_free, either you want tcache and thus use
__libc_free, or if you don't, use _int_free_chunk. Note tcache_thread_shutdown
calls __libc_free eventhough it should be calling _int_free_chunk and then has to
jump through hoops to avoid infinite recursion...

Cheers,
Wilco


More information about the Libc-alpha mailing list