Skip to contentSkip to conversation

test/hash: reset iter and found in perf test

PATCH Superseded Dharmik Thakkar 4 participants 6 messages Nov 29, 2018 – Jan 14, 2019

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 test/hash: reset iter and found in perf test

Reset 'iter' and 'tbl_rw_test_param.found' on each iteration to give correct result for lost and duplicated keys.

Fixes 0eb3726ebcf14 ("test/hash: add test for read/write concurrency")
---
 test/test/test_hash_readwrite.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
test/test/test_hash_readwrite.c +3 -2
index 6b695ce6e444..be93a2ebd270 100644
@@ -361,7 +361,6 @@ test_hash_readwrite_perf(struct perf *perf_results, int use_htm,
 
 	const void *next_key;
 	void *next_data;
-	uint32_t iter = 0;
 	int use_jhash = 0;
 
 	uint32_t duplicated_keys = 0;
@@ -536,6 +535,8 @@ test_hash_readwrite_perf(struct perf *perf_results, int use_htm,
 
 		rte_eal_mp_wait_lcore();
 
+		uint32_t iter = 0;
+		memset(tbl_rw_test_param.found, 0, TOTAL_ENTRY);
 		while (rte_hash_iterate(tbl_rw_test_param.h,
 				&next_key, &next_data, &iter) >= 0) {
 			/* Search for the key in the list of keys added .*/
@@ -619,7 +620,7 @@ test_hash_readwrite_main(void)
 	if (rte_lcore_count() <= 2) {
 		printf("More than two lcores are required "
 			"to do read write test\n");
-		return 0;
+		return -1;
 	}
 
 	RTE_LCORE_FOREACH_SLAVE(core_id) {
Signature · 1 line
2.17.1
#1 lore raw
Quoted 24 lines · Dharmik Thakkar

Reset 'iter' and 'tbl_rw_test_param.found' on each iteration to give correct result for lost and duplicated keys.

Fixes 0eb3726ebcf14 ("test/hash: add test for read/write concurrency")
---
 test/test/test_hash_readwrite.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
test/test/test_hash_readwrite.c +0 -1
index 6b695ce6e444..be93a2ebd270 100644
@@ -361,7 +361,6 @@ test_hash_readwrite_perf(struct perf *perf_results, int use_htm,
 
 	const void *next_key;
 	void *next_data;
-	uint32_t iter = 0;
 	int use_jhash = 0;
 
 	uint32_t duplicated_keys = 0;

test/test/test_hash_readwrite.c test_hash_readwrite_perf(struct perf *perf_results, int use_htm, · line 538

Quoted 4 lines
test/test/test_hash_readwrite.c +1 -0
@@ -536,6 +535,8 @@ test_hash_readwrite_perf(struct perf *perf_results, int use_htm,
 
 		rte_eal_mp_wait_lcore();
 
+		uint32_t iter = 0;

Logically looks good. Only we don't tend to declare the variables in the middle of the scope, you may prefer to keep deceleration at its place but set 'iter' to zero here.

test/test/test_hash_readwrite.c test_hash_readwrite_main(void) · line 623

Quoted 10 lines
test/test/test_hash_readwrite.c +2 -1
+		memset(tbl_rw_test_param.found, 0, TOTAL_ENTRY);
 		while (rte_hash_iterate(tbl_rw_test_param.h,
 				&next_key, &next_data, &iter) >= 0) {
 			/* Search for the key in the list of keys added .*/
@@ -619,7 +620,7 @@ test_hash_readwrite_main(void)
 	if (rte_lcore_count() <= 2) {
 		printf("More than two lcores are required "
 			"to do read write test\n");
-		return 0;
+		return -1;

This is something not mentioned in the commit log, changes the default return value of test when not enough resources provided, cc'ed Yipeng for comment.

If decided to keep this change, please update commit log to mention from it.

#2 lore raw

Thanks for the bug fix! Nice catch!

Quoted 10 lines

-----Original Message-----
From: Yigit, Ferruh
Sent: Friday, January 11, 2019 9:10 AM
To: Dharmik Thakkar <[email protected]>; Richardson, Bruce <[email protected]>; De Lara Guarch, Pablo <[email protected]>
Cc: [email protected]; [email protected]; Wang, Yipeng1 <[email protected]>
Subject: Re: [dpdk-stable] [PATCH] test/hash: reset iter and found in perf test

Quoted 3 lines
test/test/test_hash_readwrite.c +0 -0
 	uint32_t duplicated_keys = 0;
@@ -536,6 +535,8 @@ test_hash_readwrite_perf(struct perf *perf_results, int use_htm,
 
Quoted 7 lines

test/test/test_hash_readwrite.c test_hash_readwrite_perf(struct perf *perf_results, int use_htm, · line 538

Quoted 3 lines
test/test/test_hash_readwrite.c +1 -0
 		rte_eal_mp_wait_lcore();
 
+		uint32_t iter = 0;

Logically looks good. Only we don't tend to declare the variables in the middle of the scope, you may prefer to keep deceleration at its place but set 'iter' to zero here.

[Wang, Yipeng] Agree.

Quoted 2 lines

test/test/test_hash_readwrite.c test_hash_readwrite_perf(struct perf *perf_results, int use_htm, · line 539

Quoted 2 lines
test/test/test_hash_readwrite.c +1 -0
+		memset(tbl_rw_test_param.found, 0, TOTAL_ENTRY);

[Wang, Yipeng] test failed because of this line I think, the found is uint32_t array, so should be TOTAL_ENTRY * 4, or just change found to be int8

Quoted 13 lines

test/test/test_hash_readwrite.c test_hash_readwrite_main(void) · line 623

Quoted 9 lines
test/test/test_hash_readwrite.c +1 -1
 		while (rte_hash_iterate(tbl_rw_test_param.h,
 				&next_key, &next_data, &iter) >= 0) {
 			/* Search for the key in the list of keys added .*/
@@ -619,7 +620,7 @@ test_hash_readwrite_main(void)
 	if (rte_lcore_count() <= 2) {
 		printf("More than two lcores are required "
 			"to do read write test\n");
-		return 0;
+		return -1;

This is something not mentioned in the commit log, changes the default return value of test when not enough resources provided, cc'ed Yipeng for comment.

Quoted 1 line

If decided to keep this change, please update commit log to mention from it.

[Wang, Yipeng] Yes it should be -1. Thanks for the fix. Please fix the commit msg as Ferruh suggested

#3 lore raw

Thank you Ferruh and Yipeng! I will make the recommended changes and update the version.

Quoted 42 lines · On Jan 12, 2019, at 12:07 AM, Wang, Yipeng1 <[email protected]> wrote:

Thanks for the bug fix! Nice catch!

Quoted 10 lines

-----Original Message-----
From: Yigit, Ferruh
Sent: Friday, January 11, 2019 9:10 AM
To: Dharmik Thakkar <[email protected]>; Richardson, Bruce <[email protected]>; De Lara Guarch, Pablo <[email protected]>
Cc: [email protected]; [email protected]; Wang, Yipeng1 <[email protected]>
Subject: Re: [dpdk-stable] [PATCH] test/hash: reset iter and found in perf test

Quoted 3 lines
	uint32_t duplicated_keys = 0;
(quoted diff) +0 -0
@@ -536,6 +535,8 @@ test_hash_readwrite_perf(struct perf *perf_results, int use_htm,
 
Quoted 7 lines

test/test/test_hash_readwrite.c test_hash_readwrite_perf(struct perf *perf_results, int use_htm, · line 538

Quoted 3 lines
test/test/test_hash_readwrite.c +1 -0
 		rte_eal_mp_wait_lcore();
 
+		uint32_t iter = 0;

Logically looks good. Only we don't tend to declare the variables in the middle of the scope, you may prefer to keep deceleration at its place but set 'iter' to zero here.

[Wang, Yipeng] Agree.

Quoted 2 lines

test/test/test_hash_readwrite.c test_hash_readwrite_perf(struct perf *perf_results, int use_htm, · line 539

Quoted 2 lines
test/test/test_hash_readwrite.c +1 -0
+		memset(tbl_rw_test_param.found, 0, TOTAL_ENTRY);

[Wang, Yipeng] test failed because of this line I think, the found is uint32_t array, so should be TOTAL_ENTRY * 4, or just change found to be int8

Quoted 13 lines

test/test/test_hash_readwrite.c test_hash_readwrite_main(void) · line 623

Quoted 9 lines
test/test/test_hash_readwrite.c +1 -1
 		while (rte_hash_iterate(tbl_rw_test_param.h,
 				&next_key, &next_data, &iter) >= 0) {
 			/* Search for the key in the list of keys added .*/
@@ -619,7 +620,7 @@ test_hash_readwrite_main(void)
 	if (rte_lcore_count() <= 2) {
 		printf("More than two lcores are required "
 			"to do read write test\n");
-		return 0;
+		return -1;

This is something not mentioned in the commit log, changes the default return value of test when not enough resources provided, cc'ed Yipeng for comment.

Quoted 1 line

If decided to keep this change, please update commit log to mention from it.

[Wang, Yipeng] Yes it should be -1. Thanks for the fix. Please fix the commit msg as Ferruh suggested

#4 lore raw

PATCH v2 1/1 test/hash: reset iter and found in perf test

In reply to Dharmik Thakkar

Reset 'iter' and 'tbl_rw_test_param.found' on each iteration to give correct result for lost and duplicated keys.

This patch also changes the default return value of the test to -1 when not enough resources are provided.

Fixes 0eb3726ebcf14 ("test/hash: add test for read/write concurrency")

--
v2:
* Update commit message
* Change 'found' array type to uint8_t
* Restore declaration of 'iter' to the start

---
 test/test/test_hash_readwrite.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)
test/test/test_hash_readwrite.c +7 -5
index 6b695ce6e444..480ae97d857d 100644
@@ -39,7 +39,7 @@ static struct perf htm_results, non_htm_results;
 
 struct {
 	uint32_t *keys;
-	uint32_t *found;
+	uint8_t *found;
 	uint32_t num_insert;
 	uint32_t rounded_tot_insert;
 	struct rte_hash *h;
@@ -126,7 +126,7 @@ init_params(int use_ext, int use_htm, int use_jhash)
 	unsigned int i;
 
 	uint32_t *keys = NULL;
-	uint32_t *found = NULL;
+	uint8_t *found = NULL;
 	struct rte_hash *handle;
 
 	struct rte_hash_parameters hash_params = {
@@ -173,7 +173,7 @@ init_params(int use_ext, int use_htm, int use_jhash)
 		goto err;
 	}
 
-	found = rte_zmalloc(NULL, sizeof(uint32_t) * TOTAL_ENTRY, 0);
+	found = rte_zmalloc(NULL, sizeof(uint8_t) * TOTAL_ENTRY, 0);
 	if (found == NULL) {
 		printf("RTE_ZMALLOC failed\n");
 		goto err;
@@ -361,7 +361,7 @@ test_hash_readwrite_perf(struct perf *perf_results, int use_htm,
 
 	const void *next_key;
 	void *next_data;
-	uint32_t iter = 0;
+	uint32_t iter;
 	int use_jhash = 0;
 
 	uint32_t duplicated_keys = 0;
@@ -536,6 +536,8 @@ test_hash_readwrite_perf(struct perf *perf_results, int use_htm,
 
 		rte_eal_mp_wait_lcore();
 
+		iter = 0;
+		memset(tbl_rw_test_param.found, 0, TOTAL_ENTRY);
 		while (rte_hash_iterate(tbl_rw_test_param.h,
 				&next_key, &next_data, &iter) >= 0) {
 			/* Search for the key in the list of keys added .*/
@@ -619,7 +621,7 @@ test_hash_readwrite_main(void)
 	if (rte_lcore_count() <= 2) {
 		printf("More than two lcores are required "
 			"to do read write test\n");
-		return 0;
+		return -1;
 	}
 
 	RTE_LCORE_FOREACH_SLAVE(core_id) {
Signature · 1 line
2.17.1
#5 lore raw

14/01/2019 10:23, Dharmik Thakkar:

Quoted 6 lines

Reset 'iter' and 'tbl_rw_test_param.found' on each iteration to give correct result for lost and duplicated keys.

This patch also changes the default return value of the test to -1 when not enough resources are provided.

Quoted 6 lines
Fixes 0eb3726ebcf14 ("test/hash: add test for read/write concurrency")

Applied, thanks