Skip to contentSkip to conversation

test/service: fix wait for service core

PATCH Applied Harry van Haaren 3 participants 7 messages Nov 27, 2019

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 test/service: fix wait for service core

This commit fixes a sporadic failure of the service_autotest unit test, as seen in the DPDK CI. The failure occurs as the main test thread did not wait on the service-thread to return, and allowing it to read a flag before the service was able to write to it.

The fix changes the wait API call to specific the service-core ID, and this waits for cores with both ROLE_RTE and ROLE_SERVICE.

The rte_eal_mp_wait_lcore() call does not (and should not) wait for service cores, so must not be used to wait on service-cores.

Fixes f038a81e1c56 ("service: add unit tests")

---

Given this is a fix in the unit test, and not a functional change I'm not sure its worth backporting to LTS / stable releases? I've not added stable on CC yet.

---
 app/test/test_service_cores.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
app/test/test_service_cores.c +1 -1
index 9fe38f5e0..a922c7ddc 100644
@@ -483,7 +483,7 @@ service_lcore_en_dis_able(void)
 	int ret = rte_eal_remote_launch(service_remote_launch_func, NULL,
 					slcore_id);
 	TEST_ASSERT_EQUAL(0, ret, "Ex-service core remote launch failed.");
-	rte_eal_mp_wait_lcore();
+	rte_eal_wait_lcore(slcore_id);
 	TEST_ASSERT_EQUAL(1, service_remote_launch_flag,
 			"Ex-service core function call had no effect.");
 
Signature · 1 line
2.17.1
#1 lore raw
Quoted 11 lines · Harry van Haaren

This commit fixes a sporadic failure of the service_autotest unit test, as seen in the DPDK CI. The failure occurs as the main test thread did not wait on the service-thread to return, and allowing it to read a flag before the service was able to write to it.

The fix changes the wait API call to specific the service-core ID, and this waits for cores with both ROLE_RTE and ROLE_SERVICE.

The rte_eal_mp_wait_lcore() call does not (and should not) wait for service cores, so must not be used to wait on service-cores.

Quoted 6 lines
Fixes f038a81e1c56 ("service: add unit tests")

---

It might also be good to document this behavior in the API area. It's unclear that the lcore wait function which takes a core id will work, but the broad wait will not.

Quoted 3 lines

Given this is a fix in the unit test, and not a functional change I'm not sure its worth backporting to LTS / stable releases? I've not added stable on CC yet.

I think it's worth it if the LTS / stable branches use the unit tests (otherwise, they will observe sporadic failures).

Quoted 9 lines
---
 app/test/test_service_cores.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
app/test/test_service_cores.c +0 -0
index 9fe38f5e0..a922c7ddc 100644

app/test/test_service_cores.c service_lcore_en_dis_able(void) · line 488

Quoted 7 lines
app/test/test_service_cores.c +1 -1
@@ -483,7 +483,7 @@ service_lcore_en_dis_able(void)
 	int ret = rte_eal_remote_launch(service_remote_launch_func, NULL,
 					slcore_id);
 	TEST_ASSERT_EQUAL(0, ret, "Ex-service core remote launch failed.");
-	rte_eal_mp_wait_lcore();
+	rte_eal_wait_lcore(slcore_id);
 	TEST_ASSERT_EQUAL(1, service_remote_launch_flag,
 			"Ex-service core function call had no effect.");

Should we also have some change like the following (just a guess):

app/test/test_service_cores.c +1 -1
index 9fe38f5e08..695c35ac6c 100644
@@ -773,7 +773,7 @@ service_app_lcore_poll_impl(const int mt_safe)
 
 	/* flag done, then wait for the spawned 2nd core to return */
 	params[0] = 1;
-	rte_eal_mp_wait_lcore();
+	rte_eal_wait_lcore(app_core2);
 
 	/* core two gets launched first - and should hold the service lock */
 	TEST_ASSERT_EQUAL(0, app_core2_ret,
#2 lore raw
Quoted 22 lines

-----Original Message-----
From: Aaron Conole <[email protected]>
Sent: Wednesday, November 27, 2019 2:10 PM
To: Van Haaren, Harry <[email protected]>
Cc: [email protected]
Subject: Re: [PATCH] test/service: fix wait for service core

Quoted 13 lines · Harry van Haaren

This commit fixes a sporadic failure of the service_autotest unit test, as seen in the DPDK CI. The failure occurs as the main test thread did not wait on the service-thread to return, and allowing it to read a flag before the service was able to write to it.

The fix changes the wait API call to specific the service-core ID, and this waits for cores with both ROLE_RTE and ROLE_SERVICE.

The rte_eal_mp_wait_lcore() call does not (and should not) wait for service cores, so must not be used to wait on service-cores.

Fixes f038a81e1c56 ("service: add unit tests")
Quoted 8 lines
Quoted 4 lines

---

It might also be good to document this behavior in the API area. It's unclear that the lcore wait function which takes a core id will work, but the broad wait will not.

Yes agreed that docs can improve here - different patch.

Quoted 6 lines
Quoted 3 lines

Given this is a fix in the unit test, and not a functional change I'm not sure its worth backporting to LTS / stable releases? I've not added stable on CC yet.

I think it's worth it if the LTS / stable branches use the unit tests (otherwise, they will observe sporadic failures).

Ok, I've added [email protected] on CC now

Quoted 23 lines
Quoted 8 lines
 app/test/test_service_cores.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
app/test/test_service_cores.c +0 -0
index 9fe38f5e0..a922c7ddc 100644

app/test/test_service_cores.c service_lcore_en_dis_able(void) · line 488

Quoted 7 lines
app/test/test_service_cores.c +1 -1
@@ -483,7 +483,7 @@ service_lcore_en_dis_able(void)
 	int ret = rte_eal_remote_launch(service_remote_launch_func, NULL,
 					slcore_id);
 	TEST_ASSERT_EQUAL(0, ret, "Ex-service core remote launch failed.");
-	rte_eal_mp_wait_lcore();
+	rte_eal_wait_lcore(slcore_id);
 	TEST_ASSERT_EQUAL(1, service_remote_launch_flag,
 			"Ex-service core function call had no effect.");

Should we also have some change like the following (just a guess):

app/test/test_service_cores.c +0 -0
index 9fe38f5e08..695c35ac6c 100644

app/test/test_service_cores.c service_app_lcore_poll_impl(const int mt_safe) · line 779

Quoted 8 lines
app/test/test_service_cores.c +1 -1
@@ -773,7 +773,7 @@ service_app_lcore_poll_impl(const int mt_safe)
 
 	/* flag done, then wait for the spawned 2nd core to return */
 	params[0] = 1;
-	rte_eal_mp_wait_lcore();
+	rte_eal_wait_lcore(app_core2);
 
 	/* core two gets launched first - and should hold the service lock */
 	TEST_ASSERT_EQUAL(0, app_core2_ret,

I reviewed this usage of the function, and I believe it waits on application cores (aka, ROLE_RTE, not ROLE_SERVICE). Hence this usage is actually correct. Please review and double check my logic though - more eyes is good.

#3 lore raw
Quoted 74 lines · Harry
Quoted 23 lines

-----Original Message-----
From: Aaron Conole <[email protected]>
Sent: Wednesday, November 27, 2019 2:10 PM
To: Van Haaren, Harry <[email protected]>
Cc: [email protected]
Subject: Re: [PATCH] test/service: fix wait for service core

Quoted 13 lines · Harry van Haaren

This commit fixes a sporadic failure of the service_autotest unit test, as seen in the DPDK CI. The failure occurs as the main test thread did not wait on the service-thread to return, and allowing it to read a flag before the service was able to write to it.

The fix changes the wait API call to specific the service-core ID, and this waits for cores with both ROLE_RTE and ROLE_SERVICE.

The rte_eal_mp_wait_lcore() call does not (and should not) wait for service cores, so must not be used to wait on service-cores.

Fixes f038a81e1c56 ("service: add unit tests")
Quoted 8 lines
Quoted 4 lines

---

It might also be good to document this behavior in the API area. It's unclear that the lcore wait function which takes a core id will work, but the broad wait will not.

Yes agreed that docs can improve here - different patch.

Quoted 6 lines
Quoted 3 lines

Given this is a fix in the unit test, and not a functional change I'm not sure its worth backporting to LTS / stable releases? I've not added stable on CC yet.

I think it's worth it if the LTS / stable branches use the unit tests (otherwise, they will observe sporadic failures).

Ok, I've added [email protected] on CC now

Quoted 29 lines
Quoted 8 lines
 app/test/test_service_cores.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
app/test/test_service_cores.c +0 -0
index 9fe38f5e0..a922c7ddc 100644

app/test/test_service_cores.c service_lcore_en_dis_able(void) · line 488

Quoted 7 lines
app/test/test_service_cores.c +1 -1
@@ -483,7 +483,7 @@ service_lcore_en_dis_able(void)
    int ret = rte_eal_remote_launch(service_remote_launch_func, NULL,
                                    slcore_id);
    TEST_ASSERT_EQUAL(0, ret, "Ex-service core remote launch failed.");
-   rte_eal_mp_wait_lcore();
+   rte_eal_wait_lcore(slcore_id);
    TEST_ASSERT_EQUAL(1, service_remote_launch_flag,
                    "Ex-service core function call had no effect.");

Should we also have some change like the following (just a guess):

app/test/test_service_cores.c +1 -1
index 9fe38f5e08..695c35ac6c 100644
@@ -773,7 +773,7 @@ service_app_lcore_poll_impl(const int mt_safe)
 
      /* flag done, then wait for the spawned 2nd core to return */
      params[0] = 1;
-     rte_eal_mp_wait_lcore();
+     rte_eal_wait_lcore(app_core2);
 
Quoted 8 lines

app/test/test_service_cores.c service_app_lcore_poll_impl(const int mt_safe) · line 779

Quoted 2 lines
app/test/test_service_cores.c +0 -0
      /* core two gets launched first - and should hold the service lock */
      TEST_ASSERT_EQUAL(0, app_core2_ret,

I reviewed this usage of the function, and I believe it waits on application cores (aka, ROLE_RTE, not ROLE_SERVICE). Hence this usage is actually correct. Please review and double check my logic though - more eyes is good.

I will check it later tonight but I am for taking this in 19.11 if we can get more stable tests.
Aaron, do you have an objection?

Signature · 1 line
David Marchand
#4 lore raw
Quoted 85 lines · David Marchand
Quoted 74 lines · Harry
Quoted 23 lines

-----Original Message-----
From: Aaron Conole <[email protected]>
Sent: Wednesday, November 27, 2019 2:10 PM
To: Van Haaren, Harry <[email protected]>
Cc: [email protected]
Subject: Re: [PATCH] test/service: fix wait for service core

Quoted 13 lines · Harry van Haaren

This commit fixes a sporadic failure of the service_autotest unit test, as seen in the DPDK CI. The failure occurs as the main test thread did not wait on the service-thread to return, and allowing it to read a flag before the service was able to write to it.

The fix changes the wait API call to specific the service-core ID, and this waits for cores with both ROLE_RTE and ROLE_SERVICE.

The rte_eal_mp_wait_lcore() call does not (and should not) wait for service cores, so must not be used to wait on service-cores.

Fixes f038a81e1c56 ("service: add unit tests")
Quoted 8 lines
Quoted 4 lines

---

It might also be good to document this behavior in the API area. It's unclear that the lcore wait function which takes a core id will work, but the broad wait will not.

Yes agreed that docs can improve here - different patch.

Quoted 6 lines
Quoted 3 lines

Given this is a fix in the unit test, and not a functional change I'm not sure its worth backporting to LTS / stable releases? I've not added stable on CC yet.

I think it's worth it if the LTS / stable branches use the unit tests (otherwise, they will observe sporadic failures).

Ok, I've added [email protected] on CC now

Quoted 29 lines
Quoted 8 lines
 app/test/test_service_cores.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
app/test/test_service_cores.c +0 -0
index 9fe38f5e0..a922c7ddc 100644

app/test/test_service_cores.c service_lcore_en_dis_able(void) · line 488

Quoted 7 lines
app/test/test_service_cores.c +1 -1
@@ -483,7 +483,7 @@ service_lcore_en_dis_able(void)
    int ret = rte_eal_remote_launch(service_remote_launch_func, NULL,
                                    slcore_id);
    TEST_ASSERT_EQUAL(0, ret, "Ex-service core remote launch failed.");
-   rte_eal_mp_wait_lcore();
+   rte_eal_wait_lcore(slcore_id);
    TEST_ASSERT_EQUAL(1, service_remote_launch_flag,
                    "Ex-service core function call had no effect.");

Should we also have some change like the following (just a guess):

app/test/test_service_cores.c +1 -1
index 9fe38f5e08..695c35ac6c 100644
@@ -773,7 +773,7 @@ service_app_lcore_poll_impl(const int mt_safe)
 
      /* flag done, then wait for the spawned 2nd core to return */
      params[0] = 1;
-     rte_eal_mp_wait_lcore();
+     rte_eal_wait_lcore(app_core2);
 
Quoted 8 lines

app/test/test_service_cores.c service_app_lcore_poll_impl(const int mt_safe) · line 779

Quoted 2 lines
app/test/test_service_cores.c +0 -0
      /* core two gets launched first - and should hold the service lock */
      TEST_ASSERT_EQUAL(0, app_core2_ret,

I reviewed this usage of the function, and I believe it waits on application cores (aka, ROLE_RTE, not ROLE_SERVICE). Hence this usage is actually correct. Please review and double check my logic though - more eyes is good.

Quoted 3 lines

I will check it later tonight but I am for taking this in 19.11 if we can get more stable tests.
Aaron, do you have an objection?

No objection

#5 lore raw
In reply to Van Haaren, Harry
Quoted 74 lines · Harry
Quoted 23 lines

-----Original Message-----
From: Aaron Conole <[email protected]>
Sent: Wednesday, November 27, 2019 2:10 PM
To: Van Haaren, Harry <[email protected]>
Cc: [email protected]
Subject: Re: [PATCH] test/service: fix wait for service core

Quoted 13 lines · Harry van Haaren

This commit fixes a sporadic failure of the service_autotest unit test, as seen in the DPDK CI. The failure occurs as the main test thread did not wait on the service-thread to return, and allowing it to read a flag before the service was able to write to it.

The fix changes the wait API call to specific the service-core ID, and this waits for cores with both ROLE_RTE and ROLE_SERVICE.

The rte_eal_mp_wait_lcore() call does not (and should not) wait for service cores, so must not be used to wait on service-cores.

Fixes f038a81e1c56 ("service: add unit tests")
Quoted 8 lines
Quoted 4 lines

---

It might also be good to document this behavior in the API area. It's unclear that the lcore wait function which takes a core id will work, but the broad wait will not.

Yes agreed that docs can improve here - different patch.

Quoted 6 lines
Quoted 3 lines

Given this is a fix in the unit test, and not a functional change I'm not sure its worth backporting to LTS / stable releases? I've not added stable on CC yet.

I think it's worth it if the LTS / stable branches use the unit tests (otherwise, they will observe sporadic failures).

Ok, I've added [email protected] on CC now

Quoted 29 lines
Quoted 8 lines
 app/test/test_service_cores.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
app/test/test_service_cores.c +0 -0
index 9fe38f5e0..a922c7ddc 100644

app/test/test_service_cores.c service_lcore_en_dis_able(void) · line 488

Quoted 7 lines
app/test/test_service_cores.c +1 -1
@@ -483,7 +483,7 @@ service_lcore_en_dis_able(void)
    int ret = rte_eal_remote_launch(service_remote_launch_func, NULL,
                                    slcore_id);
    TEST_ASSERT_EQUAL(0, ret, "Ex-service core remote launch failed.");
-   rte_eal_mp_wait_lcore();
+   rte_eal_wait_lcore(slcore_id);
    TEST_ASSERT_EQUAL(1, service_remote_launch_flag,
                    "Ex-service core function call had no effect.");

Should we also have some change like the following (just a guess):

app/test/test_service_cores.c +1 -1
index 9fe38f5e08..695c35ac6c 100644
@@ -773,7 +773,7 @@ service_app_lcore_poll_impl(const int mt_safe)
 
      /* flag done, then wait for the spawned 2nd core to return */
      params[0] = 1;
-     rte_eal_mp_wait_lcore();
+     rte_eal_wait_lcore(app_core2);
 
Quoted 7 lines

app/test/test_service_cores.c service_app_lcore_poll_impl(const int mt_safe) · line 779

Quoted 2 lines
app/test/test_service_cores.c +0 -0
      /* core two gets launched first - and should hold the service lock */
      TEST_ASSERT_EQUAL(0, app_core2_ret,

I reviewed this usage of the function, and I believe it waits on application cores (aka, ROLE_RTE, not ROLE_SERVICE). Hence this usage is actually correct. Please review and double check my logic though - more eyes is good.

It seems to be the case, yes.
My overall feeling is that the services stuff is a giant hack, so better documentation will prove me wrong :-).

As I said I am for taking this change in 19.11 now, as it only impacts this test and it seems to solve the random failures.

Signature · 1 line
David Marchand
Acked-by on v1 1/1 Applied
#6 lore raw
In reply to Harry van Haaren
Quoted 6 lines · Harry van Haaren

This commit fixes a sporadic failure of the service_autotest unit test, as seen in the DPDK CI. The failure occurs as the main test thread did not wait on the service-thread to return, and allowing it to read a flag before the service was able to write to it.

Quoted 7 lines

The fix changes the wait API call to specific the service-core ID, and this waits for cores with both ROLE_RTE and ROLE_SERVICE.

The rte_eal_mp_wait_lcore() call does not (and should not) wait for service cores, so must not be used to wait on service-cores.

Fixes f038a81e1c56 ("service: add unit tests")
Quoted 3 lines

Before this patch, reproduced the pb in less than 2 minutes with:

# time (log=/tmp/$$.log; while true; do echo service_autotest |taskset
-c 0-1 build-gcc-static/app/test/dpdk-test --log-level *:8 -l 0-1
Quoted 1 line

$log 2>&1; grep -q 'Test OK' $log || break; done; cat $log; rm -f

$log)

With the patch, this loop has been running for 40 minutes.

Applied, thanks.

--
David Marchand