From: Pavel Charvat Date: Tue, 20 May 2014 09:08:15 +0000 (+0200) Subject: Mempool: Implemented statistics about allocated bytes from memory pool to application. X-Git-Tag: v6.0~35 X-Git-Url: http://mj.ucw.cz/gitweb/?a=commitdiff_plain;h=7c2ab38062eaadbf41085b4e2a8a2910c5d93ccd;p=libucw.git Mempool: Implemented statistics about allocated bytes from memory pool to application. --- diff --git a/ucw/mempool.c b/ucw/mempool.c index 564a8e9f..9e5d62b0 100644 --- a/ucw/mempool.c +++ b/ucw/mempool.c @@ -219,6 +219,9 @@ mp_stats(struct mempool *pool, struct mempool_stats *stats) mp_stats_chain(pool->state.last[1], stats, 1); mp_stats_chain(pool->unused, stats, 2); ASSERT(stats->total_size == pool->total_size); + stats->used_size = stats->chain_size[0] + stats->chain_size[1] + - MP_CHUNK_TAIL * (stats->chain_count[0] + stats->chain_count[1]) + - pool->state.free[0] - pool->state.free[1]; } u64 diff --git a/ucw/mempool.h b/ucw/mempool.h index 562d8f99..9d0c97d1 100644 --- a/ucw/mempool.h +++ b/ucw/mempool.h @@ -77,6 +77,7 @@ struct mempool { struct mempool_stats { /** Mempool statistics. See @mp_stats(). **/ u64 total_size; /* Real allocated size in bytes */ + u64 used_size; /* Estimated size allocated from mempool to application */ uns chain_count[3]; /* Number of allocated chunks in small/big/unused chains */ uns chain_size[3]; /* Size of allocated chunks in small/big/unused chains */ };