[PATCH v2 3/3] malloc: limit when to allow to free chunks to tcache
Wilco Dijkstra
Wilco.Dijkstra@arm.com
Fri Dec 6 16:10:17 GMT 2024
Hi Cupertino,
I don't think changing the _int_free interface makes sense - you can directly
call _int_free_chunk from sysmalloc. In principle it makes sense to abstract
some of the code needed for this and add an interface for creating internal
free chunks. But we shouldn't abuse _int_free for that.
@@ -5298,7 +5298,7 @@ _int_realloc (mstate av, mchunkptr oldp, INTERNAL_SIZE_T oldsize,
(av != &main_arena ? NON_MAIN_ARENA : 0));
/* Mark remainder as inuse so free() won't complain */
set_inuse_bit_at_offset (remainder, remainder_size);
- _int_free (av, remainder, 1);
+ _int_free (av, remainder, 1, 0);
}
And this case is splitting an existing block in realloc, why would you want to
avoid tcache here but not in the "allocate, copy, free" above?
It also makes sense to add an interface for splitting a chunk so that we can improve
the implementation. Eg. using a larger MINSIZE or percentage of original size before
splitting in order to avoid fragmenting a large chunk into lots of useless tiny ones.
Cheers,
Wilco
More information about the Libc-alpha
mailing list