[PATCH] malloc: Fix MAX_TCACHE_SMALL_SIZE

Adhemerval Zanella Netto adhemerval.zanella@linaro.org
Fri Aug 1 18:40:51 GMT 2025



On 01/08/25 15:16, DJ Delorie wrote:
> 
> On i386, doesn't this change the bit counting logic here: ?
> 
> static __always_inline size_t
> large_csize2tidx(size_t nb)
> {
>   size_t idx = TCACHE_SMALL_BINS
> 	       + __builtin_clz (MAX_TCACHE_SMALL_SIZE)
> 	       - __builtin_clz (nb);
>   return idx;
> }
> 
> MAX_TCACHE_SMALL_SIZE is 1020 pre-patch, and would be 1024 post-patch...
> 
> [Runs lots of tests]
> 
> It does, but that fixes a bug where the bin between small and large
> tcache didn't get used, and the 64-bit build shows no change in bin
> allocations.
> 
> LGTM
> Reviewed-by: DJ Delorie <dj@redhat.com>
> 
> [Looks at all his tests]
> 
> I really want to extend the malloc_info() output to include values for
> all the macros and ranges for all the bins...
> 

As a side note, can we move malloc_info out of malloc.c? It is really
annoying that static linking malloc requires to pull a lot of stdio.


More information about the Libc-alpha mailing list