aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--config/odp-linux-generic.conf12
-rw-r--r--platform/linux-generic/include/odp_config_internal.h2
-rw-r--r--platform/linux-generic/include/odp_pool_internal.h7
-rw-r--r--platform/linux-generic/odp_pool.c65
-rw-r--r--platform/linux-generic/test/inline-timer.conf2
-rw-r--r--platform/linux-generic/test/process-mode.conf2
6 files changed, 74 insertions, 16 deletions
diff --git a/config/odp-linux-generic.conf b/config/odp-linux-generic.conf
index e00e4a518..fcc5d75aa 100644
--- a/config/odp-linux-generic.conf
+++ b/config/odp-linux-generic.conf
@@ -16,7 +16,7 @@
# Mandatory fields
odp_implementation = "linux-generic"
-config_file_version = "0.1.6"
+config_file_version = "0.1.7"
# Shared memory options
shm: {
@@ -45,6 +45,16 @@ shm: {
# Pool options
pool: {
+ # Thread local cache size. Value must be a multiple of burst_size
+ # (min 2 x burst_size).
+ #
+ # The total maximum number of cached events is the number of threads
+ # using the pool multiplied with local_cache_size.
+ local_cache_size = 256
+
+ # Transfer size between local cache and global pool.
+ burst_size = 32
+
# Packet pool options
pkt: {
# Maximum number of packets per pool. Power of two minus one
diff --git a/platform/linux-generic/include/odp_config_internal.h b/platform/linux-generic/include/odp_config_internal.h
index 810576b9a..27f1db599 100644
--- a/platform/linux-generic/include/odp_config_internal.h
+++ b/platform/linux-generic/include/odp_config_internal.h
@@ -142,7 +142,7 @@ extern "C" {
/*
* Maximum number of events in a thread local pool cache
*/
-#define CONFIG_POOL_CACHE_SIZE 256
+#define CONFIG_POOL_CACHE_MAX_SIZE 256
#ifdef __cplusplus
}
diff --git a/platform/linux-generic/include/odp_pool_internal.h b/platform/linux-generic/include/odp_pool_internal.h
index a5242d60e..67d7e7b7b 100644
--- a/platform/linux-generic/include/odp_pool_internal.h
+++ b/platform/linux-generic/include/odp_pool_internal.h
@@ -27,8 +27,11 @@ extern "C" {
#include <odp/api/plat/strong_types.h>
typedef struct ODP_ALIGNED_CACHE pool_cache_t {
+ uint32_t size; /* Size of cache */
+ uint32_t burst_size; /* Cache burst size */
uint32_t num; /* Number of buffers in cache */
- odp_buffer_hdr_t *buf_hdr[CONFIG_POOL_CACHE_SIZE]; /* Cached buffers */
+ /* Cached buffers */
+ odp_buffer_hdr_t *buf_hdr[CONFIG_POOL_CACHE_MAX_SIZE];
} pool_cache_t;
@@ -92,6 +95,8 @@ typedef struct pool_table_t {
struct {
uint32_t pkt_max_num;
+ uint32_t local_cache_size;
+ uint32_t burst_size;
} config;
} pool_table_t;
diff --git a/platform/linux-generic/odp_pool.c b/platform/linux-generic/odp_pool.c
index 2e0898461..e3f53cfaa 100644
--- a/platform/linux-generic/odp_pool.c
+++ b/platform/linux-generic/odp_pool.c
@@ -36,8 +36,7 @@
#define UNLOCK(a) odp_ticketlock_unlock(a)
#define LOCK_INIT(a) odp_ticketlock_init(a)
-#define CACHE_BURST 32
-#define RING_SIZE_MIN (2 * CACHE_BURST)
+#define RING_SIZE_MIN 64
#define POOL_MAX_NUM_MIN RING_SIZE_MIN
/* Make sure packet buffers don't cross huge page boundaries starting from this
@@ -51,9 +50,6 @@
* rounded up to this value. */
#define BUFFER_ALIGN_MIN ODP_CACHE_LINE_SIZE
-ODP_STATIC_ASSERT(CONFIG_POOL_CACHE_SIZE > (2 * CACHE_BURST),
- "cache_burst_size_too_large_compared_to_cache_size");
-
ODP_STATIC_ASSERT(CONFIG_PACKET_SEG_LEN_MIN >= 256,
"ODP Segment size must be a minimum of 256 bytes");
@@ -94,6 +90,9 @@ static inline pool_t *pool_from_buf(odp_buffer_t buf)
static inline void cache_init(pool_cache_t *cache)
{
memset(cache, 0, sizeof(pool_cache_t));
+
+ cache->size = pool_tbl->config.local_cache_size;
+ cache->burst_size = pool_tbl->config.burst_size;
}
static inline uint32_t cache_pop(pool_cache_t *cache,
@@ -150,6 +149,48 @@ static int read_config_file(pool_table_t *pool_tbl)
ODP_PRINT("Pool config:\n");
+ str = "pool.local_cache_size";
+ if (!_odp_libconfig_lookup_int(str, &val)) {
+ ODP_ERR("Config option '%s' not found.\n", str);
+ return -1;
+ }
+
+ if (val > CONFIG_POOL_CACHE_MAX_SIZE || val < 0) {
+ ODP_ERR("Bad value %s = %u, max %d\n", str, val,
+ CONFIG_POOL_CACHE_MAX_SIZE);
+ return -1;
+ }
+
+ pool_tbl->config.local_cache_size = val;
+ ODP_PRINT(" %s: %i\n", str, val);
+
+ str = "pool.burst_size";
+ if (!_odp_libconfig_lookup_int(str, &val)) {
+ ODP_ERR("Config option '%s' not found.\n", str);
+ return -1;
+ }
+
+ if (val <= 0) {
+ ODP_ERR("Bad value %s = %u\n", str, val);
+ return -1;
+ }
+
+ pool_tbl->config.burst_size = val;
+ ODP_PRINT(" %s: %i\n", str, val);
+
+ /* Check local cache size and burst size relation */
+ if (pool_tbl->config.local_cache_size % pool_tbl->config.burst_size) {
+ ODP_ERR("Pool cache size not multiple of burst size\n");
+ return -1;
+ }
+
+ if (pool_tbl->config.local_cache_size &&
+ (pool_tbl->config.local_cache_size /
+ pool_tbl->config.burst_size < 2)) {
+ ODP_ERR("Cache burst size too large compared to cache size\n");
+ return -1;
+ }
+
str = "pool.pkt.max_num";
if (!_odp_libconfig_lookup_int(str, &val)) {
ODP_ERR("Config option '%s' not found.\n", str);
@@ -832,17 +873,18 @@ int buffer_alloc_multi(pool_t *pool, odp_buffer_hdr_t *buf_hdr[], int max_num)
odp_buffer_hdr_t *hdr;
uint32_t mask, num_ch, i;
uint32_t num_deq = 0;
+ uint32_t burst_size = cache->burst_size;
/* First pull packets from local cache */
num_ch = cache_pop(cache, buf_hdr, max_num);
/* If needed, get more from the global pool */
if (odp_unlikely(num_ch != (uint32_t)max_num)) {
- uint32_t burst = CACHE_BURST;
+ uint32_t burst = burst_size;
uint32_t cache_num;
num_deq = max_num - num_ch;
- if (odp_unlikely(num_deq > CACHE_BURST))
+ if (odp_unlikely(num_deq > burst_size))
burst = num_deq;
uint32_t data[burst];
@@ -891,10 +933,11 @@ static inline void buffer_free_to_pool(pool_t *pool,
ring_t *ring;
int i;
uint32_t cache_num, mask;
+ uint32_t cache_size = cache->size;
/* Special case of a very large free. Move directly to
* the global pool. */
- if (odp_unlikely(num > CONFIG_POOL_CACHE_SIZE)) {
+ if (odp_unlikely(num > (int)cache_size)) {
uint32_t buf_index[num];
ring = &pool->ring->hdr;
@@ -911,13 +954,13 @@ static inline void buffer_free_to_pool(pool_t *pool,
* transfer. */
cache_num = cache->num;
- if (odp_unlikely((int)(CONFIG_POOL_CACHE_SIZE - cache_num) < num)) {
- int burst = CACHE_BURST;
+ if (odp_unlikely((int)(cache_size - cache_num) < num)) {
+ int burst = cache->burst_size;
ring = &pool->ring->hdr;
mask = pool->ring_mask;
- if (odp_unlikely(num > CACHE_BURST))
+ if (odp_unlikely(num > burst))
burst = num;
if (odp_unlikely((uint32_t)num > cache_num))
burst = cache_num;
diff --git a/platform/linux-generic/test/inline-timer.conf b/platform/linux-generic/test/inline-timer.conf
index 6cae241da..36bc7f323 100644
--- a/platform/linux-generic/test/inline-timer.conf
+++ b/platform/linux-generic/test/inline-timer.conf
@@ -1,6 +1,6 @@
# Mandatory fields
odp_implementation = "linux-generic"
-config_file_version = "0.1.6"
+config_file_version = "0.1.7"
timer: {
# Enable inline timer implementation
diff --git a/platform/linux-generic/test/process-mode.conf b/platform/linux-generic/test/process-mode.conf
index fc8974944..12c79617f 100644
--- a/platform/linux-generic/test/process-mode.conf
+++ b/platform/linux-generic/test/process-mode.conf
@@ -1,6 +1,6 @@
# Mandatory fields
odp_implementation = "linux-generic"
-config_file_version = "0.1.6"
+config_file_version = "0.1.7"
# Shared memory options
shm: {