diff mbox series

[v1,5/10] test: pktio_ordered: honour max queue size

Message ID 1519214407-28047-6-git-send-email-odpbot@yandex.ru
State Superseded
Headers show
Series [v1,1/10] linux-gen: queue: inline queue from index conversion | expand

Commit Message

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


Limit maximum number of events to maximum pool and queue
capability when needed. Pool size should not be larger than
queue size as test run in validation suite suffers from queue
enqueue failures (queue full) and sequence number checking
does not pass due to that.

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: 5a58bbf2bb331fd7dde2ebbc0430634ace6900fb
 ** Merge commit sha: 82a6bfe942419330a430b63149220e6b472f419c
 **/
 test/performance/odp_pktio_ordered.c | 44 +++++++++++++++++++++++++++---------
 1 file changed, 33 insertions(+), 11 deletions(-)
diff mbox series

Patch

diff --git a/test/performance/odp_pktio_ordered.c b/test/performance/odp_pktio_ordered.c
index db9bfe764..0a1c556cc 100644
--- a/test/performance/odp_pktio_ordered.c
+++ b/test/performance/odp_pktio_ordered.c
@@ -75,12 +75,12 @@ 
 
 #define JHASH_GOLDEN_RATIO	0x9e3779b9
 
+/* Maximum pool and queue size */
+#define MAX_NUM_PKT             (8 * 1024)
+
 /** Maximum number of worker threads */
 #define MAX_WORKERS		64
 
-/** Number of packet buffers in the memory pool */
-#define PKT_POOL_SIZE		8192
-
 /** Buffer size of the packet pool buffer in bytes*/
 #define PKT_POOL_BUF_SIZE	1856
 
@@ -93,9 +93,6 @@ 
 /** Maximum number of pktio queues per interface */
 #define MAX_QUEUES		32
 
-/** Seems to need at least 8192 elements per queue */
-#define QUEUE_SIZE		8192
-
 /** Maximum number of pktio interfaces */
 #define MAX_PKTIOS		8
 
@@ -1074,7 +1071,8 @@  int main(int argc, char *argv[])
 	odp_pool_t pool;
 	odp_pool_param_t params;
 	odp_shm_t shm;
-	odp_queue_capability_t capa;
+	odp_queue_capability_t queue_capa;
+	odp_pool_capability_t pool_capa;
 	odph_ethaddr_t new_addr;
 	odph_odpthread_t thread_tbl[MAX_WORKERS];
 	stats_t *stats;
@@ -1085,6 +1083,7 @@  int main(int argc, char *argv[])
 	int ret;
 	int num_workers;
 	int in_mode;
+	uint32_t queue_size, pool_size;
 
 	/* Init ODP before calling anything else */
 	if (odp_init_global(&instance, NULL, NULL)) {
@@ -1098,6 +1097,16 @@  int main(int argc, char *argv[])
 		exit(EXIT_FAILURE);
 	}
 
+	if (odp_queue_capability(&queue_capa)) {
+		LOG_ERR("Error: Queue capa failed\n");
+		exit(EXIT_FAILURE);
+	}
+
+	if (odp_pool_capability(&pool_capa)) {
+		LOG_ERR("Error: Pool capa failed\n");
+		exit(EXIT_FAILURE);
+	}
+
 	/* Reserve memory for args from shared mem */
 	shm = odp_shm_reserve("shm_args", sizeof(args_t),
 			      ODP_CACHE_LINE_SIZE, 0);
@@ -1121,8 +1130,7 @@  int main(int argc, char *argv[])
 
 	if (gbl_args->appl.in_mode == SCHED_ORDERED) {
 		/* At least one ordered lock required  */
-		odp_queue_capability(&capa);
-		if (capa.max_ordered_locks < 1) {
+		if (queue_capa.max_ordered_locks < 1) {
 			LOG_ERR("Error: Ordered locks not available.\n");
 			exit(EXIT_FAILURE);
 		}
@@ -1145,11 +1153,25 @@  int main(int argc, char *argv[])
 	printf("First CPU:          %i\n", odp_cpumask_first(&cpumask));
 	printf("CPU mask:           %s\n\n", cpumaskstr);
 
+	pool_size = MAX_NUM_PKT;
+	if (pool_capa.pkt.max_num && pool_capa.pkt.max_num < MAX_NUM_PKT)
+		pool_size = pool_capa.pkt.max_num;
+
+	queue_size = MAX_NUM_PKT;
+	if (queue_capa.sched.max_size &&
+	    queue_capa.sched.max_size < MAX_NUM_PKT)
+		queue_size = queue_capa.sched.max_size;
+
+	/* Pool should not be larger than queue, otherwise queue enqueues at
+	 * packet input may fail. */
+	if (pool_size > queue_size)
+		pool_size = queue_size;
+
 	/* Create packet pool */
 	odp_pool_param_init(&params);
 	params.pkt.seg_len = PKT_POOL_BUF_SIZE;
 	params.pkt.len     = PKT_POOL_BUF_SIZE;
-	params.pkt.num     = PKT_POOL_SIZE;
+	params.pkt.num     = pool_size;
 	params.pkt.uarea_size = PKT_UAREA_SIZE;
 	params.type        = ODP_POOL_PACKET;
 
@@ -1225,7 +1247,7 @@  int main(int argc, char *argv[])
 			qparam.sched.prio = ODP_SCHED_PRIO_DEFAULT;
 			qparam.sched.sync = ODP_SCHED_SYNC_ATOMIC;
 			qparam.sched.group = ODP_SCHED_GROUP_ALL;
-			qparam.size	  = QUEUE_SIZE;
+			qparam.size	  = queue_size;
 
 			gbl_args->flow_qcontext[i][j].idx = i;
 			gbl_args->flow_qcontext[i][j].input_queue = 0;