aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatias Elo <matias.elo@nokia.com>2019-04-10 08:45:32 +0300
committerMatias Elo <matias.elo@nokia.com>2019-04-15 10:32:36 +0300
commit939166d4414609717264e6f51f51d4b22cdd022a (patch)
treed6c79e5b4dd59b3daf5b462de1777d2ded48edcb
parent5fd772d236db2059935d12ab27fcbf1f50d10591 (diff)
downloadodp-939166d4414609717264e6f51f51d4b22cdd022a.tar.gz
linux-gen: pool: warn about entire pool fitting into thread local caches
Add debug print when entire pool fits into thread local caches. Pool starvation may occur if the pool is used by multiple threads. Signed-off-by: Matias Elo <matias.elo@nokia.com> Reviewed-by: Petri Savolainen <petri.savolainen@nokia.com> Suggested-by: Mikko Kurikka <mikko.kurikka@nokia.com>
-rw-r--r--platform/linux-generic/odp_pool.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/platform/linux-generic/odp_pool.c b/platform/linux-generic/odp_pool.c
index e3f53cfaa..832991d32 100644
--- a/platform/linux-generic/odp_pool.c
+++ b/platform/linux-generic/odp_pool.c
@@ -681,12 +681,22 @@ error:
static int check_params(odp_pool_param_t *params)
{
odp_pool_capability_t capa;
+ odp_bool_t cache_warning = false;
+ uint32_t cache_size = pool_tbl->config.local_cache_size;
+ int num_threads = odp_global_ro.init_param.num_control +
+ odp_global_ro.init_param.num_worker;
if (!params || odp_pool_capability(&capa) < 0)
return -1;
+ if (num_threads)
+ cache_size = num_threads * pool_tbl->config.local_cache_size;
+
switch (params->type) {
case ODP_POOL_BUFFER:
+ if (params->buf.num <= cache_size)
+ cache_warning = true;
+
if (params->buf.num > capa.buf.max_num) {
ODP_ERR("buf.num too large %u\n", params->buf.num);
return -1;
@@ -705,6 +715,9 @@ static int check_params(odp_pool_param_t *params)
break;
case ODP_POOL_PACKET:
+ if (params->pkt.num <= cache_size)
+ cache_warning = true;
+
if (params->pkt.num > capa.pkt.max_num) {
ODP_ERR("pkt.num too large %u\n", params->pkt.num);
return -1;
@@ -748,6 +761,9 @@ static int check_params(odp_pool_param_t *params)
break;
case ODP_POOL_TIMEOUT:
+ if (params->tmo.num <= cache_size)
+ cache_warning = true;
+
if (params->tmo.num > capa.tmo.max_num) {
ODP_ERR("tmo.num too large %u\n", params->tmo.num);
return -1;
@@ -759,6 +775,11 @@ static int check_params(odp_pool_param_t *params)
return -1;
}
+ if (cache_warning)
+ ODP_DBG("Entire pool fits into thread local caches. Pool "
+ "starvation may occur if the pool is used by multiple "
+ "threads.\n");
+
return 0;
}