Skip to content

Commit

Permalink
pager: enable BestFit allocation when using the pager
Browse files Browse the repository at this point in the history
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: OP-TEE#2580

Signed-off-by: Joakim Bech <[email protected]>
Tested-by: Joakim Bech <[email protected]> (HiKey 6220, QEMU v8)
Reviewed-by: Jerome Forissier <[email protected]>
Reviewed-by: Jens Wiklander <[email protected]>
  • Loading branch information
jbech-linaro authored and jforissier committed Oct 3, 2018
1 parent 6230566 commit bde8a25
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
6 changes: 6 additions & 0 deletions lib/libutils/isoc/bget.c
Original file line number Diff line number Diff line change
Expand Up @@ -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. */

Expand Down
4 changes: 4 additions & 0 deletions mk/config.mk
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down

0 comments on commit bde8a25

Please sign in to comment.