kernel: heap: Add allocation metadata to allocated_bytes
The allocated_bytes were missing the allocation metadata. Because of that the sum of free_bytes and allocated_bytes doesn't remain constant after each allocation. This convention doesn't match glibc's behavior. This commit changes the chunksz_to_bytes function to include the metadata in the calculation. The analysis of the mallinfo2 function from glibc has been done in #92392 Pull Request. Signed-off-by: Krzysztof Sychla <ksychla@antmicro.com>
This commit is contained in:
parent
b478cd8f37
commit
a51d3c0f74
@ -255,7 +255,7 @@ static inline chunksz_t min_chunk_size(struct z_heap *h)
|
||||
|
||||
static inline size_t chunksz_to_bytes(struct z_heap *h, chunksz_t chunksz_in)
|
||||
{
|
||||
return chunksz_in * CHUNK_UNIT - chunk_header_bytes(h);
|
||||
return chunksz_in * CHUNK_UNIT;
|
||||
}
|
||||
|
||||
static inline int bucket_idx(struct z_heap *h, chunksz_t sz)
|
||||
|
||||
@ -9,8 +9,8 @@ common:
|
||||
type: multi_line
|
||||
ordered: true
|
||||
regex:
|
||||
- ".*allocated 15.,.*"
|
||||
- ".*allocated 10.,.*"
|
||||
- ".*allocated 16.,.*"
|
||||
- ".*allocated 1..,.*"
|
||||
- ".*allocated 0, free ..., max allocated ..., heap size 256.*"
|
||||
tests:
|
||||
sample.basic.sys_heap:
|
||||
|
||||
Loading…
Reference in New Issue
Block a user