diff mbox series

[RFC,v3,4/5] test/rcu_qsbr: modify test cases for dynamic memory allocation

Message ID 20190222070427.22866-5-honnappa.nagarahalli@arm.com
State New
Headers show
Series rcu: add RCU library supporting QSBR mechanism | expand

Commit Message

Honnappa Nagarahalli Feb. 22, 2019, 7:04 a.m. UTC
Modify the test cases to allocate the QSBR variable dynamically.

Signed-off-by: Honnappa Nagarahalli <honnappa.nagarahalli@arm.com>

---
 test/test/test_rcu_qsbr.c      | 225 ++++++++++++++++++---------------
 test/test/test_rcu_qsbr_perf.c |  33 ++---
 2 files changed, 144 insertions(+), 114 deletions(-)

-- 
2.17.1
diff mbox series

Patch

diff --git a/test/test/test_rcu_qsbr.c b/test/test/test_rcu_qsbr.c
index ae60614af..09744279f 100644
--- a/test/test/test_rcu_qsbr.c
+++ b/test/test/test_rcu_qsbr.c
@@ -15,7 +15,7 @@ 
 #include "test.h"
 
 /* Check condition and return an error if true. */
-#define RCU_QSBR_RETURN_IF_ERROR(cond, str, ...) do { \
+#define TEST_RCU_QSBR_RETURN_IF_ERROR(cond, str, ...) do { \
 	if (cond) { \
 		printf("ERROR file %s, line %d: " str "\n", __FILE__, \
 			__LINE__, ##__VA_ARGS__); \
@@ -23,8 +23,8 @@ 
 	} \
 } while (0)
 
-#define RTE_RCU_MAX_LCORE 128
-uint16_t enabled_core_ids[RTE_RCU_MAX_LCORE];
+#define TEST_RCU_MAX_LCORE 128
+uint16_t enabled_core_ids[TEST_RCU_MAX_LCORE];
 uint8_t num_cores;
 uint16_t num_1qs = 1; /* Number of quiescent states = 1 */
 uint16_t num_2qs = 2; /* Number of quiescent states = 2 */
@@ -33,20 +33,20 @@  uint16_t num_3qs = 3; /* Number of quiescent states = 3 */
 static uint32_t *keys;
 #define TOTAL_ENTRY (1024 * 8)
 #define COUNTER_VALUE 4096
-uint32_t *hash_data[RTE_RCU_MAX_LCORE][TOTAL_ENTRY];
+uint32_t *hash_data[TEST_RCU_MAX_LCORE][TOTAL_ENTRY];
 uint8_t writer_done;
 
-struct rte_rcu_qsbr t[RTE_RCU_MAX_LCORE];
-struct rte_hash *h[RTE_RCU_MAX_LCORE];
-char hash_name[RTE_RCU_MAX_LCORE][8];
+static struct rte_rcu_qsbr *t[TEST_RCU_MAX_LCORE];
+struct rte_hash *h[TEST_RCU_MAX_LCORE];
+char hash_name[TEST_RCU_MAX_LCORE][8];
 
 static inline int
 get_enabled_cores_mask(void)
 {
 	uint16_t core_id;
 	uint32_t max_cores = rte_lcore_count();
-	if (max_cores > RTE_RCU_MAX_LCORE) {
-		printf("Number of cores exceed %d\n", RTE_RCU_MAX_LCORE);
+	if (max_cores > TEST_RCU_MAX_LCORE) {
+		printf("Number of cores exceed %d\n", TEST_RCU_MAX_LCORE);
 		return -1;
 	}
 
@@ -60,6 +60,30 @@  get_enabled_cores_mask(void)
 	return 0;
 }
 
+/*
+ * rte_rcu_qsbr_register_thread: Add a reader thread, to the list of threads
+ * reporting their quiescent state on a QS variable.
+ */
+static int
+test_rcu_qsbr_get_memsize(void)
+{
+	uint32_t sz;
+
+	printf("\nTest rte_rcu_qsbr_register_thread()\n");
+
+	sz = rte_rcu_qsbr_get_memsize(TEST_RCU_MAX_LCORE);
+	t[0] = (struct rte_rcu_qsbr *)rte_zmalloc("rcu0", sz,
+						RTE_CACHE_LINE_SIZE);
+	t[1] = (struct rte_rcu_qsbr *)rte_zmalloc("rcu1", sz,
+						RTE_CACHE_LINE_SIZE);
+	t[2] = (struct rte_rcu_qsbr *)rte_zmalloc("rcu2", sz,
+						RTE_CACHE_LINE_SIZE);
+	t[3] = (struct rte_rcu_qsbr *)rte_zmalloc("rcu3", sz,
+						RTE_CACHE_LINE_SIZE);
+
+	return 0;
+}
+
 /*
  * rte_rcu_qsbr_register_thread: Add a reader thread, to the list of threads
  * reporting their quiescent state on a QS variable.
@@ -69,9 +93,9 @@  test_rcu_qsbr_register_thread(void)
 {
 	printf("\nTest rte_rcu_qsbr_register_thread()\n");
 
-	rte_rcu_qsbr_init(&t[0]);
+	rte_rcu_qsbr_init(t[0], TEST_RCU_MAX_LCORE);
 
-	rte_rcu_qsbr_register_thread(&t[0], enabled_core_ids[0]);
+	rte_rcu_qsbr_register_thread(t[0], enabled_core_ids[0]);
 	return 0;
 }
 
@@ -84,68 +108,68 @@  test_rcu_qsbr_unregister_thread(void)
 {
 	int i, j, ret;
 	uint64_t token;
-	uint8_t num_threads[3] = {1, RTE_RCU_MAX_THREADS, 1};
+	uint8_t num_threads[3] = {1, TEST_RCU_MAX_LCORE, 1};
 
 	printf("\nTest rte_rcu_qsbr_unregister_thread()\n");
 
-	rte_rcu_qsbr_init(&t[0]);
+	rte_rcu_qsbr_init(t[0], TEST_RCU_MAX_LCORE);
 
-	rte_rcu_qsbr_register_thread(&t[0], enabled_core_ids[0]);
+	rte_rcu_qsbr_register_thread(t[0], enabled_core_ids[0]);
 
 	/* Find first disabled core */
-	for (i = 0; i < RTE_RCU_MAX_LCORE; i++) {
+	for (i = 0; i < TEST_RCU_MAX_LCORE; i++) {
 		if (enabled_core_ids[i] == 0)
 			break;
 	}
 	/* Test with disabled lcore */
-	rte_rcu_qsbr_unregister_thread(&t[0], i);
+	rte_rcu_qsbr_unregister_thread(t[0], i);
 
 	/* Test with enabled lcore */
-	rte_rcu_qsbr_unregister_thread(&t[0], enabled_core_ids[0]);
+	rte_rcu_qsbr_unregister_thread(t[0], enabled_core_ids[0]);
 
 	/*
 	 * Test with different thread_ids:
 	 * 1 - thread_id = 0
-	 * 2 - All possible thread_ids, from 0 to RTE_RCU_MAX_THREADS
-	 * 3 - thread_id = RTE_RCU_MAX_THREADS - 1
+	 * 2 - All possible thread_ids, from 0 to TEST_RCU_MAX_LCORE
+	 * 3 - thread_id = TEST_RCU_MAX_LCORE - 1
 	 */
 	for (j = 0; j < 3; j++) {
-		rte_rcu_qsbr_init(&t[0]);
+		rte_rcu_qsbr_init(t[0], TEST_RCU_MAX_LCORE);
 
 		for (i = 0; i < num_threads[j]; i++)
-			rte_rcu_qsbr_register_thread(&t[0],
-				(j == 2) ? (RTE_RCU_MAX_THREADS - 1) : i);
+			rte_rcu_qsbr_register_thread(t[0],
+				(j == 2) ? (TEST_RCU_MAX_LCORE - 1) : i);
 
-		rte_rcu_qsbr_start(&t[0], 1, &token);
-		RCU_QSBR_RETURN_IF_ERROR((token != 1), "QSBR Start");
+		rte_rcu_qsbr_start(t[0], 1, &token);
+		TEST_RCU_QSBR_RETURN_IF_ERROR((token != 1), "QSBR Start");
 		/* Update quiescent state counter */
 		for (i = 0; i < num_threads[j]; i++) {
 			/* Skip one update */
-			if (i == (RTE_RCU_MAX_THREADS - 10))
+			if (i == (TEST_RCU_MAX_LCORE - 10))
 				continue;
-			rte_rcu_qsbr_update(&t[0],
-				(j == 2) ? (RTE_RCU_MAX_THREADS - 1) : i);
+			rte_rcu_qsbr_update(t[0],
+				(j == 2) ? (TEST_RCU_MAX_LCORE - 1) : i);
 		}
 
 		if (j == 1) {
 			/* Validate the updates */
-			ret = rte_rcu_qsbr_check(&t[0], token, false);
-			RCU_QSBR_RETURN_IF_ERROR((ret == 1), "Non-blocking QSBR check");
+			ret = rte_rcu_qsbr_check(t[0], token, false);
+			TEST_RCU_QSBR_RETURN_IF_ERROR((ret == 1), "Non-blocking QSBR check");
 			/* Update the previously skipped thread */
-			rte_rcu_qsbr_update(&t[0], RTE_RCU_MAX_THREADS - 10);
+			rte_rcu_qsbr_update(t[0], TEST_RCU_MAX_LCORE - 10);
 		}
 
 		/* Validate the updates */
-		ret = rte_rcu_qsbr_check(&t[0], token, false);
-		RCU_QSBR_RETURN_IF_ERROR((ret == 0), "Non-blocking QSBR check");
+		ret = rte_rcu_qsbr_check(t[0], token, false);
+		TEST_RCU_QSBR_RETURN_IF_ERROR((ret == 0), "Non-blocking QSBR check");
 
 		for (i = 0; i < num_threads[j]; i++)
-			rte_rcu_qsbr_unregister_thread(&t[0],
-				(j == 2) ? (RTE_RCU_MAX_THREADS - 1) : i);
+			rte_rcu_qsbr_unregister_thread(t[0],
+				(j == 2) ? (TEST_RCU_MAX_LCORE - 1) : i);
 
 		/* Check with no thread registered */
-		ret = rte_rcu_qsbr_check(&t[0], token, true);
-		RCU_QSBR_RETURN_IF_ERROR((ret == 0), "Blocking QSBR check");
+		ret = rte_rcu_qsbr_check(t[0], token, true);
+		TEST_RCU_QSBR_RETURN_IF_ERROR((ret == 0), "Blocking QSBR check");
 	}
 	return 0;
 }
@@ -162,13 +186,13 @@  test_rcu_qsbr_start(void)
 
 	printf("\nTest rte_rcu_qsbr_start()\n");
 
-	rte_rcu_qsbr_init(&t[0]);
+	rte_rcu_qsbr_init(t[0], TEST_RCU_MAX_LCORE);
 
 	for (i = 0; i < 3; i++)
-		rte_rcu_qsbr_register_thread(&t[0], enabled_core_ids[i]);
+		rte_rcu_qsbr_register_thread(t[0], enabled_core_ids[i]);
 
-	rte_rcu_qsbr_start(&t[0], 1, &token);
-	RCU_QSBR_RETURN_IF_ERROR((token != 1), "QSBR Start");
+	rte_rcu_qsbr_start(t[0], 1, &token);
+	TEST_RCU_QSBR_RETURN_IF_ERROR((token != 1), "QSBR Start");
 	return 0;
 }
 
@@ -177,7 +201,7 @@  test_rcu_qsbr_check_reader(void *arg)
 {
 	struct rte_rcu_qsbr *temp;
 	uint8_t read_type = (uint8_t)((uintptr_t)arg);
-	temp = &t[read_type];
+	temp = t[read_type];
 
 	/* Update quiescent state counter */
 	rte_rcu_qsbr_update(temp, enabled_core_ids[0]);
@@ -198,50 +222,50 @@  test_rcu_qsbr_check(void)
 
 	printf("\nTest rte_rcu_qsbr_check()\n");
 
-	rte_rcu_qsbr_init(&t[0]);
+	rte_rcu_qsbr_init(t[0], TEST_RCU_MAX_LCORE);
 
-	rte_rcu_qsbr_start(&t[0], 1, &token);
-	RCU_QSBR_RETURN_IF_ERROR((token != 1), "QSBR Start");
+	rte_rcu_qsbr_start(t[0], 1, &token);
+	TEST_RCU_QSBR_RETURN_IF_ERROR((token != 1), "QSBR Start");
 
 
-	ret = rte_rcu_qsbr_check(&t[0], 0, false);
-	RCU_QSBR_RETURN_IF_ERROR((ret == 0), "Token = 0");
+	ret = rte_rcu_qsbr_check(t[0], 0, false);
+	TEST_RCU_QSBR_RETURN_IF_ERROR((ret == 0), "Token = 0");
 
-	ret = rte_rcu_qsbr_check(&t[0], token, true);
-	RCU_QSBR_RETURN_IF_ERROR((ret == 0), "Blocking QSBR check");
+	ret = rte_rcu_qsbr_check(t[0], token, true);
+	TEST_RCU_QSBR_RETURN_IF_ERROR((ret == 0), "Blocking QSBR check");
 
 	for (i = 0; i < 3; i++)
-		rte_rcu_qsbr_register_thread(&t[0], enabled_core_ids[i]);
+		rte_rcu_qsbr_register_thread(t[0], enabled_core_ids[i]);
 
-	ret = rte_rcu_qsbr_check(&t[0], token, false);
-	RCU_QSBR_RETURN_IF_ERROR((ret == 0), "Non-blocking QSBR check");
+	ret = rte_rcu_qsbr_check(t[0], token, false);
+	TEST_RCU_QSBR_RETURN_IF_ERROR((ret == 0), "Non-blocking QSBR check");
 
-	rte_rcu_qsbr_start(&t[0], 1, &token);
-	RCU_QSBR_RETURN_IF_ERROR((token != 2), "QSBR Start");
+	rte_rcu_qsbr_start(t[0], 1, &token);
+	TEST_RCU_QSBR_RETURN_IF_ERROR((token != 2), "QSBR Start");
 
-	ret = rte_rcu_qsbr_check(&t[0], token, false);
-	RCU_QSBR_RETURN_IF_ERROR((ret == 1), "Non-blocking QSBR check");
+	ret = rte_rcu_qsbr_check(t[0], token, false);
+	TEST_RCU_QSBR_RETURN_IF_ERROR((ret == 1), "Non-blocking QSBR check");
 
 	for (i = 0; i < 3; i++)
-		rte_rcu_qsbr_unregister_thread(&t[0], enabled_core_ids[i]);
+		rte_rcu_qsbr_unregister_thread(t[0], enabled_core_ids[i]);
 
-	ret = rte_rcu_qsbr_check(&t[0], token, true);
-	RCU_QSBR_RETURN_IF_ERROR((ret == 0), "Blocking QSBR check");
+	ret = rte_rcu_qsbr_check(t[0], token, true);
+	TEST_RCU_QSBR_RETURN_IF_ERROR((ret == 0), "Blocking QSBR check");
 
-	rte_rcu_qsbr_init(&t[0]);
+	rte_rcu_qsbr_init(t[0], TEST_RCU_MAX_LCORE);
 
 	for (i = 0; i < 4; i++)
-		rte_rcu_qsbr_register_thread(&t[0], enabled_core_ids[i]);
+		rte_rcu_qsbr_register_thread(t[0], enabled_core_ids[i]);
 
-	rte_rcu_qsbr_start(&t[0], 1, &token);
-	RCU_QSBR_RETURN_IF_ERROR((token != 1), "QSBR Start");
+	rte_rcu_qsbr_start(t[0], 1, &token);
+	TEST_RCU_QSBR_RETURN_IF_ERROR((token != 1), "QSBR Start");
 
 	rte_eal_remote_launch(test_rcu_qsbr_check_reader, NULL,
 							enabled_core_ids[0]);
 
 	rte_eal_mp_wait_lcore();
-	ret = rte_rcu_qsbr_check(&t[0], token, true);
-	RCU_QSBR_RETURN_IF_ERROR((ret != 1), "Blocking QSBR check");
+	ret = rte_rcu_qsbr_check(t[0], token, true);
+	TEST_RCU_QSBR_RETURN_IF_ERROR((ret != 1), "Blocking QSBR check");
 
 	return 0;
 }
@@ -256,19 +280,19 @@  test_rcu_qsbr_dump(void)
 
 	printf("\nTest rte_rcu_qsbr_dump()\n");
 
-	rte_rcu_qsbr_init(&t[0]);
-	rte_rcu_qsbr_init(&t[1]);
+	rte_rcu_qsbr_init(t[0], TEST_RCU_MAX_LCORE);
+	rte_rcu_qsbr_init(t[1], TEST_RCU_MAX_LCORE);
 
 	/* QS variable with 0 core mask */
-	rte_rcu_qsbr_dump(stdout, &t[0]);
+	rte_rcu_qsbr_dump(stdout, t[0]);
 
-	rte_rcu_qsbr_register_thread(&t[0], enabled_core_ids[0]);
+	rte_rcu_qsbr_register_thread(t[0], enabled_core_ids[0]);
 
 	for (i = 1; i < 3; i++)
-		rte_rcu_qsbr_register_thread(&t[1], enabled_core_ids[i]);
+		rte_rcu_qsbr_register_thread(t[1], enabled_core_ids[i]);
 
-	rte_rcu_qsbr_dump(stdout, &t[0]);
-	rte_rcu_qsbr_dump(stdout, &t[1]);
+	rte_rcu_qsbr_dump(stdout, t[0]);
+	rte_rcu_qsbr_dump(stdout, t[1]);
 	printf("\n");
 	return 0;
 }
@@ -283,7 +307,7 @@  test_rcu_qsbr_reader(void *arg)
 	uint8_t read_type = (uint8_t)((uintptr_t)arg);
 	uint32_t *pdata;
 
-	temp = &t[read_type];
+	temp = t[read_type];
 	hash = h[read_type];
 
 	do {
@@ -313,8 +337,8 @@  test_rcu_qsbr_writer(void *arg)
 	struct rte_hash *hash = NULL;
 	uint8_t writer_type = (uint8_t)((uintptr_t)arg);
 
-	temp = &t[(writer_type/2) % RTE_RCU_MAX_LCORE];
-	hash = h[(writer_type/2) % RTE_RCU_MAX_LCORE];
+	temp = t[(writer_type/2) % TEST_RCU_MAX_LCORE];
+	hash = h[(writer_type/2) % TEST_RCU_MAX_LCORE];
 
 	/* Delete element from the shared data structure */
 	pos = rte_hash_del_key(hash, keys + (writer_type % TOTAL_ENTRY));
@@ -330,12 +354,12 @@  test_rcu_qsbr_writer(void *arg)
 	rte_rcu_qsbr_start(temp, writer_type + 1, &token);
 	/* Check the quiescent state status */
 	rte_rcu_qsbr_check(temp, token, true);
-	if (*hash_data[(writer_type/2) % RTE_RCU_MAX_LCORE]
+	if (*hash_data[(writer_type/2) % TEST_RCU_MAX_LCORE]
 	    [writer_type % TOTAL_ENTRY] != COUNTER_VALUE &&
-	    *hash_data[(writer_type/2) % RTE_RCU_MAX_LCORE]
+	    *hash_data[(writer_type/2) % TEST_RCU_MAX_LCORE]
 	    [writer_type % TOTAL_ENTRY] != 0) {
 		printf("Reader did not complete #%d = %d\t", writer_type,
-			*hash_data[(writer_type/2) % RTE_RCU_MAX_LCORE]
+			*hash_data[(writer_type/2) % TEST_RCU_MAX_LCORE]
 				[writer_type % TOTAL_ENTRY]);
 		return -1;
 	}
@@ -345,9 +369,9 @@  test_rcu_qsbr_writer(void *arg)
 		       keys[writer_type % TOTAL_ENTRY]);
 		return -1;
 	}
-	rte_free(hash_data[(writer_type/2) % RTE_RCU_MAX_LCORE]
+	rte_free(hash_data[(writer_type/2) % TEST_RCU_MAX_LCORE]
 				[writer_type % TOTAL_ENTRY]);
-	hash_data[(writer_type/2) % RTE_RCU_MAX_LCORE]
+	hash_data[(writer_type/2) % TEST_RCU_MAX_LCORE]
 			[writer_type % TOTAL_ENTRY] = NULL;
 
 	return 0;
@@ -419,11 +443,11 @@  test_rcu_qsbr_sw_sv_1qs(void)
 	       "Blocking QSBR Check\n");
 
 	/* QS variable is initialized */
-	rte_rcu_qsbr_init(&t[0]);
+	rte_rcu_qsbr_init(t[0], TEST_RCU_MAX_LCORE);
 
 	/* Register worker threads on 4 cores */
 	for (i = 0; i < 4; i++)
-		rte_rcu_qsbr_register_thread(&t[0], enabled_core_ids[i]);
+		rte_rcu_qsbr_register_thread(t[0], enabled_core_ids[i]);
 
 	/* Shared data structure created */
 	h[0] = init_hash(0);
@@ -445,10 +469,10 @@  test_rcu_qsbr_sw_sv_1qs(void)
 			goto error;
 		}
 		/* Start the quiescent state query process */
-		rte_rcu_qsbr_start(&t[0], num_1qs, &token);
+		rte_rcu_qsbr_start(t[0], num_1qs, &token);
 
 		/* Check the quiescent state status */
-		rte_rcu_qsbr_check(&t[0], token, true);
+		rte_rcu_qsbr_check(t[0], token, true);
 		if (*hash_data[0][i] != COUNTER_VALUE &&
 			*hash_data[0][i] != 0) {
 			printf("Reader did not complete #%d =  %d\n", i,
@@ -504,10 +528,10 @@  test_rcu_qsbr_sw_sv_1qs_non_blocking(void)
 	printf("Test: 1 writer, 1 QSBR variable, 1 QSBR Query, "
 	       "Non-Blocking QSBR check\n");
 
-	rte_rcu_qsbr_init(&t[0]);
+	rte_rcu_qsbr_init(t[0], TEST_RCU_MAX_LCORE);
 	/* Register worker threads on 4 cores */
 	for (i = 0; i < 4; i++)
-		rte_rcu_qsbr_register_thread(&t[0], enabled_core_ids[i]);
+		rte_rcu_qsbr_register_thread(t[0], enabled_core_ids[i]);
 
 	/* Shared data structure created */
 	h[0] = init_hash(0);
@@ -529,11 +553,11 @@  test_rcu_qsbr_sw_sv_1qs_non_blocking(void)
 			goto error;
 		}
 		/* Start the quiescent state query process */
-		rte_rcu_qsbr_start(&t[0], num_1qs, &token);
+		rte_rcu_qsbr_start(t[0], num_1qs, &token);
 
 		/* Check the quiescent state status */
 		do {
-			ret = rte_rcu_qsbr_check(&t[0], token, false);
+			ret = rte_rcu_qsbr_check(t[0], token, false);
 		} while (ret == 0);
 		if (*hash_data[0][i] != COUNTER_VALUE &&
 			*hash_data[0][i] != 0) {
@@ -588,11 +612,11 @@  test_rcu_qsbr_sw_sv_3qs(void)
 
 	printf("Test: 1 writer, 1 QSBR variable, simultaneous QSBR queries\n");
 
-	rte_rcu_qsbr_init(&t[0]);
+	rte_rcu_qsbr_init(t[0], TEST_RCU_MAX_LCORE);
 
 	/* Register worker threads on 4 cores */
 	for (i = 0; i < 4; i++)
-		rte_rcu_qsbr_register_thread(&t[0], enabled_core_ids[i]);
+		rte_rcu_qsbr_register_thread(t[0], enabled_core_ids[i]);
 
 	/* Shared data structure created */
 	h[0] = init_hash(0);
@@ -613,7 +637,7 @@  test_rcu_qsbr_sw_sv_3qs(void)
 		goto error;
 	}
 	/* Start the quiescent state query process */
-	rte_rcu_qsbr_start(&t[0], num_1qs, &token[0]);
+	rte_rcu_qsbr_start(t[0], num_1qs, &token[0]);
 
 	/* Delete element from the shared data structure */
 	pos[1] = rte_hash_del_key(h[0], keys + 3);
@@ -625,7 +649,7 @@  test_rcu_qsbr_sw_sv_3qs(void)
 	 * Start the quiescent state query process
 	 * Note: num_2qs kept greater than 1 for test only
 	 */
-	rte_rcu_qsbr_start(&t[0], num_2qs, &token[1]);
+	rte_rcu_qsbr_start(t[0], num_2qs, &token[1]);
 
 	/* Delete element from the shared data structure */
 	pos[2] = rte_hash_del_key(h[0], keys + 6);
@@ -637,10 +661,10 @@  test_rcu_qsbr_sw_sv_3qs(void)
 	 * Start the quiescent state query process
 	 * Note: num_3qs kept greater than 1 for test only
 	 */
-	rte_rcu_qsbr_start(&t[0], num_3qs, &token[2]);
+	rte_rcu_qsbr_start(t[0], num_3qs, &token[2]);
 
 	/* Check the quiescent state status */
-	rte_rcu_qsbr_check(&t[0], token[0], true);
+	rte_rcu_qsbr_check(t[0], token[0], true);
 	if (*hash_data[0][0] != COUNTER_VALUE && *hash_data[0][0] != 0) {
 		printf("Reader did not complete #0 = %d\n", *hash_data[0][0]);
 		goto error;
@@ -654,7 +678,7 @@  test_rcu_qsbr_sw_sv_3qs(void)
 	hash_data[0][0] = NULL;
 
 	/* Check the quiescent state status */
-	rte_rcu_qsbr_check(&t[0], token[1], true);
+	rte_rcu_qsbr_check(t[0], token[1], true);
 	if (*hash_data[0][3] != COUNTER_VALUE && *hash_data[0][3] != 0) {
 		printf("Reader did not complete #3 = %d\n", *hash_data[0][3]);
 		goto error;
@@ -668,7 +692,7 @@  test_rcu_qsbr_sw_sv_3qs(void)
 	hash_data[0][3] = NULL;
 
 	/* Check the quiescent state status */
-	rte_rcu_qsbr_check(&t[0], token[2], true);
+	rte_rcu_qsbr_check(t[0], token[2], true);
 	if (*hash_data[0][6] != COUNTER_VALUE && *hash_data[0][6] != 0) {
 		printf("Reader did not complete #6 = %d\n", *hash_data[0][6]);
 		goto error;
@@ -722,7 +746,7 @@  test_rcu_qsbr_mw_mv_mqs(void)
 	       , test_cores / 2, test_cores / 4);
 
 	for (i = 0; i < num_cores / 4; i++) {
-		rte_rcu_qsbr_init(&t[i]);
+		rte_rcu_qsbr_init(t[i], TEST_RCU_MAX_LCORE);
 		h[i] = init_hash(i);
 		if (h[i] == NULL) {
 			printf("Hash init failed\n");
@@ -732,8 +756,8 @@  test_rcu_qsbr_mw_mv_mqs(void)
 
 	/* Register worker threads on 2 cores */
 	for (i = 0; i < test_cores / 2; i += 2) {
-		rte_rcu_qsbr_register_thread(&t[i / 2], enabled_core_ids[i]);
-		rte_rcu_qsbr_register_thread(&t[i / 2],
+		rte_rcu_qsbr_register_thread(t[i / 2], enabled_core_ids[i]);
+		rte_rcu_qsbr_register_thread(t[i / 2],
 					     enabled_core_ids[i + 1]);
 	}
 
@@ -776,7 +800,7 @@  test_rcu_qsbr_mw_mv_mqs(void)
 	for (i = 0; i < num_cores / 4; i++)
 		rte_hash_free(h[i]);
 	rte_free(keys);
-	for (j = 0; j < RTE_RCU_MAX_LCORE; j++)
+	for (j = 0; j < TEST_RCU_MAX_LCORE; j++)
 		for (i = 0; i < TOTAL_ENTRY; i++)
 			rte_free(hash_data[j][i]);
 
@@ -788,6 +812,9 @@  test_rcu_qsbr_main(void)
 {
 	if (get_enabled_cores_mask() != 0)
 		return -1;
+
+test_rcu_qsbr_get_memsize();
+
 	/* Error-checking test cases */
 	if (test_rcu_qsbr_register_thread() < 0)
 		goto test_fail;
diff --git a/test/test/test_rcu_qsbr_perf.c b/test/test/test_rcu_qsbr_perf.c
index 51af4961d..89c5030bb 100644
--- a/test/test/test_rcu_qsbr_perf.c
+++ b/test/test/test_rcu_qsbr_perf.c
@@ -24,7 +24,7 @@  uint8_t num_cores;
 uint32_t *hash_data[TEST_RCU_MAX_LCORE][TOTAL_ENTRY];
 uint8_t writer_done;
 
-static struct rte_rcu_qsbr t;
+static struct rte_rcu_qsbr *t;
 struct rte_hash *h[TEST_RCU_MAX_LCORE];
 char hash_name[TEST_RCU_MAX_LCORE][8];
 static rte_atomic64_t updates, checks;
@@ -70,13 +70,13 @@  test_rcu_qsbr_reader_perf(void *arg)
 	if (writer_present) {
 		while (!writer_done) {
 			/* Update quiescent state counter */
-			rte_rcu_qsbr_update(&t, lcore_id);
+			rte_rcu_qsbr_update(t, lcore_id);
 			loop_cnt++;
 		}
 	} else {
 		while (loop_cnt < 100000000) {
 			/* Update quiescent state counter */
-			rte_rcu_qsbr_update(&t, lcore_id);
+			rte_rcu_qsbr_update(t, lcore_id);
 			loop_cnt++;
 		}
 	}
@@ -86,7 +86,7 @@  test_rcu_qsbr_reader_perf(void *arg)
 	rte_atomic64_add(&updates, loop_cnt);
 
 	/* Unregister before exiting to avoid writer from waiting */
-	rte_rcu_qsbr_unregister_thread(&t, lcore_id);
+	rte_rcu_qsbr_unregister_thread(t, lcore_id);
 
 	return 0;
 }
@@ -103,10 +103,10 @@  test_rcu_qsbr_writer_perf(void *arg)
 
 	do {
 		/* Start the quiescent state query process */
-		if (wait) rte_rcu_qsbr_start(&t, 1, &token);
+		if (wait) rte_rcu_qsbr_start(t, 1, &token);
 
 		/* Check quiescent state status */
-		rte_rcu_qsbr_check(&t, token, wait);
+		rte_rcu_qsbr_check(t, token, wait);
 		loop_cnt++;
 	} while (loop_cnt < 20000000);
 
@@ -134,11 +134,11 @@  test_rcu_qsbr_perf(void)
 	printf("\nPerf Test: 6 Readers/1 Writer('wait' in qsbr_check == true)\n");
 
 	/* QS variable is initialized */
-	rte_rcu_qsbr_init(&t);
+	rte_rcu_qsbr_init(t, TEST_RCU_MAX_LCORE);
 
 	/* Register worker threads on 6 cores */
 	for (i = 0; i < 6; i++)
-		rte_rcu_qsbr_register_thread(&t, enabled_core_ids[i]);
+		rte_rcu_qsbr_register_thread(t, enabled_core_ids[i]);
 
 	/* Reader threads are launched */
 	for (i = 0; i < 6; i++)
@@ -179,17 +179,15 @@  test_rcu_qsbr_rperf(void)
 
 	rte_atomic64_clear(&updates);
 	rte_atomic64_clear(&update_cycles);
-	rte_atomic64_clear(&checks);
-	rte_atomic64_clear(&check_cycles);
 
 	printf("\nPerf Test: 8 Readers\n");
 
 	/* QS variable is initialized */
-	rte_rcu_qsbr_init(&t);
+	rte_rcu_qsbr_init(t, TEST_RCU_MAX_LCORE);
 
 	/* Register worker threads on 8 cores */
 	for (i = 0; i < 8; i++)
-		rte_rcu_qsbr_register_thread(&t, enabled_core_ids[i]);
+		rte_rcu_qsbr_register_thread(t, enabled_core_ids[i]);
 
 	/* Reader threads are launched */
 	for (i = 0; i < 8; i++)
@@ -200,6 +198,8 @@  test_rcu_qsbr_rperf(void)
 	rte_eal_mp_wait_lcore();
 
 	printf("Total RCU updates = %ld\n", rte_atomic64_read(&updates));
+	printf("Total update cycles = %ld\n",
+			rte_atomic64_read(&update_cycles));
 	printf("Cycles per %d updates: %lu\n", RCU_SCALE_DOWN,
 		rte_atomic64_read(&update_cycles) /
 		(rte_atomic64_read(&updates) / RCU_SCALE_DOWN));
@@ -216,15 +216,13 @@  test_rcu_qsbr_wperf(void)
 {
 	int i;
 
-	rte_atomic64_clear(&updates);
-	rte_atomic64_clear(&update_cycles);
 	rte_atomic64_clear(&checks);
 	rte_atomic64_clear(&check_cycles);
 
 	printf("\nPerf test: 8 Writers ('wait' in qsbr_check == false)\n");
 
 	/* QS variable is initialized */
-	rte_rcu_qsbr_init(&t);
+	rte_rcu_qsbr_init(t, TEST_RCU_MAX_LCORE);
 
 	/* Writer threads are launched */
 	for (i = 0; i < 8; i++)
@@ -245,6 +243,8 @@  test_rcu_qsbr_wperf(void)
 static int
 test_rcu_qsbr_main(void)
 {
+	uint32_t sz;
+
 	rte_atomic64_init(&updates);
 	rte_atomic64_init(&update_cycles);
 	rte_atomic64_init(&checks);
@@ -253,6 +253,9 @@  test_rcu_qsbr_main(void)
 	if (get_enabled_cores_mask() != 0)
 		return -1;
 
+	sz = rte_rcu_qsbr_get_memsize(TEST_RCU_MAX_LCORE);
+	t = (struct rte_rcu_qsbr *)rte_zmalloc("rcu", sz, RTE_CACHE_LINE_SIZE);
+
 	if (test_rcu_qsbr_perf() < 0)
 		goto test_fail;