| #
f288234f |
| 07-Mar-2025 |
Jens Wiklander <jens.wiklander@linaro.org> |
libutils: bget: add free2_sum to struct bpoolset
Add the field free2_sum to struct bpoolset to be used to calculate a metric for heap fragmentation. The value is calculated and kept up to date when
libutils: bget: add free2_sum to struct bpoolset
Add the field free2_sum to struct bpoolset to be used to calculate a metric for heap fragmentation. The value is calculated and kept up to date when compiled with statistics (CFG_WITH_STATS=y) enabled. See xtest and [1] for how to use the new field.
Link: https://asawicki.info/news_1757_a_metric_for_memory_fragmentation [1] Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org> Reviewed-by: Jerome Forissier <jerome.forissier@linaro.org>
show more ...
|
| #
0d4767a9 |
| 17-Oct-2022 |
Zengxx <zengxiaoxu@huawei.com> |
libutils: brel: bugfix memset scope larger than expected
In the case of wipe = true and previous buffer is free, memset the current buffer, rather then current buffer with previous free buffer.
Sig
libutils: brel: bugfix memset scope larger than expected
In the case of wipe = true and previous buffer is free, memset the current buffer, rather then current buffer with previous free buffer.
Signed-off-by: Zengxx <zengxiaoxu@huawei.com> Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org> Reviewed-by: Etienne Carriere <etienne.carriere@linaro.org> Reviewed-by: Guangwei Zhou <zhouguangwei5@huawei.com>
show more ...
|
| #
466162e2 |
| 12-Apr-2022 |
Jens Wiklander <jens.wiklander@linaro.org> |
libutils: refactor heap tagging
Refactors the heap tagging with CFG_CORE_SANITIZE_KADDRESS to use two new hooks maybe_tag_buf() and maybe_untag_buf().
maybe_tag_buf() is called from raw_malloc_retu
libutils: refactor heap tagging
Refactors the heap tagging with CFG_CORE_SANITIZE_KADDRESS to use two new hooks maybe_tag_buf() and maybe_untag_buf().
maybe_tag_buf() is called from raw_malloc_return_hook() which is called after bget(). maybe_untag_buf() is called before brel() is called.
This removes some of the local modifications to bget.c.
Acked-by: Jerome Forissier <jerome.forissier@linaro.org> Acked-by: Etienne Carriere <etienne.carriere@linaro.org> Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
show more ...
|
| #
17967299 |
| 28-Dec-2020 |
Jens Wiklander <jens.wiklander@linaro.org> |
libutil: add hdr_size parameter to bget
Adds a hdr_size parameter to bget(), bgetz() and bgetr(). hdr_size must be a multiple of BGET_HDR_QUANTUM. If hdr_size is larger than 0 the buffer will be all
libutil: add hdr_size parameter to bget
Adds a hdr_size parameter to bget(), bgetz() and bgetr(). hdr_size must be a multiple of BGET_HDR_QUANTUM. If hdr_size is larger than 0 the buffer will be allocated so that the alignment constraints are fulfilled after advancing hdr_size bytes into the returned buffer.
Acked-by: Etienne Carriere <etienne.carriere@linaro.org> Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
show more ...
|
| #
cc5981b2 |
| 28-Dec-2020 |
Jens Wiklander <jens.wiklander@linaro.org> |
libutil: add alignment parameter to bget
Adds alignment parameter to bget(), bgetz() and bgetr(). If alignment is larger then 0 the returned buffer is guaranteed to have an address which is a multip
libutil: add alignment parameter to bget
Adds alignment parameter to bget(), bgetz() and bgetr(). If alignment is larger then 0 the returned buffer is guaranteed to have an address which is a multiple of this value.
The algorithm is basically unchanged, in the way that the memory is still allocated from the end of a free memory block. The difference is in the core implementation in bget() where now alignment of the returned memory is taken into account. If only allocating with the minimum alignment the memory blocks are expected to be allocated in the same pattern.
Acked-by: Etienne Carriere <etienne.carriere@linaro.org> Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
show more ...
|
| #
27e8d08d |
| 27-Dec-2020 |
Jens Wiklander <jens.wiklander@linaro.org> |
Introduce CFG_TA_BGET_TEST
Introduces CFG_TA_BGET_TEST which compiles the integrated bget test suite together with the rest of bget. When enabled, the test entry point is bget_main_test() in libutil
Introduce CFG_TA_BGET_TEST
Introduces CFG_TA_BGET_TEST which compiles the integrated bget test suite together with the rest of bget. When enabled, the test entry point is bget_main_test() in libutils.
Acked-by: Etienne Carriere <etienne.carriere@linaro.org> Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
show more ...
|
| #
4e570655 |
| 13-Feb-2019 |
Jerome Forissier <jerome.forissier@linaro.org> |
libutils: add free_wipe()
Adds function free_wipe(void *ptr) to clear a buffer before returning it to the heap. The pattern used to overwrite the data is 0x55. Users have to #include <stdlib_ext.h>
libutils: add free_wipe()
Adds function free_wipe(void *ptr) to clear a buffer before returning it to the heap. The pattern used to overwrite the data is 0x55. Users have to #include <stdlib_ext.h> to import the declaration.
Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org> Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org> Reviewed-by: Joakim Bech <joakim.bech@linaro.org> Reviewed-by: Etienne Carriere <etienne.carriere@linaro.org>
show more ...
|
| #
7539e8c3 |
| 31-Jan-2019 |
PeiKan Tsai <mark1990301@gmail.com> |
bget: Check for size overflow
Check size overflow to avoid size <= 0 which may be caused by calculation "size += sizeof(struct bhead)" and "size = (size + (SizeQuant - 1)) & (~(SizeQuant - 1))".
Si
bget: Check for size overflow
Check size overflow to avoid size <= 0 which may be caused by calculation "size += sizeof(struct bhead)" and "size = (size + (SizeQuant - 1)) & (~(SizeQuant - 1))".
Signed-off-by: Peikan Tsai <mark1990301@gmail.com> Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org>
show more ...
|
| #
bde8a250 |
| 02-Oct-2018 |
Joakim Bech <joakim.bech@linaro.org> |
pager: enable BestFit allocation when using the pager
When running xtest 6018 we have got panics because of TEE_ERROR_OUT_OF_MEMORY errors when trying to allocate memory (using malloc and calloc). T
pager: enable BestFit allocation when using the pager
When running xtest 6018 we have got panics because of TEE_ERROR_OUT_OF_MEMORY errors when trying to allocate memory (using malloc and calloc). The reason for this seems to be a fragmented heap when running with the pager enabled. By enabling the BestFit algorithm in bget we have seen a much improved use of the heap with a lot less fragmentation. We have been running xtest on QEMU v8 and HiKey 6220 and the performance difference seems to be negligible.
Fixes: https://github.com/OP-TEE/optee_os/issues/2580
Signed-off-by: Joakim Bech <joakim.bech@linaro.org> Tested-by: Joakim Bech <joakim.bech@linaro.org> (HiKey 6220, QEMU v8) Reviewed-by: Jerome Forissier <jerome.forissier@linaro.org> Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org>
show more ...
|
| #
96c1d8c5 |
| 24-Apr-2018 |
Jens Wiklander <jens.wiklander@linaro.org> |
ta: TEE_Malloc() and friend: skips layers
Prior to this patch TEE_Malloc(), TEE_Realloc() and TEE_Free() were using two extra layers implemented on top of the well known malloc(), realloc(), calloc(
ta: TEE_Malloc() and friend: skips layers
Prior to this patch TEE_Malloc(), TEE_Realloc() and TEE_Free() were using two extra layers implemented on top of the well known malloc(), realloc(), calloc() and free() functions. With this patch the extra layers are skipped.
When compiled for user TAs realloc() clears all memory that otherwise would be uninitialized memory since it's required by the spec [1] if TEE_Malloc() is called with the hint TEE_MALLOC_FILL_ZERO. Since that's the only recognized hint in the spec realloc() assumes that it's always needed.
[1] GP TEE Internal Core API Specification v1.1
Reviewed-by: Jerome Forissier <jerome.forissier@linaro.org> Reviewed-by: Etienne Carriere <etienne.carriere@linaro.org> Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
show more ...
|
| #
b7f0111d |
| 26-Jan-2018 |
Volodymyr Babchuk <vlad.babchuk@gmail.com> |
bget: use struct bpoolset instead of global variables
Move all global variables that are used by bget into struct bpoolset. "poolset" choosed because term "pool" already used by bget itself. bget ca
bget: use struct bpoolset instead of global variables
Move all global variables that are used by bget into struct bpoolset. "poolset" choosed because term "pool" already used by bget itself. bget can use multiple pools to allocate memory. Now it is posible to use number of pool sets simultaneosly.
Such feature is needed for virtualization support, because we want to use separate allocator for OP-TEE kernel memory allocations and separate allocator for client memory allocations.
Signed-off-by: Volodymyr Babchuk <vlad.babchuk@gmail.com> Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org>
show more ...
|
| #
e103c301 |
| 11-Sep-2017 |
Jens Wiklander <jens.wiklander@linaro.org> |
libutils: malloc: use asan_memset_unchecked()
The malloc implementation uses the new asan_memset_unchecked() function internally instead of memset() to avoid unexpected asserts when the address sani
libutils: malloc: use asan_memset_unchecked()
The malloc implementation uses the new asan_memset_unchecked() function internally instead of memset() to avoid unexpected asserts when the address sanitizer is enabled.
bget() tags the requested amount of memory allocated, but eventual padding etc isn't tagged so writes there from instrumented functions, for instance the normal memset(), will be caught.
Reviewed-by: Etienne Carriere <etienne.carriere@linaro.org> Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
show more ...
|
| #
1d171f95 |
| 30-Aug-2016 |
Jens Wiklander <jens.wiklander@linaro.org> |
core: add support for kernel address sanitizer
Adds support for kernel address sanitizer. Currently only for plat-vexpress-qemu_virt.
Reviewed-by: Etienne Carriere <etienne.carriere@linaro.org> Tes
core: add support for kernel address sanitizer
Adds support for kernel address sanitizer. Currently only for plat-vexpress-qemu_virt.
Reviewed-by: Etienne Carriere <etienne.carriere@linaro.org> Tested-by: Jens Wiklander <jens.wiklander@linaro.org> (QEMU v7) Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
show more ...
|
| #
074ba9b2 |
| 09-Oct-2014 |
Jens Wiklander <jens.wiklander@linaro.org> |
Move bget to libutils replacing dlmalloc
* Moves bget to libutils replacing dlmalloc as kernel memory allocator * Restores the code formatting of bget.{c,h} to the original state as parts of the c
Move bget to libutils replacing dlmalloc
* Moves bget to libutils replacing dlmalloc as kernel memory allocator * Restores the code formatting of bget.{c,h} to the original state as parts of the current code was unreadable * Adds malloc_add_pool() to make use of previously unused memory * Moves call to malloc_init() into platform specific code * Restores MDBG into working condition * Adds memalign function to bget.
Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org> Tested-by: Jens Wiklander <jens.wiklander@linaro.org> (QEMU virt platform) Tested-by: Jerome Forissier <jerome.forissier@linaro.org> (FVP) Reviewed-by: Etienne Carriere <etienne.carriere@st.com> Tested-by: Pascal Brand <pascal.brand@linaro.org> (STM platform)
show more ...
|