X-Git-Url: https://git.lttng.org/?p=lttng-ust.git;a=blobdiff_plain;f=src%2Fcommon%2Fmacros.h;fp=src%2Fcommon%2Fmacros.h;h=e8965b383cae3b25d0228d0778f79ca3487c6483;hp=308a1dfca696349832af3df107c22d808155f4bb;hb=97572c0438845cee953ebd3e39615f78bfa405a7;hpb=4b01076fea0f635af6af6762a8edce1be03e5d39 diff --git a/src/common/macros.h b/src/common/macros.h index 308a1dfc..e8965b38 100644 --- a/src/common/macros.h +++ b/src/common/macros.h @@ -8,9 +8,32 @@ #define _UST_COMMON_MACROS_H #include +#include +#include #include +/* + * calloc() does not always populate the page table for the allocated + * memory. Optionally enforce page table populate. + */ +static inline +void *zmalloc_populate(size_t len, bool populate) + __attribute__((always_inline)); +static inline +void *zmalloc_populate(size_t len, bool populate) +{ + if (populate) { + void *ret = malloc(len); + if (ret == NULL) + return ret; + bzero(ret, len); + return ret; + } else { + return calloc(len, 1); + } +} + /* * Memory allocation zeroed */ @@ -20,7 +43,7 @@ void *zmalloc(size_t len) static inline void *zmalloc(size_t len) { - return calloc(len, 1); + return zmalloc_populate(len, false); } #define max_t(type, x, y) \