[v3,4/10] validation: sched: honour max queue size

Message ID 1519819218-27901-5-git-send-email-odpbot@yandex.ru
State New
Headers show
Series
  • Ring implementation of queues
Related show

Commit Message

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


When needed, scale down atomic queue size requirement
to maximum queue size capability.

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
 **/
 test/validation/api/scheduler/scheduler.c | 21 ++++++++++++++-------
 1 file changed, 14 insertions(+), 7 deletions(-)

Patch

diff --git a/test/validation/api/scheduler/scheduler.c b/test/validation/api/scheduler/scheduler.c
index 098c03a0a..d5783b4d2 100644
--- a/test/validation/api/scheduler/scheduler.c
+++ b/test/validation/api/scheduler/scheduler.c
@@ -57,6 +57,7 @@  typedef struct {
 	odp_barrier_t barrier;
 	int buf_count;
 	int buf_count_cpy;
+	uint32_t max_sched_queue_size;
 	odp_ticketlock_t lock;
 	odp_spinlock_t atomic_lock;
 	struct {
@@ -1060,7 +1061,7 @@  static void parallel_execute(odp_schedule_sync_t sync, int num_queues,
 	args->num_queues = num_queues;
 	args->num_prio = num_prio;
 	if (enable_excl_atomic)
-		args->num_bufs = BUFS_PER_QUEUE_EXCL;
+		args->num_bufs = globals->max_sched_queue_size;
 	else
 		args->num_bufs = BUFS_PER_QUEUE;
 	args->num_workers = globals->num_workers;
@@ -1405,7 +1406,7 @@  static void scheduler_test_ordered_lock(void)
 	CU_ASSERT(ret == 0);
 }
 
-static int create_queues(void)
+static int create_queues(test_globals_t *globals)
 {
 	int i, j, prios, rc;
 	odp_queue_capability_t capa;
@@ -1427,6 +1428,12 @@  static int create_queues(void)
 		       capa.max_ordered_locks);
 	}
 
+	globals->max_sched_queue_size = BUFS_PER_QUEUE_EXCL;
+	if (capa.sched.max_size && capa.sched.max_size < BUFS_PER_QUEUE_EXCL) {
+		printf("Max sched queue size %u\n", capa.sched.max_size);
+		globals->max_sched_queue_size = capa.sched.max_size;
+	}
+
 	prios = odp_schedule_num_prio();
 	odp_pool_param_init(&params);
 	params.buf.size = sizeof(queue_context);
@@ -1455,17 +1462,17 @@  static int create_queues(void)
 			q = odp_queue_create(name, &p);
 
 			if (q == ODP_QUEUE_INVALID) {
-				printf("Schedule queue create failed.\n");
+				printf("Parallel queue create failed.\n");
 				return -1;
 			}
 
 			snprintf(name, sizeof(name), "sched_%d_%d_a", i, j);
 			p.sched.sync = ODP_SCHED_SYNC_ATOMIC;
-			p.size = BUFS_PER_QUEUE_EXCL;
+			p.size = globals->max_sched_queue_size;
 			q = odp_queue_create(name, &p);
 
 			if (q == ODP_QUEUE_INVALID) {
-				printf("Schedule queue create failed.\n");
+				printf("Atomic queue create failed.\n");
 				return -1;
 			}
 
@@ -1501,7 +1508,7 @@  static int create_queues(void)
 			q = odp_queue_create(name, &p);
 
 			if (q == ODP_QUEUE_INVALID) {
-				printf("Schedule queue create failed.\n");
+				printf("Ordered queue create failed.\n");
 				return -1;
 			}
 			if (odp_queue_lock_count(q) !=
@@ -1598,7 +1605,7 @@  static int scheduler_suite_init(void)
 	odp_ticketlock_init(&globals->lock);
 	odp_spinlock_init(&globals->atomic_lock);
 
-	if (create_queues() != 0)
+	if (create_queues(globals) != 0)
 		return -1;
 
 	return 0;