Skip to content
Permalink
Browse files

linux-gen: pool: ring size must be larger than num items

Ensure that ring size is larger than number of events to be
stored in there.

Signed-off-by: Petri Savolainen <petri.savolainen@linaro.org>
Reviewed-by: Bill Fischofer <bill.fischofer@linaro.org>
Signed-off-by: Maxim Uvarov <maxim.uvarov@linaro.org>
  • Loading branch information...
psavol authored and muvarov committed Oct 11, 2018
1 parent 81b8a6b commit cb97c894c05ef5a43dce262cf178ce5f54b1c806
@@ -154,9 +154,10 @@ extern "C" {
#define CONFIG_BURST_SIZE 32

/*
* Maximum number of events in a pool
* Maximum number of events in a pool. Power of two minus one results optimal
* memory usage for the ring.
*/
#define CONFIG_POOL_MAX_NUM (1 * 1024 * 1024)
#define CONFIG_POOL_MAX_NUM ((1 * 1024 * 1024) - 1)

/*
* Maximum number of events in a thread local pool cache
@@ -38,7 +38,7 @@ typedef struct ODP_ALIGNED_CACHE {
ring_t hdr;

/* Ring data: buffer handles */
uint32_t buf[CONFIG_POOL_MAX_NUM];
uint32_t buf[CONFIG_POOL_MAX_NUM + 1];

} pool_ring_t;

@@ -471,10 +471,11 @@ static odp_pool_t pool_create(const char *name, odp_pool_param_t *params,
FIRST_HP_SIZE - 1) / FIRST_HP_SIZE);
}

if (num <= RING_SIZE_MIN)
/* Ring size must be larger than the number of items stored */
if (num + 1 <= RING_SIZE_MIN)
ring_size = RING_SIZE_MIN;
else
ring_size = ROUNDUP_POWER2_U32(num);
ring_size = ROUNDUP_POWER2_U32(num + 1);

pool->ring_mask = ring_size - 1;
pool->num = num;

0 comments on commit cb97c89

Please sign in to comment.
You can’t perform that action at this time.