[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[UNIKRAFT PATCH v2] lib/ukalloc: make uk_alloc_get_default static inline



Every allocation done through the libc malloc wrapper triggers a function
call to uk_alloc_get_default in order to get a pointer to the default
allocator.  This is not great, because the allocation path is performance
critical, and we should avoid any superflous overhead there.

This patch removes the capability to change the default allocator once it
has been set. This never really worked anyways... the libc wrapper would
forward free() calls to the new allocator, potentially resulting in memory
corruption if the new allocator doesn't handle these foreign pointers
correctly, and memory leaks because these pointers won't be freed anymore.

We make the uk_alloc_head variable global and uk_alloc_get_default static
inline. We rename uk_alloc_head to _uk_alloc_head -- it should preferably
be accessed through uk_alloc_get_default.

Setting aside compiler optimizations, retrieving the default allocator
becomes less expensive: a single memory read instead of a function call +
memory read.

It appears that uk_alloc_set_default was not called anywhere, so this patch
does not require any additional changes in external libraries.

Changes since v1:
 - rename uk_alloc_head to _uk_alloc_head

Hugo Lefeuvre (1):
  lib/ukalloc: make uk_alloc_get_default static inline

 lib/ukalloc/alloc.c            | 45 ++++--------------------------------------
 lib/ukalloc/exportsyms.uk      |  2 +-
 lib/ukalloc/include/uk/alloc.h | 10 +++++++---
 3 files changed, 12 insertions(+), 45 deletions(-)

-- 
2.7.4




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.