[PATCH] malloc: fix definition for MAX_TCACHE_SMALL_SIZE
Arjun Shankar
arjun@redhat.com
Mon Jul 14 17:39:53 GMT 2025
Hi Cupertino,
> This patch fixes an incorrect definition of MAX_TCACHE_SMALL_SIZE which
> was missed by me and passed through review process.
> Wilco: Thank you for the finding.
So, looking at commit cbfd7988107b27b9ff1d0b57fa2c8f13a932e508 which
added support for large chunk caching:
-# define TCACHE_MAX_BINS 64
-# define MAX_TCACHE_SIZE tidx2usize (TCACHE_MAX_BINS-1)
+# define TCACHE_SMALL_BINS 64
+# define TCACHE_LARGE_BINS 12 /* Up to 4M chunks */
+# define TCACHE_MAX_BINS (TCACHE_SMALL_BINS + TCACHE_LARGE_BINS)
+# define MAX_TCACHE_SMALL_SIZE tidx2usize (TCACHE_MAX_BINS-1)
... looks like the intention was to have TCACHE_SMALL_BINS and
MAX_TCACHE_SMALL_SIZE represent the "default" (non large) chunks and
this definition was a bit of a "typo".
Wilco noticed this here:
https://inbox.sourceware.org/libc-alpha/DB3PR08MB89867BB318B699FAF1D133458361A@DB3PR08MB8986.eurprd08.prod.outlook.com/
This patch looks good to me.
Reviewed-by: Arjun Shankar <arjun@redhat.com>
I'm going to drop the "cover letter" that inadvertently got added as a
commit message when pushing this.
> ---
> malloc/malloc.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/malloc/malloc.c b/malloc/malloc.c
> index 3f91ff44b3..d522617f2b 100644
> --- a/malloc/malloc.c
> +++ b/malloc/malloc.c
> @@ -294,7 +294,7 @@
> # define TCACHE_SMALL_BINS 64
> # define TCACHE_LARGE_BINS 12 /* Up to 4M chunks */
> # define TCACHE_MAX_BINS (TCACHE_SMALL_BINS + TCACHE_LARGE_BINS)
> -# define MAX_TCACHE_SMALL_SIZE tidx2usize (TCACHE_MAX_BINS-1)
> +# define MAX_TCACHE_SMALL_SIZE tidx2usize (TCACHE_SMALL_BINS-1)
OK.
>
> /* Only used to pre-fill the tunables. */
> # define tidx2usize(idx) (((size_t) idx) * MALLOC_ALIGNMENT + MINSIZE - SIZE_SZ)
> --
> 2.30.2
>
--
Arjun Shankar
he/him/his
More information about the Libc-alpha
mailing list