[v4] test/rcu: fix build for small number of cores

Message ID 1574652993-17755-1-git-send-email-gavin.hu@arm.com (mailing list archive)
State Accepted, archived
Delegated to: Thomas Monjalon
Headers
Series [v4] test/rcu: fix build for small number of cores |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-compilation success Compile Testing PASS
ci/iol-mellanox-Performance success Performance Testing PASS
ci/travis-robot success Travis build: passed
ci/Intel-compilation fail Compilation issues

Commit Message

Gavin Hu Nov. 25, 2019, 3:36 a.m. UTC
  If the RTE_MAX_LCORE is less than 10, a compilation error is generated:
app/test/test_rcu_qsbr.c:234:10: error: comparison of integer
expressions of different signedness: ‘unsigned int’ and ‘int’
[-Werror=sign-compare]

The cause is (RTE_MAX_LCORE - 10) results in a negative value.

To fix, use rte_rand() to find a number between 0 and RTE_MAX_LCORE.

Fixes: b87089b0bb19 ("test/rcu: add API and functional tests")
Cc: stable@dpdk.org

Signed-off-by: Gavin Hu <gavin.hu@arm.com>
Reviewed-by: Honnappa Nagarahalli <honnappa.nagarahalli@arm.com>
Reviewed-by: Steve Capper <steve.capper@arm.com>
Reviewed-by: Dharmik Thakkar <dharmik.thakkar@arm.com>
---
v4:
- separate from the N1SDP configuration patch series
- fix the build for smaller number of cores(Thomas Monjalon)
---
 app/test/test_rcu_qsbr.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
  

Comments

Thomas Monjalon Nov. 25, 2019, 10:40 p.m. UTC | #1
25/11/2019 04:36, Gavin Hu:
> If the RTE_MAX_LCORE is less than 10, a compilation error is generated:
> app/test/test_rcu_qsbr.c:234:10: error: comparison of integer
> expressions of different signedness: ‘unsigned int’ and ‘int’
> [-Werror=sign-compare]
> 
> The cause is (RTE_MAX_LCORE - 10) results in a negative value.
> 
> To fix, use rte_rand() to find a number between 0 and RTE_MAX_LCORE.
> 
> Fixes: b87089b0bb19 ("test/rcu: add API and functional tests")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Gavin Hu <gavin.hu@arm.com>
> Reviewed-by: Honnappa Nagarahalli <honnappa.nagarahalli@arm.com>
> Reviewed-by: Steve Capper <steve.capper@arm.com>
> Reviewed-by: Dharmik Thakkar <dharmik.thakkar@arm.com>

Applied, thanks
  

Patch

diff --git a/app/test/test_rcu_qsbr.c b/app/test/test_rcu_qsbr.c
index 85d80e0..b60dc50 100644
--- a/app/test/test_rcu_qsbr.c
+++ b/app/test/test_rcu_qsbr.c
@@ -9,6 +9,7 @@ 
 #include <rte_hash_crc.h>
 #include <rte_malloc.h>
 #include <rte_cycles.h>
+#include <rte_random.h>
 #include <unistd.h>
 
 #include "test.h"
@@ -168,6 +169,7 @@  test_rcu_qsbr_thread_unregister(void)
 {
 	unsigned int num_threads[3] = {1, RTE_MAX_LCORE, 1};
 	unsigned int i, j;
+	unsigned int skip_thread_id;
 	uint64_t token;
 	int ret;
 
@@ -227,10 +229,11 @@  test_rcu_qsbr_thread_unregister(void)
 		token = rte_rcu_qsbr_start(t[0]);
 		TEST_RCU_QSBR_RETURN_IF_ERROR(
 			(token != (TEST_RCU_QSBR_CNT_INIT + 1)), "QSBR Start");
+		skip_thread_id = rte_rand() % RTE_MAX_LCORE;
 		/* Update quiescent state counter */
 		for (i = 0; i < num_threads[j]; i++) {
 			/* Skip one update */
-			if (i == (RTE_MAX_LCORE - 10))
+			if ((j == 1) && (i == skip_thread_id))
 				continue;
 			rte_rcu_qsbr_quiescent(t[0],
 				(j == 2) ? (RTE_MAX_LCORE - 1) : i);
@@ -242,7 +245,7 @@  test_rcu_qsbr_thread_unregister(void)
 			TEST_RCU_QSBR_RETURN_IF_ERROR((ret == 0),
 						"Non-blocking QSBR check");
 			/* Update the previously skipped thread */
-			rte_rcu_qsbr_quiescent(t[0], RTE_MAX_LCORE - 10);
+			rte_rcu_qsbr_quiescent(t[0], skip_thread_id);
 		}
 
 		/* Validate the updates */