diff options
author | Jens Wiklander <jens.wiklander@linaro.org> | 2018-11-08 11:17:34 +0100 |
---|---|---|
committer | Jérôme Forissier <jerome.forissier@linaro.org> | 2018-11-14 15:32:01 +0100 |
commit | b69b86b6f9ae67008000fced8925fe0830291d1c (patch) | |
tree | c18fd3af107daa79fbe5239112bb3a168549c7e9 /lib | |
parent | d4f909c01d27814c655bce7b818f21f4555d98cd (diff) |
mempool: report max memory usage
Adds CFG_MEMPOOL_REPORT_LAST_OFFSET which if set to y causes mempool to
report each time the maximum amount of memory has increased. This helps
to determine required size of a mempool.
Reviewed-by: Jerome Forissier <jerome.forissier@linaro.org>
Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/libutils/ext/mempool.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/lib/libutils/ext/mempool.c b/lib/libutils/ext/mempool.c index 0fa9a348..0d085dee 100644 --- a/lib/libutils/ext/mempool.c +++ b/lib/libutils/ext/mempool.c @@ -58,6 +58,9 @@ struct mempool { size_t size; /* size of the memory pool, in bytes */ ssize_t last_offset; /* offset to the last one */ vaddr_t data; +#ifdef CFG_MEMPOOL_REPORT_LAST_OFFSET + ssize_t max_last_offset; +#endif #if defined(__KERNEL__) void (*release_mem)(void *ptr, size_t size); struct mutex mu; @@ -167,6 +170,13 @@ void *mempool_alloc(struct mempool *pool, size_t size) last_item->next_item_offset = offset; new_item->next_item_offset = -1; pool->last_offset = offset; +#ifdef CFG_MEMPOOL_REPORT_LAST_OFFSET + if (pool->last_offset > pool->max_last_offset) { + pool->max_last_offset = pool->last_offset; + DMSG("Max memory usage increased to %zu", + (size_t)pool->max_last_offset); + } +#endif return new_item + 1; |