diff mbox series

[v3,3/10] helper: cuckoo: check pool and queue limits

Message ID 1519819218-27901-4-git-send-email-odpbot@yandex.ru
State New
Headers show
Series [v3,1/10] linux-gen: queue: inline queue from index conversion | expand

Commit Message

Github ODP bot Feb. 28, 2018, noon UTC
From: Petri Savolainen <petri.savolainen@linaro.org>


Use capability to check if pool and queue can hold enough events.
Also lower test case resource requirement.

Signed-off-by: Petri Savolainen <petri.savolainen@linaro.org>

---
/** Email created from pull request 492 (psavol:master-sched-optim)
 ** https://github.com/Linaro/odp/pull/492
 ** Patch: https://github.com/Linaro/odp/pull/492.patch
 ** Base sha: f5e12df388352b27f09787028a0040afb28564f4
 ** Merge commit sha: 56e6340663c8679516a24dc81df13a53488b86b8
 **/
 helper/cuckootable.c      | 22 ++++++++++++++++++++++
 helper/test/cuckootable.c |  2 +-
 2 files changed, 23 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/helper/cuckootable.c b/helper/cuckootable.c
index 1dc43b57b..febfa28ed 100644
--- a/helper/cuckootable.c
+++ b/helper/cuckootable.c
@@ -184,6 +184,8 @@  odph_cuckoo_table_create(
 
 	odp_queue_t queue;
 	odp_queue_param_t qparam;
+	odp_queue_capability_t qcapa;
+	odp_pool_capability_t pcapa;
 
 	char pool_name[ODPH_TABLE_NAME_LEN + 3],
 		 queue_name[ODPH_TABLE_NAME_LEN + 3];
@@ -191,6 +193,26 @@  odph_cuckoo_table_create(
 	uint32_t impl_size, kv_entry_size,
 			 bucket_num, bucket_size;
 
+	if (odp_queue_capability(&qcapa)) {
+		ODPH_DBG("queue capa failed\n");
+		return NULL;
+	}
+
+	if (qcapa.plain.max_size && qcapa.plain.max_size < capacity) {
+		ODPH_DBG("queue max_size too small\n");
+		return NULL;
+	}
+
+	if (odp_pool_capability(&pcapa)) {
+		ODPH_DBG("pool capa failed\n");
+		return NULL;
+	}
+
+	if (pcapa.buf.max_num && pcapa.buf.max_num < capacity) {
+		ODPH_DBG("pool max_num too small\n");
+		return NULL;
+	}
+
 	/* Check for valid parameters */
 	if (
 	    (capacity > HASH_ENTRIES_MAX) ||
diff --git a/helper/test/cuckootable.c b/helper/test/cuckootable.c
index 7798f94e7..3afa490a6 100644
--- a/helper/test/cuckootable.c
+++ b/helper/test/cuckootable.c
@@ -429,7 +429,7 @@  static int test_creation_with_bad_parameters(void)
 	return 0;
 }
 
-#define PERFORMANCE_CAPACITY 1000000
+#define PERFORMANCE_CAPACITY 4000
 
 /*
  * Test the performance of cuckoo hash table.