fixup! tlsf: support on-demand requesting memory from external store
PATCH 1/1 fixup! tlsf: support on-demand requesting memory from external store
tlsf: fix misaccounting in request_store feature
A TLSF pool itself has overhead in the form of tlsf_pool_overhead() that's distinct from the struct pool_entry. Adding a helper that returns this total overhead allows us also to use roundup_pow_of_two(), which previously issues a warning on clang about sizeof(sizeof(...)) looking strange.
Another issues is that request_store was not explicitly zeroed leading to issues on OOM situations, which is remedied as well.
--- common/tlsf.c | 1 + common/tlsf_malloc.c | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-)
common/tlsf.c +1 -0
@@ -654,6 +654,7 @@ static void control_construct(control_t* control) control->block_null.next_free = &control->block_null; control->block_null.prev_free = &control->block_null; + control->request_store =NULL ; control->fl_bitmap =0 ;for (i =0 ; i <FL_INDEX_COUNT ; ++i) {
common/tlsf_malloc.c +6 -1
@@ -27,6 +27,11 @@ struct pool_entry {static LIST_HEAD (mem_pool_list); +static inline size_t mem_pool_overhead (void ) +{ +return sizeof (struct pool_entry ) +tlsf_pool_overhead (); +} +void *malloc (size_t bytes) {void *mem;
@@ -132,7 +137,7 @@ static void tlsf_request_store(tlsf_t tlsf, size_t bytes) {size_t size; - size =__roundup_pow_of_two (bytes +sizeof (struct pool_entry )); + size =roundup_pow_of_two (bytes +mem_pool_overhead ());malloc_request_store (max_t (size_t,SZ_8M , size)); }
Signature · 1 line
2.47.3
Sascha Hauer
AppliedQuoted 9 lines · Ahmad Fatoum
tlsf: fix misaccounting in
request_storefeatureA TLSF pool itself has overhead in the form of
tlsf_pool_overhead()that's distinct from the structpool_entry. Adding a helper that returns this total overhead allows us also to useroundup_pow_of_two(), which previously issues a warning on clang about sizeof(sizeof(...)) looking strange.[...]
Applied, thanks!
[1/1] fixup! tlsf: support on-demand requesting memory from external store
https://git.pengutronix.de/cgit/barebox/commit/?id=78cd84652672 (link may not be stable)
Best regards,
Signature · 1 line
Sascha Hauer <[email protected]>