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

Florian Weimer fw@deneb.enyo.de
Mon Mar 24 20:41:21 GMT 2025


* Wilco Dijkstra:

> Currently __libc_free checks for a freed mmap chunk in the fast path.
> Also errno is always saved and restored to preserve it.  Since mmap chunks
> are larger than the largest tcache chunk, it is safe to delay this and
> handle tcache, smallbin and medium bin blocks first.  Move saving of errno
> to cases that actually need it.

I think the “Since mmap chunks are larger than the largest tcache
chunk” part is not correct.  We can fall back to performing mmap for a
smallish allocation.  But I think it's still fine to put such chunks
into tcache.  Maybe add a comment to this effect?


More information about the Libc-alpha mailing list