DPDK patches and discussions
 help / color / mirror / Atom feed
From: Harry van Haaren <harry.van.haaren@intel.com>
To: dev@dpdk.org
Cc: Harry van Haaren <harry.van.haaren@intel.com>
Subject: [dpdk-dev] [PATCH 2/2] service: fix service core launch
Date: Wed, 20 Dec 2017 11:21:47 +0000	[thread overview]
Message-ID: <1513768907-112647-2-git-send-email-harry.van.haaren@intel.com> (raw)
In-Reply-To: <1513768907-112647-1-git-send-email-harry.van.haaren@intel.com>

This patch fixes a potential bug, which was not consistently
showing up in the unit tests. The issue was that the service-
lcore being started was not in a "WAIT" state, and hence EAL
would return -EBUSY instead of launching the lcore.

In order to ensure a core is in a launch-ready state, the application
must call rte_eal_wait_lcore, to ensure that the core has completed
its previous task, and that EAL is ready to re-launch it.

The call to rte_eal_wait_lcore() is explicitly not in the
service core function, to make it visible to the application.
Requiring an explicit function call ensures the developer sees
that a lcore could block in the rte_eal_wait_lcore() function
if the core hasn't returned from its previous function.

>From a usability perspective, hiding the wait_lcore() inside
service cores would cause confusion.

This patch adds rte_eal_wait_lcore() calls to the unit tests,
to ensure that the lcores for testing functionality are ready
to run the test.

Fixes: 21698354c832 ("service: introduce service cores concept")
+CC stable@dpdk.org

Signed-off-by: Harry van Haaren <harry.van.haaren@intel.com>

---

@Stable maintainers; this is an EXPERIMENTAL tagged API, so
I'm not sure what the expectation is in terms of backporting.
---
 lib/librte_eal/common/include/rte_service.h | 4 +++-
 test/test/test_service_cores.c              | 6 ++++++
 2 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/lib/librte_eal/common/include/rte_service.h b/lib/librte_eal/common/include/rte_service.h
index 9272440..495b531 100644
--- a/lib/librte_eal/common/include/rte_service.h
+++ b/lib/librte_eal/common/include/rte_service.h
@@ -274,7 +274,9 @@ int32_t rte_service_run_iter_on_app_lcore(uint32_t id,
  * Start a service core.
  *
  * Starting a core makes the core begin polling. Any services assigned to it
- * will be run as fast as possible.
+ * will be run as fast as possible. The application must ensure that the lcore
+ * is in a launchable state: e.g. call *rte_eal_lcore_wait* on the lcore_id
+ * before calling this function.
  *
  * @retval 0 Success
  * @retval -EINVAL Failed to start core. The *lcore_id* passed in is not
diff --git a/test/test/test_service_cores.c b/test/test/test_service_cores.c
index 311c704..43f2318 100644
--- a/test/test/test_service_cores.c
+++ b/test/test/test_service_cores.c
@@ -348,6 +348,7 @@ service_lcore_en_dis_able(void)
 
 	/* call remote_launch to verify that app can launch ex-service lcore */
 	service_remote_launch_flag = 0;
+	rte_eal_wait_lcore(slcore_id);
 	int ret = rte_eal_remote_launch(service_remote_launch_func, NULL,
 					slcore_id);
 	TEST_ASSERT_EQUAL(0, ret, "Ex-service core remote launch failed.");
@@ -505,6 +506,10 @@ service_threaded_test(int mt_safe)
 	if (!mt_safe)
 		test_params[1] = 1;
 
+	/* wait for lcores before start() */
+	rte_eal_wait_lcore(slcore_1);
+	rte_eal_wait_lcore(slcore_2);
+
 	rte_service_lcore_start(slcore_1);
 	rte_service_lcore_start(slcore_2);
 
@@ -611,6 +616,7 @@ service_app_lcore_poll_impl(const int mt_safe)
 	rte_service_runstate_set(id, 1);
 
 	uint32_t app_core2 = rte_get_next_lcore(slcore_id, 1, 1);
+	rte_eal_wait_lcore(app_core2);
 	int app_core2_ret = rte_eal_remote_launch(service_run_on_app_core_func,
 						  &id, app_core2);
 
-- 
2.7.4

  reply	other threads:[~2017-12-20 11:21 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-12-20 11:21 [dpdk-dev] [PATCH 1/2] service: fix del to reset lcore role to rte Harry van Haaren
2017-12-20 11:21 ` Harry van Haaren [this message]
2018-01-04 15:30   ` [dpdk-dev] [PATCH 2/2] service: fix service core launch Pavan Nikhilesh
2018-01-04 15:20 ` [dpdk-dev] [PATCH 1/2] service: fix del to reset lcore role to rte Pavan Nikhilesh
2018-01-08 15:58 ` [dpdk-dev] [PATCH v2 " Harry van Haaren
2018-01-08 15:58   ` [dpdk-dev] [PATCH v2 2/2] service: fix service core launch Harry van Haaren
2018-01-09 11:38   ` [dpdk-dev] [PATCH v3 1/2] service: fix del to reset lcore role to rte Harry van Haaren
2018-01-09 11:38     ` [dpdk-dev] [PATCH v3 2/2] service: fix service core launch Harry van Haaren
2018-01-09 12:14     ` [dpdk-dev] [PATCH v3 1/2] service: fix del to reset lcore role to rte Bruce Richardson
2018-01-09 13:37     ` [dpdk-dev] [PATCH v4 1/2] service: fix lcore role after delete Harry van Haaren
2018-01-09 13:37       ` [dpdk-dev] [PATCH v4 2/2] service: fix service core launch Harry van Haaren
2018-01-10 10:23       ` [dpdk-dev] [PATCH v4 1/2] service: fix lcore role after delete Pavan Nikhilesh
2018-01-11 22:30         ` Thomas Monjalon

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1513768907-112647-2-git-send-email-harry.van.haaren@intel.com \
    --to=harry.van.haaren@intel.com \
    --cc=dev@dpdk.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).