Skip to contentSkip to conversation

test: fix mempool perf test enq_count wraparound of 32-bit uint

PATCH Superseded David Hunt 4 participants 5 messages May 26, 2016 – Jun 13, 2016

lore
Share & tools
lore

David Hunt

author
#0 lore raw

PATCH 1/1 test: fix mempool perf test enq_count wraparound of 32-bit uint

recent CPU's can easily wrap around a 32-bit unsigned int in the mempool perf test. Increase to a 64-bit uint.

---
 app/test/test_mempool_perf.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
app/test/test_mempool_perf.c +3 -3
index cdc02a0..2f48545 100644
@@ -110,7 +110,7 @@ static unsigned n_keep;
 
 /* number of enqueues / dequeues */
 struct mempool_test_stats {
-	unsigned enq_count;
+	uint64_t enq_count;
 } __rte_cache_aligned;
 
 static struct mempool_test_stats stats[RTE_MAX_LCORE];
@@ -189,7 +189,7 @@ static int
 launch_cores(unsigned cores)
 {
 	unsigned lcore_id;
-	unsigned rate;
+	uint64_t rate;
 	int ret;
 	unsigned cores_save = cores;
 
@@ -238,7 +238,7 @@ launch_cores(unsigned cores)
 	for (lcore_id = 0; lcore_id < RTE_MAX_LCORE; lcore_id++)
 		rate += (stats[lcore_id].enq_count / TIME_S);
 
-	printf("rate_persec=%u\n", rate);
+	printf("rate_persec=%lu\n", rate);
 
 	return 0;
 }
Signature · 1 line
2.5.5
#1 lore raw
Quoted 31 lines · David Hunt

recent CPU's can easily wrap around a 32-bit unsigned int in the mempool perf test. Increase to a 64-bit uint.

---
 app/test/test_mempool_perf.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
app/test/test_mempool_perf.c +2 -2
index cdc02a0..2f48545 100644
@@ -110,7 +110,7 @@ static unsigned n_keep;
 
 /* number of enqueues / dequeues */
 struct mempool_test_stats {
-	unsigned enq_count;
+	uint64_t enq_count;
 } __rte_cache_aligned;
 
 static struct mempool_test_stats stats[RTE_MAX_LCORE];
@@ -189,7 +189,7 @@ static int
 launch_cores(unsigned cores)
 {
 	unsigned lcore_id;
-	unsigned rate;
+	uint64_t rate;
 	int ret;
 	unsigned cores_save = cores;
 

app/test/test_mempool_perf.c launch_cores(unsigned cores) · line 241

Quoted 5 lines
app/test/test_mempool_perf.c +1 -1
@@ -238,7 +238,7 @@ launch_cores(unsigned cores)
 	for (lcore_id = 0; lcore_id < RTE_MAX_LCORE; lcore_id++)
 		rate += (stats[lcore_id].enq_count / TIME_S);
 
-	printf("rate_persec=%u\n", rate);
+	printf("rate_persec=%lu\n", rate);

Use PRIu64 instead of %lu, as %lu is only 32-bit on 32-bit systems.

/Bruce

author
#2 lore raw

PATCH v2 1/1 test: fix mempool perf test enq_count wraparound of 32-bit uint

In reply to David Hunt

recent CPU's can easily wrap around a 32-bit unsigned int in the mempool perf test. Increase to a 64-bit uint.

v2: change from %lu to %"PRIu64"

---
 app/test/test_mempool_perf.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
app/test/test_mempool_perf.c +3 -3
index cdc02a0..0fc8110 100644
@@ -110,7 +110,7 @@ static unsigned n_keep;
 
 /* number of enqueues / dequeues */
 struct mempool_test_stats {
-	unsigned enq_count;
+	uint64_t enq_count;
 } __rte_cache_aligned;
 
 static struct mempool_test_stats stats[RTE_MAX_LCORE];
@@ -189,7 +189,7 @@ static int
 launch_cores(unsigned cores)
 {
 	unsigned lcore_id;
-	unsigned rate;
+	uint64_t rate;
 	int ret;
 	unsigned cores_save = cores;
 
@@ -238,7 +238,7 @@ launch_cores(unsigned cores)
 	for (lcore_id = 0; lcore_id < RTE_MAX_LCORE; lcore_id++)
 		rate += (stats[lcore_id].enq_count / TIME_S);
 
-	printf("rate_persec=%u\n", rate);
+	printf("rate_persec=%"PRIu64"\n", rate);
 
 	return 0;
 }
Signature · 1 line
2.5.5