diff options
author | Honnappa Nagarahalli <honnappa.nagarahalli@arm.com> | 2017-11-21 14:21:18 -0600 |
---|---|---|
committer | Yi He <yi.he@linaro.org> | 2017-12-08 11:05:25 +0800 |
commit | 80b0d616f750e824a4bf0b0f3406ea3a3173ae0e (patch) | |
tree | d44a97f6280aff150ef17d4fcb1f5e58cfc1c2e6 | |
parent | 00c7441fae53949dd87855d48102f932f8f64537 (diff) |
linux-generic: pool: allocate ring memory based on pool size
Adjust the size of ring based on configured number of
buffers in the pool.
Signed-off-by: Honnappa Nagarahalli <honnappa.nagarahalli@arm.com>
Reviewed-by: Ola Liljedahl <ola.Liljedahl@arm.com>
Reviewed-by: Bill Fischofer <bill.fischofer@linaro.org>
Signed-off-by: Yi He <yi.he@linaro.org>
-rw-r--r-- | platform/linux-generic/include/odp_config_internal.h | 5 | ||||
-rw-r--r-- | platform/linux-generic/include/odp_pool_internal.h | 2 | ||||
-rw-r--r-- | platform/linux-generic/pool/generic.c | 37 |
3 files changed, 17 insertions, 27 deletions
diff --git a/platform/linux-generic/include/odp_config_internal.h b/platform/linux-generic/include/odp_config_internal.h index 9b334df49..9720581a3 100644 --- a/platform/linux-generic/include/odp_config_internal.h +++ b/platform/linux-generic/include/odp_config_internal.h @@ -148,11 +148,6 @@ #define CONFIG_BURST_SIZE 16 /* - * Maximum number of events in a pool - */ -#define CONFIG_POOL_MAX_NUM (1 * 1024 * 1024) - -/* * Maximum number of events in a thread local pool cache */ #define CONFIG_POOL_CACHE_SIZE 256 diff --git a/platform/linux-generic/include/odp_pool_internal.h b/platform/linux-generic/include/odp_pool_internal.h index 60687b3d4..a124697e9 100644 --- a/platform/linux-generic/include/odp_pool_internal.h +++ b/platform/linux-generic/include/odp_pool_internal.h @@ -41,7 +41,7 @@ typedef struct { ring_t hdr; /* Ring data: buffer handles */ - uint32_t buf[CONFIG_POOL_MAX_NUM]; + uint32_t buf[]; } pool_ring_t ODP_ALIGNED_CACHE; diff --git a/platform/linux-generic/pool/generic.c b/platform/linux-generic/pool/generic.c index c55f67575..7a068472c 100644 --- a/platform/linux-generic/pool/generic.c +++ b/platform/linux-generic/pool/generic.c @@ -156,11 +156,12 @@ static int generic_pool_term_local(void) return 0; } -static pool_t *reserve_pool(void) +static pool_t *reserve_pool(uint32_t ring_size) { int i; pool_t *pool; char ring_name[ODP_POOL_NAME_LEN]; + uint32_t ring_shm_size; for (i = 0; i < ODP_CONFIG_POOLS; i++) { pool = pool_entry(i); @@ -169,10 +170,13 @@ static pool_t *reserve_pool(void) if (pool->reserved == 0) { pool->reserved = 1; UNLOCK(&pool->lock); - sprintf(ring_name, "pool_ring_%d", i); + snprintf(ring_name, ODP_POOL_NAME_LEN, + "pool_ring_%d", i); + ring_shm_size = sizeof(pool_ring_t) + + sizeof(pool->ring->buf[0]) * ring_size; pool->ring_shm = odp_shm_reserve(ring_name, - sizeof(pool_ring_t), + ring_shm_size, ODP_CACHE_LINE_SIZE, 0); if (odp_unlikely(pool->ring_shm == ODP_SHM_INVALID)) { ODP_ERR("Unable to alloc pool ring %d\n", i); @@ -395,7 +399,12 @@ static odp_pool_t pool_create(const char *name, odp_pool_param_t *params, if (uarea_size) uarea_size = ROUNDUP_CACHE_LINE(uarea_size); - pool = reserve_pool(); + if (num <= RING_SIZE_MIN) + ring_size = RING_SIZE_MIN; + else + ring_size = ROUNDUP_POWER2_U32(num); + + pool = reserve_pool(ring_size); if (pool == NULL) { ODP_ERR("No more free pools"); @@ -431,11 +440,6 @@ 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 = RING_SIZE_MIN; - else - ring_size = ROUNDUP_POWER2_U32(num); - pool->ring_mask = ring_size - 1; pool->num = num; pool->align = align; @@ -506,11 +510,6 @@ static int check_params(odp_pool_param_t *params) switch (params->type) { case ODP_POOL_BUFFER: - if (params->buf.num > capa.buf.max_num) { - printf("buf.num too large %u\n", params->buf.num); - return -1; - } - if (params->buf.size > capa.buf.max_size) { printf("buf.size too large %u\n", params->buf.size); return -1; @@ -550,10 +549,6 @@ static int check_params(odp_pool_param_t *params) break; case ODP_POOL_TIMEOUT: - if (params->tmo.num > capa.tmo.max_num) { - printf("tmo.num too large %u\n", params->tmo.num); - return -1; - } break; default: @@ -663,12 +658,12 @@ static int generic_pool_capability(odp_pool_capability_t *capa) capa->buf.max_pools = ODP_CONFIG_POOLS; capa->buf.max_align = ODP_CONFIG_BUFFER_ALIGN_MAX; capa->buf.max_size = MAX_SIZE; - capa->buf.max_num = CONFIG_POOL_MAX_NUM; + capa->buf.max_num = 0; /* Packet pools */ capa->pkt.max_pools = ODP_CONFIG_POOLS; capa->pkt.max_len = CONFIG_PACKET_MAX_LEN; - capa->pkt.max_num = CONFIG_POOL_MAX_NUM; + capa->pkt.max_num = 0; capa->pkt.min_headroom = CONFIG_PACKET_HEADROOM; capa->pkt.max_headroom = CONFIG_PACKET_HEADROOM; capa->pkt.min_tailroom = CONFIG_PACKET_TAILROOM; @@ -679,7 +674,7 @@ static int generic_pool_capability(odp_pool_capability_t *capa) /* Timeout pools */ capa->tmo.max_pools = ODP_CONFIG_POOLS; - capa->tmo.max_num = CONFIG_POOL_MAX_NUM; + capa->tmo.max_num = 0; return 0; } |