[v2] app/test: fix PMD perf test on devices with no socket ID

Message ID 20221024071214.20980-1-olivier.matz@6wind.com (mailing list archive)
State Accepted, archived
Delegated to: David Marchand
Headers
Series [v2] app/test: fix PMD perf test on devices with no socket ID |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK
ci/iol-intel-Functional success Functional Testing PASS
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-aarch64-compile-testing success Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-aarch64-unit-testing success Testing PASS
ci/iol-x86_64-compile-testing success Testing PASS
ci/github-robot: build success github build: passed
ci/iol-x86_64-unit-testing success Testing PASS
ci/intel-Testing success Testing PASS

Commit Message

Olivier Matz Oct. 24, 2022, 7:12 a.m. UTC
  If the socket ID of a device is unknown, rte_eth_dev_socket_id(portid)
now returns -1 instead of 0 since commit 7dcd73e37965 ("drivers/bus: set
device NUMA node to unknown by default").

This change breaks the pmd_perf test on environment where the device
socket ID is unknown. The test fails with the following error, because
it does not find a lcore on socket -1:

> No avail lcore to run test

Take the new behavior in account in the pmd_perf test: in this
environment, the test can now run on any lcore, and not only those from
socket 0 (this was the old behavior).

Bugzilla ID: 1105
Fixes: 7dcd73e37965 ("drivers/bus: set device NUMA node to unknown by default")

Signed-off-by: Olivier Matz <olivier.matz@6wind.com>
---

v2:
* fix typo (-SOCKET_ID_ANY instead of SOCKET_ID_ANY)

 app/test/test_pmd_perf.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)
  

Comments

David Marchand Oct. 24, 2022, 11:37 a.m. UTC | #1
On Mon, Oct 24, 2022 at 9:12 AM Olivier Matz <olivier.matz@6wind.com> wrote:
>
> If the socket ID of a device is unknown, rte_eth_dev_socket_id(portid)
> now returns -1 instead of 0 since commit 7dcd73e37965 ("drivers/bus: set
> device NUMA node to unknown by default").
>
> This change breaks the pmd_perf test on environment where the device
> socket ID is unknown. The test fails with the following error, because
> it does not find a lcore on socket -1:
>
> > No avail lcore to run test
>
> Take the new behavior in account in the pmd_perf test: in this
> environment, the test can now run on any lcore, and not only those from
> socket 0 (this was the old behavior).
>
> Bugzilla ID: 1105
> Fixes: 7dcd73e37965 ("drivers/bus: set device NUMA node to unknown by default")
>
> Signed-off-by: Olivier Matz <olivier.matz@6wind.com>

From the bugzilla comments:
Tested-by: Lingli Chen <linglix.chen@intel.com>

Reviewed-by: David Marchand <david.marchand@redhat.com>

Applied, thanks.
  

Patch

diff --git a/app/test/test_pmd_perf.c b/app/test/test_pmd_perf.c
index fe765c4173..ff84d251ff 100644
--- a/app/test/test_pmd_perf.c
+++ b/app/test/test_pmd_perf.c
@@ -265,13 +265,14 @@  init_mbufpool(unsigned nb_mbuf)
 }
 
 static uint16_t
-alloc_lcore(uint16_t socketid)
+alloc_lcore(int socketid)
 {
 	unsigned lcore_id;
 
 	for (lcore_id = 0; lcore_id < RTE_MAX_LCORE; lcore_id++) {
 		if (LCORE_AVAIL != lcore_conf[lcore_id].status ||
-		    lcore_conf[lcore_id].socketid != socketid ||
+		    (socketid != SOCKET_ID_ANY &&
+		     lcore_conf[lcore_id].socketid != socketid) ||
 		    lcore_id == rte_get_main_lcore())
 			continue;
 		lcore_conf[lcore_id].status = LCORE_USED;
@@ -711,17 +712,18 @@  test_pmd_perf(void)
 	num = 0;
 	RTE_ETH_FOREACH_DEV(portid) {
 		if (socketid == -1) {
-			socketid = rte_eth_dev_socket_id(portid);
-			worker_id = alloc_lcore(socketid);
+			worker_id = alloc_lcore(rte_eth_dev_socket_id(portid));
 			if (worker_id == (uint16_t)-1) {
 				printf("No avail lcore to run test\n");
 				return -1;
 			}
+			socketid = rte_lcore_to_socket_id(worker_id);
 			printf("Performance test runs on lcore %u socket %u\n",
 			       worker_id, socketid);
 		}
 
-		if (socketid != rte_eth_dev_socket_id(portid)) {
+		if (socketid != rte_eth_dev_socket_id(portid) &&
+		    rte_eth_dev_socket_id(portid) != SOCKET_ID_ANY) {
 			printf("Skip port %d\n", portid);
 			continue;
 		}