Message ID | 1432813301-21973-1-git-send-email-bill.fischofer@linaro.org |
---|---|
State | Accepted |
Commit | 743dcb0ac68a8af59609a94a632e3f3c506442e5 |
Headers | show |
Merged, thanks, Maxim. On 05/28/15 14:41, Bill Fischofer wrote: > Address bug https://bugs.linaro.org/show_bug.cgi?id=1480 > > Signed-off-by: Bill Fischofer <bill.fischofer@linaro.org> > --- > platform/linux-generic/include/odp_pool_internal.h | 44 +++++++++++-------- > platform/linux-generic/odp_pool.c | 50 +++++++++++----------- > 2 files changed, 52 insertions(+), 42 deletions(-) > > diff --git a/platform/linux-generic/include/odp_pool_internal.h b/platform/linux-generic/include/odp_pool_internal.h > index 247a75a..136db2c 100644 > --- a/platform/linux-generic/include/odp_pool_internal.h > +++ b/platform/linux-generic/include/odp_pool_internal.h > @@ -73,6 +73,20 @@ typedef struct local_cache_t { > #define POOL_LOCK_INIT(a) odp_spinlock_init(a) > #endif > > +/** > + * ODP Pool stats - Maintain some useful stats regarding pool utilization > + */ > +typedef struct { > + odp_atomic_u64_t bufallocs; /**< Count of successful buf allocs */ > + odp_atomic_u64_t buffrees; /**< Count of successful buf frees */ > + odp_atomic_u64_t blkallocs; /**< Count of successful blk allocs */ > + odp_atomic_u64_t blkfrees; /**< Count of successful blk frees */ > + odp_atomic_u64_t bufempty; /**< Count of unsuccessful buf allocs */ > + odp_atomic_u64_t blkempty; /**< Count of unsuccessful blk allocs */ > + odp_atomic_u64_t high_wm_count; /**< Count of high wm conditions */ > + odp_atomic_u64_t low_wm_count; /**< Count of low wm conditions */ > +} _odp_pool_stats_t; > + > struct pool_entry_s { > #ifdef POOL_USE_TICKETLOCK > odp_ticketlock_t lock ODP_ALIGNED_CACHE; > @@ -111,14 +125,7 @@ struct pool_entry_s { > void *blk_freelist; > odp_atomic_u32_t bufcount; > odp_atomic_u32_t blkcount; > - odp_atomic_u64_t bufallocs; > - odp_atomic_u64_t buffrees; > - odp_atomic_u64_t blkallocs; > - odp_atomic_u64_t blkfrees; > - odp_atomic_u64_t bufempty; > - odp_atomic_u64_t blkempty; > - odp_atomic_u64_t high_wm_count; > - odp_atomic_u64_t low_wm_count; > + _odp_pool_stats_t poolstats; > uint32_t buf_num; > uint32_t seg_size; > uint32_t blk_size; > @@ -153,12 +160,12 @@ static inline void *get_blk(struct pool_entry_s *pool) > > if (odp_unlikely(myhead == NULL)) { > POOL_UNLOCK(&pool->blk_lock); > - odp_atomic_inc_u64(&pool->blkempty); > + odp_atomic_inc_u64(&pool->poolstats.blkempty); > } else { > pool->blk_freelist = ((odp_buf_blk_t *)myhead)->next; > POOL_UNLOCK(&pool->blk_lock); > odp_atomic_dec_u32(&pool->blkcount); > - odp_atomic_inc_u64(&pool->blkallocs); > + odp_atomic_inc_u64(&pool->poolstats.blkallocs); > } > > return myhead; > @@ -174,7 +181,7 @@ static inline void ret_blk(struct pool_entry_s *pool, void *block) > POOL_UNLOCK(&pool->blk_lock); > > odp_atomic_inc_u32(&pool->blkcount); > - odp_atomic_inc_u64(&pool->blkfrees); > + odp_atomic_inc_u64(&pool->poolstats.blkfrees); > } > > static inline odp_buffer_hdr_t *get_buf(struct pool_entry_s *pool) > @@ -186,7 +193,7 @@ static inline odp_buffer_hdr_t *get_buf(struct pool_entry_s *pool) > > if (odp_unlikely(myhead == NULL)) { > POOL_UNLOCK(&pool->buf_lock); > - odp_atomic_inc_u64(&pool->bufempty); > + odp_atomic_inc_u64(&pool->poolstats.bufempty); > } else { > pool->buf_freelist = myhead->next; > POOL_UNLOCK(&pool->buf_lock); > @@ -196,10 +203,10 @@ static inline odp_buffer_hdr_t *get_buf(struct pool_entry_s *pool) > /* Check for low watermark condition */ > if (bufcount == pool->low_wm && !pool->low_wm_assert) { > pool->low_wm_assert = 1; > - odp_atomic_inc_u64(&pool->low_wm_count); > + odp_atomic_inc_u64(&pool->poolstats.low_wm_count); > } > > - odp_atomic_inc_u64(&pool->bufallocs); > + odp_atomic_inc_u64(&pool->poolstats.bufallocs); > myhead->allocator = odp_thread_id(); > } > > @@ -229,10 +236,10 @@ static inline void ret_buf(struct pool_entry_s *pool, odp_buffer_hdr_t *buf) > /* Check if low watermark condition should be deasserted */ > if (bufcount == pool->high_wm && pool->low_wm_assert) { > pool->low_wm_assert = 0; > - odp_atomic_inc_u64(&pool->high_wm_count); > + odp_atomic_inc_u64(&pool->poolstats.high_wm_count); > } > > - odp_atomic_inc_u64(&pool->buffrees); > + odp_atomic_inc_u64(&pool->poolstats.buffrees); > } > > static inline void *get_local_buf(local_cache_t *buf_cache, > @@ -291,8 +298,9 @@ static inline void flush_cache(local_cache_t *buf_cache, > flush_count++; > } > > - odp_atomic_add_u64(&pool->bufallocs, buf_cache->bufallocs); > - odp_atomic_add_u64(&pool->buffrees, buf_cache->buffrees - flush_count); > + odp_atomic_add_u64(&pool->poolstats.bufallocs, buf_cache->bufallocs); > + odp_atomic_add_u64(&pool->poolstats.buffrees, > + buf_cache->buffrees - flush_count); > > buf_cache->buf_freelist = NULL; > buf_cache->bufallocs = 0; > diff --git a/platform/linux-generic/odp_pool.c b/platform/linux-generic/odp_pool.c > index cd2c449..f2bf0c7 100644 > --- a/platform/linux-generic/odp_pool.c > +++ b/platform/linux-generic/odp_pool.c > @@ -89,14 +89,14 @@ int odp_pool_init_global(void) > odp_atomic_init_u32(&pool->s.blkcount, 0); > > /* Initialize pool statistics counters */ > - odp_atomic_init_u64(&pool->s.bufallocs, 0); > - odp_atomic_init_u64(&pool->s.buffrees, 0); > - odp_atomic_init_u64(&pool->s.blkallocs, 0); > - odp_atomic_init_u64(&pool->s.blkfrees, 0); > - odp_atomic_init_u64(&pool->s.bufempty, 0); > - odp_atomic_init_u64(&pool->s.blkempty, 0); > - odp_atomic_init_u64(&pool->s.high_wm_count, 0); > - odp_atomic_init_u64(&pool->s.low_wm_count, 0); > + odp_atomic_init_u64(&pool->s.poolstats.bufallocs, 0); > + odp_atomic_init_u64(&pool->s.poolstats.buffrees, 0); > + odp_atomic_init_u64(&pool->s.poolstats.blkallocs, 0); > + odp_atomic_init_u64(&pool->s.poolstats.blkfrees, 0); > + odp_atomic_init_u64(&pool->s.poolstats.bufempty, 0); > + odp_atomic_init_u64(&pool->s.poolstats.blkempty, 0); > + odp_atomic_init_u64(&pool->s.poolstats.high_wm_count, 0); > + odp_atomic_init_u64(&pool->s.poolstats.low_wm_count, 0); > } > > ODP_DBG("\nPool init global\n"); > @@ -401,14 +401,14 @@ odp_pool_t odp_pool_create(const char *name, > } while (blk >= block_base_addr); > > /* Initialize pool statistics counters */ > - odp_atomic_store_u64(&pool->s.bufallocs, 0); > - odp_atomic_store_u64(&pool->s.buffrees, 0); > - odp_atomic_store_u64(&pool->s.blkallocs, 0); > - odp_atomic_store_u64(&pool->s.blkfrees, 0); > - odp_atomic_store_u64(&pool->s.bufempty, 0); > - odp_atomic_store_u64(&pool->s.blkempty, 0); > - odp_atomic_store_u64(&pool->s.high_wm_count, 0); > - odp_atomic_store_u64(&pool->s.low_wm_count, 0); > + odp_atomic_store_u64(&pool->s.poolstats.bufallocs, 0); > + odp_atomic_store_u64(&pool->s.poolstats.buffrees, 0); > + odp_atomic_store_u64(&pool->s.poolstats.blkallocs, 0); > + odp_atomic_store_u64(&pool->s.poolstats.blkfrees, 0); > + odp_atomic_store_u64(&pool->s.poolstats.bufempty, 0); > + odp_atomic_store_u64(&pool->s.poolstats.blkempty, 0); > + odp_atomic_store_u64(&pool->s.poolstats.high_wm_count, 0); > + odp_atomic_store_u64(&pool->s.poolstats.low_wm_count, 0); > > /* Reset other pool globals to initial state */ > pool->s.low_wm_assert = 0; > @@ -586,14 +586,16 @@ void odp_pool_print(odp_pool_t pool_hdl) > > uint32_t bufcount = odp_atomic_load_u32(&pool->s.bufcount); > uint32_t blkcount = odp_atomic_load_u32(&pool->s.blkcount); > - uint64_t bufallocs = odp_atomic_load_u64(&pool->s.bufallocs); > - uint64_t buffrees = odp_atomic_load_u64(&pool->s.buffrees); > - uint64_t blkallocs = odp_atomic_load_u64(&pool->s.blkallocs); > - uint64_t blkfrees = odp_atomic_load_u64(&pool->s.blkfrees); > - uint64_t bufempty = odp_atomic_load_u64(&pool->s.bufempty); > - uint64_t blkempty = odp_atomic_load_u64(&pool->s.blkempty); > - uint64_t hiwmct = odp_atomic_load_u64(&pool->s.high_wm_count); > - uint64_t lowmct = odp_atomic_load_u64(&pool->s.low_wm_count); > + uint64_t bufallocs = odp_atomic_load_u64(&pool->s.poolstats.bufallocs); > + uint64_t buffrees = odp_atomic_load_u64(&pool->s.poolstats.buffrees); > + uint64_t blkallocs = odp_atomic_load_u64(&pool->s.poolstats.blkallocs); > + uint64_t blkfrees = odp_atomic_load_u64(&pool->s.poolstats.blkfrees); > + uint64_t bufempty = odp_atomic_load_u64(&pool->s.poolstats.bufempty); > + uint64_t blkempty = odp_atomic_load_u64(&pool->s.poolstats.blkempty); > + uint64_t hiwmct = > + odp_atomic_load_u64(&pool->s.poolstats.high_wm_count); > + uint64_t lowmct = > + odp_atomic_load_u64(&pool->s.poolstats.low_wm_count); > > ODP_DBG("Pool info\n"); > ODP_DBG("---------\n");
diff --git a/platform/linux-generic/include/odp_pool_internal.h b/platform/linux-generic/include/odp_pool_internal.h index 247a75a..136db2c 100644 --- a/platform/linux-generic/include/odp_pool_internal.h +++ b/platform/linux-generic/include/odp_pool_internal.h @@ -73,6 +73,20 @@ typedef struct local_cache_t { #define POOL_LOCK_INIT(a) odp_spinlock_init(a) #endif +/** + * ODP Pool stats - Maintain some useful stats regarding pool utilization + */ +typedef struct { + odp_atomic_u64_t bufallocs; /**< Count of successful buf allocs */ + odp_atomic_u64_t buffrees; /**< Count of successful buf frees */ + odp_atomic_u64_t blkallocs; /**< Count of successful blk allocs */ + odp_atomic_u64_t blkfrees; /**< Count of successful blk frees */ + odp_atomic_u64_t bufempty; /**< Count of unsuccessful buf allocs */ + odp_atomic_u64_t blkempty; /**< Count of unsuccessful blk allocs */ + odp_atomic_u64_t high_wm_count; /**< Count of high wm conditions */ + odp_atomic_u64_t low_wm_count; /**< Count of low wm conditions */ +} _odp_pool_stats_t; + struct pool_entry_s { #ifdef POOL_USE_TICKETLOCK odp_ticketlock_t lock ODP_ALIGNED_CACHE; @@ -111,14 +125,7 @@ struct pool_entry_s { void *blk_freelist; odp_atomic_u32_t bufcount; odp_atomic_u32_t blkcount; - odp_atomic_u64_t bufallocs; - odp_atomic_u64_t buffrees; - odp_atomic_u64_t blkallocs; - odp_atomic_u64_t blkfrees; - odp_atomic_u64_t bufempty; - odp_atomic_u64_t blkempty; - odp_atomic_u64_t high_wm_count; - odp_atomic_u64_t low_wm_count; + _odp_pool_stats_t poolstats; uint32_t buf_num; uint32_t seg_size; uint32_t blk_size; @@ -153,12 +160,12 @@ static inline void *get_blk(struct pool_entry_s *pool) if (odp_unlikely(myhead == NULL)) { POOL_UNLOCK(&pool->blk_lock); - odp_atomic_inc_u64(&pool->blkempty); + odp_atomic_inc_u64(&pool->poolstats.blkempty); } else { pool->blk_freelist = ((odp_buf_blk_t *)myhead)->next; POOL_UNLOCK(&pool->blk_lock); odp_atomic_dec_u32(&pool->blkcount); - odp_atomic_inc_u64(&pool->blkallocs); + odp_atomic_inc_u64(&pool->poolstats.blkallocs); } return myhead; @@ -174,7 +181,7 @@ static inline void ret_blk(struct pool_entry_s *pool, void *block) POOL_UNLOCK(&pool->blk_lock); odp_atomic_inc_u32(&pool->blkcount); - odp_atomic_inc_u64(&pool->blkfrees); + odp_atomic_inc_u64(&pool->poolstats.blkfrees); } static inline odp_buffer_hdr_t *get_buf(struct pool_entry_s *pool) @@ -186,7 +193,7 @@ static inline odp_buffer_hdr_t *get_buf(struct pool_entry_s *pool) if (odp_unlikely(myhead == NULL)) { POOL_UNLOCK(&pool->buf_lock); - odp_atomic_inc_u64(&pool->bufempty); + odp_atomic_inc_u64(&pool->poolstats.bufempty); } else { pool->buf_freelist = myhead->next; POOL_UNLOCK(&pool->buf_lock); @@ -196,10 +203,10 @@ static inline odp_buffer_hdr_t *get_buf(struct pool_entry_s *pool) /* Check for low watermark condition */ if (bufcount == pool->low_wm && !pool->low_wm_assert) { pool->low_wm_assert = 1; - odp_atomic_inc_u64(&pool->low_wm_count); + odp_atomic_inc_u64(&pool->poolstats.low_wm_count); } - odp_atomic_inc_u64(&pool->bufallocs); + odp_atomic_inc_u64(&pool->poolstats.bufallocs); myhead->allocator = odp_thread_id(); } @@ -229,10 +236,10 @@ static inline void ret_buf(struct pool_entry_s *pool, odp_buffer_hdr_t *buf) /* Check if low watermark condition should be deasserted */ if (bufcount == pool->high_wm && pool->low_wm_assert) { pool->low_wm_assert = 0; - odp_atomic_inc_u64(&pool->high_wm_count); + odp_atomic_inc_u64(&pool->poolstats.high_wm_count); } - odp_atomic_inc_u64(&pool->buffrees); + odp_atomic_inc_u64(&pool->poolstats.buffrees); } static inline void *get_local_buf(local_cache_t *buf_cache, @@ -291,8 +298,9 @@ static inline void flush_cache(local_cache_t *buf_cache, flush_count++; } - odp_atomic_add_u64(&pool->bufallocs, buf_cache->bufallocs); - odp_atomic_add_u64(&pool->buffrees, buf_cache->buffrees - flush_count); + odp_atomic_add_u64(&pool->poolstats.bufallocs, buf_cache->bufallocs); + odp_atomic_add_u64(&pool->poolstats.buffrees, + buf_cache->buffrees - flush_count); buf_cache->buf_freelist = NULL; buf_cache->bufallocs = 0; diff --git a/platform/linux-generic/odp_pool.c b/platform/linux-generic/odp_pool.c index cd2c449..f2bf0c7 100644 --- a/platform/linux-generic/odp_pool.c +++ b/platform/linux-generic/odp_pool.c @@ -89,14 +89,14 @@ int odp_pool_init_global(void) odp_atomic_init_u32(&pool->s.blkcount, 0); /* Initialize pool statistics counters */ - odp_atomic_init_u64(&pool->s.bufallocs, 0); - odp_atomic_init_u64(&pool->s.buffrees, 0); - odp_atomic_init_u64(&pool->s.blkallocs, 0); - odp_atomic_init_u64(&pool->s.blkfrees, 0); - odp_atomic_init_u64(&pool->s.bufempty, 0); - odp_atomic_init_u64(&pool->s.blkempty, 0); - odp_atomic_init_u64(&pool->s.high_wm_count, 0); - odp_atomic_init_u64(&pool->s.low_wm_count, 0); + odp_atomic_init_u64(&pool->s.poolstats.bufallocs, 0); + odp_atomic_init_u64(&pool->s.poolstats.buffrees, 0); + odp_atomic_init_u64(&pool->s.poolstats.blkallocs, 0); + odp_atomic_init_u64(&pool->s.poolstats.blkfrees, 0); + odp_atomic_init_u64(&pool->s.poolstats.bufempty, 0); + odp_atomic_init_u64(&pool->s.poolstats.blkempty, 0); + odp_atomic_init_u64(&pool->s.poolstats.high_wm_count, 0); + odp_atomic_init_u64(&pool->s.poolstats.low_wm_count, 0); } ODP_DBG("\nPool init global\n"); @@ -401,14 +401,14 @@ odp_pool_t odp_pool_create(const char *name, } while (blk >= block_base_addr); /* Initialize pool statistics counters */ - odp_atomic_store_u64(&pool->s.bufallocs, 0); - odp_atomic_store_u64(&pool->s.buffrees, 0); - odp_atomic_store_u64(&pool->s.blkallocs, 0); - odp_atomic_store_u64(&pool->s.blkfrees, 0); - odp_atomic_store_u64(&pool->s.bufempty, 0); - odp_atomic_store_u64(&pool->s.blkempty, 0); - odp_atomic_store_u64(&pool->s.high_wm_count, 0); - odp_atomic_store_u64(&pool->s.low_wm_count, 0); + odp_atomic_store_u64(&pool->s.poolstats.bufallocs, 0); + odp_atomic_store_u64(&pool->s.poolstats.buffrees, 0); + odp_atomic_store_u64(&pool->s.poolstats.blkallocs, 0); + odp_atomic_store_u64(&pool->s.poolstats.blkfrees, 0); + odp_atomic_store_u64(&pool->s.poolstats.bufempty, 0); + odp_atomic_store_u64(&pool->s.poolstats.blkempty, 0); + odp_atomic_store_u64(&pool->s.poolstats.high_wm_count, 0); + odp_atomic_store_u64(&pool->s.poolstats.low_wm_count, 0); /* Reset other pool globals to initial state */ pool->s.low_wm_assert = 0; @@ -586,14 +586,16 @@ void odp_pool_print(odp_pool_t pool_hdl) uint32_t bufcount = odp_atomic_load_u32(&pool->s.bufcount); uint32_t blkcount = odp_atomic_load_u32(&pool->s.blkcount); - uint64_t bufallocs = odp_atomic_load_u64(&pool->s.bufallocs); - uint64_t buffrees = odp_atomic_load_u64(&pool->s.buffrees); - uint64_t blkallocs = odp_atomic_load_u64(&pool->s.blkallocs); - uint64_t blkfrees = odp_atomic_load_u64(&pool->s.blkfrees); - uint64_t bufempty = odp_atomic_load_u64(&pool->s.bufempty); - uint64_t blkempty = odp_atomic_load_u64(&pool->s.blkempty); - uint64_t hiwmct = odp_atomic_load_u64(&pool->s.high_wm_count); - uint64_t lowmct = odp_atomic_load_u64(&pool->s.low_wm_count); + uint64_t bufallocs = odp_atomic_load_u64(&pool->s.poolstats.bufallocs); + uint64_t buffrees = odp_atomic_load_u64(&pool->s.poolstats.buffrees); + uint64_t blkallocs = odp_atomic_load_u64(&pool->s.poolstats.blkallocs); + uint64_t blkfrees = odp_atomic_load_u64(&pool->s.poolstats.blkfrees); + uint64_t bufempty = odp_atomic_load_u64(&pool->s.poolstats.bufempty); + uint64_t blkempty = odp_atomic_load_u64(&pool->s.poolstats.blkempty); + uint64_t hiwmct = + odp_atomic_load_u64(&pool->s.poolstats.high_wm_count); + uint64_t lowmct = + odp_atomic_load_u64(&pool->s.poolstats.low_wm_count); ODP_DBG("Pool info\n"); ODP_DBG("---------\n");
Address bug https://bugs.linaro.org/show_bug.cgi?id=1480 Signed-off-by: Bill Fischofer <bill.fischofer@linaro.org> --- platform/linux-generic/include/odp_pool_internal.h | 44 +++++++++++-------- platform/linux-generic/odp_pool.c | 50 +++++++++++----------- 2 files changed, 52 insertions(+), 42 deletions(-)