aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoakim Bech <joakim.bech@linaro.org>2018-10-02 12:46:09 +0200
committerJérôme Forissier <jerome.forissier@linaro.org>2018-10-03 16:25:44 +0200
commitbde8a250edd97987f8fc2c20fcb36ea4038f0e22 (patch)
tree3332a983b80909cd3a49f6c7593c302b9bbbd8e8
parent623056670b301c2315ef52ae04c5fa32d1576924 (diff)
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>
-rw-r--r--lib/libutils/isoc/bget.c6
-rw-r--r--mk/config.mk4
2 files changed, 10 insertions, 0 deletions
diff --git a/lib/libutils/isoc/bget.c b/lib/libutils/isoc/bget.c
index b29e13ea..6de0b091 100644
--- a/lib/libutils/isoc/bget.c
+++ b/lib/libutils/isoc/bget.c
@@ -480,6 +480,12 @@ extern char *sprintf(); /* Sun includes don't define sprintf */
#include <ctype.h>
#endif
+#ifdef __KERNEL__
+#ifdef CFG_CORE_BGET_BESTFIT
+#define BestFit 1
+#endif
+#endif
+
/* Declare the interface, including the requested buffer size type,
bufsize. */
diff --git a/mk/config.mk b/mk/config.mk
index d92c33a2..e0c050a8 100644
--- a/mk/config.mk
+++ b/mk/config.mk
@@ -219,6 +219,10 @@ CFG_TA_DYNLINK ?= y
# Enable paging, requires SRAM, can't be enabled by default
CFG_WITH_PAGER ?= n
+# BestFit algorithm in bget reduces the fragmentation of the heap when running
+# with the pager enabled.
+CFG_CORE_BGET_BESTFIT ?= $(CFG_WITH_PAGER)
+
# Use the pager for user TAs
CFG_PAGED_USER_TA ?= $(CFG_WITH_PAGER)