service: fix wrong lcore indexes
PATCH 1/1 service: fix wrong lcore indexes
From: Igor Romanov <[email protected]>
The service core list is populated, but not used. Incorrect lcore states are examined for a service.
Use the populated list to iterate over service cores.
--- lib/librte_eal/common/rte_service.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
lib/librte_eal/common/rte_service.c +1 -1
@@ -422,7 +422,7 @@ rte_service_may_be_active(uint32_t id)return -EINVAL ;for (i =0 ; i < lcore_count; i++) { -if (lcore_states[i].service_active_on_lcore[id]) +if (lcore_states[ids[i]].service_active_on_lcore[id])return 1 ; }
Signature · 1 line
2.17.1
Hi Andrew/Igor,
A effective test case is missing for this, can you please add a test case? Otherwise it looks good.
Quoted 7 lines
-----Original Message-----
From: dev <[email protected]> On Behalf Of Andrew Rybchenko
Sent: Saturday, July 4, 2020 9:36 AM
To: [email protected]
Cc: Igor Romanov <[email protected]>; [email protected]; Harry van Haaren <[email protected]>
Subject: [dpdk-dev] [PATCH] service: fix wrong lcore indexes
Nit, 'indices' would be better? ^^^^^^^
Quoted 33 lines
From: Igor Romanov <[email protected]>
The service core list is populated, but not used. Incorrect lcore states are examined for a service.
Use the populated list to iterate over service cores.
Fixes e30dd31847d2 ("service: add mechanism for quiescing")Signed-off-by Igor Romanov <[email protected]>Signed-off-by Andrew Rybchenko <[email protected]>--- lib/librte_eal/common/rte_service.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)lib/librte_eal/common/rte_service.c +1
-2@@ -422,7 +422,7 @@ rte_service_may_be_active(uint32_t id)return -EINVAL ;for (i =0 ; i < lcore_count; i++) { -if (lcore_states[i].service_active_on_lcore[id]) +if (lcore_states[ids[i]].service_active_on_lcore[id])return 1 ; } --2.17.1
Quoted 3 lines · Honnappa Nagarahalli
Hi Andrew/Igor,
A effective test case is missing for this, can you please add a test case? Otherwise it looks good.
+1, I was about to reply this.
Signature · 1 line
David Marchand
Quoted 7 lines · David Marchand
Quoted 3 lines · Honnappa Nagarahalli
Hi Andrew/Igor,
A effective test case is missing for this, can you please add a test case? Otherwise it looks good.+1, I was about to reply this.
Done in v2
PATCH v2 1/2 service: fix wrong lcore indices
In reply to Andrew RybchenkoFrom: Igor Romanov <[email protected]>
The service core list is populated, but not used. Incorrect lcore states are examined for a service.
Use the populated list to iterate over service cores.
--- lib/librte_eal/common/rte_service.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
lib/librte_eal/common/rte_service.c +1 -1
@@ -422,7 +422,7 @@ rte_service_may_be_active(uint32_t id)return -EINVAL ;for (i =0 ; i < lcore_count; i++) { -if (lcore_states[i].service_active_on_lcore[id]) +if (lcore_states[ids[i]].service_active_on_lcore[id])return 1 ; }
Signature · 1 line
2.17.1
PATCH v2 2/2 test/service: add test for service active on two lcores
From: Igor Romanov <[email protected]>
The test checks that the service may be active API works when there are two cores: a non-service lcore and a service one.
The API notes to take care when checking the status of a running service, but the test setup allows for a safe usage in that case.
--- app/test/test_service_cores.c | 50 +++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+)
app/test/test_service_cores.c +50 -0
@@ -910,6 +910,55 @@ service_may_be_active(void)return unregister_all (); } +/* check service may be active when service is running on a second lcore */ +static int +service_active_two_cores (void ) +{ +const uint32_t sid =0 ; +int i; + +uint32_t lcore =rte_get_next_lcore (/* start core */ -1 , +/* skip master */ 1 , +/* wrap */ 0 ); +uint32_t slcore =rte_get_next_lcore (/* start core */ lcore, +/* skip master */ 1 , +/* wrap */ 0 ); + +/* start the service on the second available lcore */ +TEST_ASSERT_EQUAL (0 ,rte_service_runstate_set (sid,1 ), +"Starting valid service failed" ); +TEST_ASSERT_EQUAL (0 ,rte_service_lcore_add (slcore), +"Add service core failed when not in use before" ); +TEST_ASSERT_EQUAL (0 ,rte_service_map_lcore_set (sid, slcore,1 ), +"Enabling valid service on valid core failed" ); +TEST_ASSERT_EQUAL (0 ,rte_service_lcore_start (slcore), +"Service core start after add failed" ); + +/* ensures core really is running the service function */ +TEST_ASSERT_EQUAL (1 ,service_lcore_running_check (), +"Service core expected to poll service but it didn't" ); + +/* ensures that service may be active reports running state */ +TEST_ASSERT_EQUAL (1 ,rte_service_may_be_active (sid), +"Service may be active did not report running state" ); + +/* stop the service */ +TEST_ASSERT_EQUAL (0 ,rte_service_runstate_set (sid,0 ), +"Error: Service stop returned non-zero" ); + +/* give the service 100ms to stop running */ +for (i =0 ; i <100 ; i++) { +if (!rte_service_may_be_active (sid)) +break ; +rte_delay_ms (SERVICE_DELAY ); + } + +TEST_ASSERT_EQUAL (0 ,rte_service_may_be_active (sid), +"Error: Service not stopped after 100ms" ); + +return unregister_all (); +} +static struct unit_test_suite service_tests = { .suite_name ="service core test suite" , .setup = testsuite_setup,
@@ -931,6 +980,7 @@ static struct unit_test_suite service_tests = {TEST_CASE_ST (dummy_register,NULL , service_app_lcore_mt_safe),TEST_CASE_ST (dummy_register,NULL , service_app_lcore_mt_unsafe),TEST_CASE_ST (dummy_register,NULL , service_may_be_active), +TEST_CASE_ST (dummy_register,NULL , service_active_two_cores), TEST_CASES_END() /**< NULL terminate unit test array */ } };
Signature · 1 line
2.17.1
PATCH v3 1/2 service: fix wrong lcore indices
In reply to Andrew RybchenkoFrom: Igor Romanov <[email protected]>
The service core list is populated, but not used. Incorrect lcore states are examined for a service.
Use the populated list to iterate over service cores.
--- lib/librte_eal/common/rte_service.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
lib/librte_eal/common/rte_service.c +1 -1
@@ -422,7 +422,7 @@ rte_service_may_be_active(uint32_t id)return -EINVAL ;for (i =0 ; i < lcore_count; i++) { -if (lcore_states[i].service_active_on_lcore[id]) +if (lcore_states[ids[i]].service_active_on_lcore[id])return 1 ; }
Signature · 1 line
2.17.1
PATCH v3 2/2 test/service: add test for service active on two lcores
From: Igor Romanov <[email protected]>
The test checks that the service may be active API works when there are two cores: a non-service lcore and a service one.
The API notes to take care when checking the status of a running service, but the test setup allows for a safe usage in that case.
---
v3:
- skip the test if number of cores is insufficient
app/test/test_service_cores.c | 54 +++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+)
app/test/test_service_cores.c +54 -0
@@ -910,6 +910,59 @@ service_may_be_active(void)return unregister_all (); } +/* check service may be active when service is running on a second lcore */ +static int +service_active_two_cores (void ) +{ +if (!rte_lcore_is_enabled (0 ) || !rte_lcore_is_enabled (1 ) || + !rte_lcore_is_enabled (2 )) +return TEST_SKIPPED ; + +const uint32_t sid =0 ; +int i; + +uint32_t lcore =rte_get_next_lcore (/* start core */ -1 , +/* skip master */ 1 , +/* wrap */ 0 ); +uint32_t slcore =rte_get_next_lcore (/* start core */ lcore, +/* skip master */ 1 , +/* wrap */ 0 ); + +/* start the service on the second available lcore */ +TEST_ASSERT_EQUAL (0 ,rte_service_runstate_set (sid,1 ), +"Starting valid service failed" ); +TEST_ASSERT_EQUAL (0 ,rte_service_lcore_add (slcore), +"Add service core failed when not in use before" ); +TEST_ASSERT_EQUAL (0 ,rte_service_map_lcore_set (sid, slcore,1 ), +"Enabling valid service on valid core failed" ); +TEST_ASSERT_EQUAL (0 ,rte_service_lcore_start (slcore), +"Service core start after add failed" ); + +/* ensures core really is running the service function */ +TEST_ASSERT_EQUAL (1 ,service_lcore_running_check (), +"Service core expected to poll service but it didn't" ); + +/* ensures that service may be active reports running state */ +TEST_ASSERT_EQUAL (1 ,rte_service_may_be_active (sid), +"Service may be active did not report running state" ); + +/* stop the service */ +TEST_ASSERT_EQUAL (0 ,rte_service_runstate_set (sid,0 ), +"Error: Service stop returned non-zero" ); + +/* give the service 100ms to stop running */ +for (i =0 ; i <100 ; i++) { +if (!rte_service_may_be_active (sid)) +break ; +rte_delay_ms (SERVICE_DELAY ); + } + +TEST_ASSERT_EQUAL (0 ,rte_service_may_be_active (sid), +"Error: Service not stopped after 100ms" ); + +return unregister_all (); +} +static struct unit_test_suite service_tests = { .suite_name ="service core test suite" , .setup = testsuite_setup,
@@ -931,6 +984,7 @@ static struct unit_test_suite service_tests = {TEST_CASE_ST (dummy_register,NULL , service_app_lcore_mt_safe),TEST_CASE_ST (dummy_register,NULL , service_app_lcore_mt_unsafe),TEST_CASE_ST (dummy_register,NULL , service_may_be_active), +TEST_CASE_ST (dummy_register,NULL , service_active_two_cores), TEST_CASES_END() /**< NULL terminate unit test array */ } };
Signature · 1 line
2.17.1
Re: [dpdk-dev] [PATCH v3 2/2] test/service: add test for service active on two lcores
Quoted 10 lines
-----Original Message-----
From: Andrew Rybchenko <[email protected]>
Sent: Tuesday, July 7, 2020 11:45 AM
To: [email protected]
Cc: Igor Romanov <[email protected]>; Van Haaren, Harry <[email protected]>
Subject: [PATCH v3 2/2] test/service: add test for service active on two lcoresFrom: Igor Romanov <[email protected]>
Quoted 8 lines
The test checks that the service may be active API works when there are two cores: a non-service lcore and a service one.
The API notes to take care when checking the status of a running service, but the test setup allows for a safe usage in that case.
Signed-off-by Igor Romanov <[email protected]>Signed-off-by Andrew Rybchenko <[email protected]>
Confirmed test case fails without 1/2 fix, and passes with fix.
Re: [dpdk-dev] [PATCH v3 2/2] test/service: add test for service active on two lcores
In reply to Andrew RybchenkoQuoted 13 lines
-----Original Message-----
From: dev <[email protected]> On Behalf Of Andrew Rybchenko
Sent: Tuesday, July 7, 2020 5:45 AM
To: [email protected]
Cc: Igor Romanov <[email protected]>; Harry van Haaren <[email protected]>
Subject: [dpdk-dev] [PATCH v3 2/2] test/service: add test for service active on two lcoresFrom: Igor Romanov <[email protected]>
Quoted 8 lines
The test checks that the service may be active API works when there are two
cores: a non-service lcore and a service one.The API notes to take care when checking the status of a running service, but the test setup allows for a safe usage in that case.
Signed-off-by Igor Romanov <[email protected]>Signed-off-by Andrew Rybchenko <[email protected]>
Quoted 84 lines
---
v3:
- skip the test if number of cores is insufficientapp/test/test_service_cores.c | 54 +++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+)app/test/test_service_cores.c index renamed from app/test/test_service_cores.c +0
-0
981e212130..4f003ed1af100644app/test/test_service_cores.c +54
-0@@ -910,6 +910,59 @@ service_may_be_active(void)return unregister_all (); } +/* check service may be active when service is running on a second +lcore */ static int +service_active_two_cores (void ) +{ +if (!rte_lcore_is_enabled (0 ) || !rte_lcore_is_enabled (1 ) || + !rte_lcore_is_enabled (2 )) +return TEST_SKIPPED ; + +const uint32_t sid =0 ; +int i; + +uint32_t lcore =rte_get_next_lcore (/* start core */ -1 , +/* skip master */ 1 , +/* wrap */ 0 ); +uint32_t slcore =rte_get_next_lcore (/* start core */ lcore, +/* skip master */ 1 , +/* wrap */ 0 ); + +/* start the service on the second available lcore */ +TEST_ASSERT_EQUAL (0 ,rte_service_runstate_set (sid,1 ), +"Starting valid service failed" ); +TEST_ASSERT_EQUAL (0 ,rte_service_lcore_add (slcore), +"Add service core failed when not in use before" ); +TEST_ASSERT_EQUAL (0 ,rte_service_map_lcore_set (sid, slcore,1 ), +"Enabling valid service on valid core failed" ); +TEST_ASSERT_EQUAL (0 ,rte_service_lcore_start (slcore), +"Service core start after add failed" ); + +/* ensures core really is running the service function */ +TEST_ASSERT_EQUAL (1 ,service_lcore_running_check (), +"Service core expected to poll service but it didn't" ); + +/* ensures that service may be active reports running state */ +TEST_ASSERT_EQUAL (1 ,rte_service_may_be_active (sid), +"Service may be active did not report running state" ); + +/* stop the service */ +TEST_ASSERT_EQUAL (0 ,rte_service_runstate_set (sid,0 ), +"Error: Service stop returned non-zero" ); + +/* give the service 100ms to stop running */ +for (i =0 ; i <100 ; i++) { +if (!rte_service_may_be_active (sid)) +break ; +rte_delay_ms (SERVICE_DELAY ); + } + +TEST_ASSERT_EQUAL (0 ,rte_service_may_be_active (sid), +"Error: Service not stopped after 100ms" ); + +return unregister_all (); +} +static struct unit_test_suite service_tests = { .suite_name ="service core test suite" , .setup = testsuite_setup,@@ -931,6 +984,7 @@ static struct unit_test_suite service_tests = {TEST_CASE_ST (dummy_register,NULL , service_app_lcore_mt_safe),TEST_CASE_ST (dummy_register,NULL , service_app_lcore_mt_unsafe),TEST_CASE_ST (dummy_register,NULL , service_may_be_active), +TEST_CASE_ST (dummy_register,NULL , service_active_two_cores),app/test/test_service_cores.c +0
-1TEST_CASES_END() /**< NULL terminate unit test array */ } }; --2.17.1
Re: [dpdk-dev] [PATCH v3 1/2] service: fix wrong lcore indices
In reply to Andrew RybchenkoQuoted 10 lines
-----Original Message-----
From: Andrew Rybchenko <[email protected]>
Sent: Tuesday, July 7, 2020 11:45 AM
To: [email protected]
Cc: Igor Romanov <[email protected]>; [email protected]; Van Haaren, Harry <[email protected]>
Subject: [PATCH v3 1/2] service: fix wrong lcore indicesFrom: Igor Romanov <[email protected]>
Quoted 7 lines
The service core list is populated, but not used. Incorrect lcore states are examined for a service.
Use the populated list to iterate over service cores.
Fixes e30d d318 47d2 ("service: add mechanism for quiescing")
I believe the original adding of quiescing did not have this exact bug (ids[] was used)? It seems to have been introduced when reworking to avoid false sharing, so fixes is:
Quoted 2 lines
Signed-off-by Igor Romanov <[email protected]>Signed-off-by Andrew Rybchenko <[email protected]>
Code change itself:
<snip patch>
Re: [dpdk-dev] [PATCH v3 1/2] service: fix wrong lcore indices
07/07/2020 15:14, Van Haaren, Harry:
Quoted 13 lines
From: Andrew Rybchenko <[email protected]>
Quoted 9 lines
From: Igor Romanov <[email protected]>
The service core list is populated, but not used. Incorrect lcore states are examined for a service.
Use the populated list to iterate over service cores.
Fixes e30d d318 47d2 ("service: add mechanism for quiescing")I believe the original adding of quiescing did not have this exact bug (ids[] was used)? It seems to have been introduced when reworking to avoid false sharing, so fixes is:
Quoted 8 lines
Fixes e484ccddbe1b ("services: avoid false sharing on core state")Quoted 2 lines
Signed-off-by Igor Romanov <[email protected]>Signed-off-by Andrew Rybchenko <[email protected]>Code change itself:
Acked-by Harry van Haaren <[email protected]>
Series applied, thanks
Re: [dpdk-dev] [PATCH v3 1/2] service: fix wrong lcore indices
In reply to Andrew Rybchenko<snip>
Quoted 7 lines
Subject: [dpdk-dev] [PATCH v3 1/2] service: fix wrong lcore indices
From: Igor Romanov <[email protected]>
The service core list is populated, but not used. Incorrect lcore states are examined for a service.
Quoted 7 lines
Use the populated list to iterate over service cores.
Fixes e30dd31847d2 ("service: add mechanism for quiescing")Signed-off-by Igor Romanov <[email protected]>Signed-off-by Andrew Rybchenko <[email protected]>
LGTM
Quoted 20 lines
--- lib/librte_eal/common/rte_service.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)lib/librte_eal/common/rte_service.c +1
-2@@ -422,7 +422,7 @@ rte_service_may_be_active(uint32_t id)return -EINVAL ;for (i =0 ; i < lcore_count; i++) { -if (lcore_states[i].service_active_on_lcore[id]) +if (lcore_states[ids[i]].service_active_on_lcore[id])return 1 ; } --2.17.1