DPDK patches and discussions
 help / color / mirror / Atom feed
From: Honnappa Nagarahalli <honnappa.nagarahalli@arm.com>
To: dev@dpdk.org, honnappa.nagarahalli@arm.com,
	konstantin.ananyev@intel.com, david.marchand@redhat.com,
	feifei.wang2@arm.com
Cc: ruifeng.wang@arm.com, nd@arm.com,
	Ola Liljedahl <ola.liljedahl@arm.com>,
	Feifei Wang <feifei.wang@arm.com>
Subject: [dpdk-dev] [PATCH v2 3/6] eal: lcore state FINISHED is not required
Date: Thu,  9 Sep 2021 18:13:09 -0500	[thread overview]
Message-ID: <20210909231312.2572006-4-honnappa.nagarahalli@arm.com> (raw)
In-Reply-To: <20210909231312.2572006-1-honnappa.nagarahalli@arm.com>

FINISHED state seems to be used to indicate that the worker's update
of the 'state' is not visible to other threads. There seems to be no
requirement to have such a state.

Signed-off-by: Honnappa Nagarahalli <honnappa.nagarahalli@arm.com>
Reviewed-by: Ola Liljedahl <ola.liljedahl@arm.com>
Reviewed-by: Feifei Wang <feifei.wang@arm.com>
---
 drivers/event/dpaa2/dpaa2_eventdev_selftest.c |  2 +-
 drivers/event/octeontx/ssovf_evdev_selftest.c |  2 +-
 drivers/event/sw/sw_evdev_selftest.c          |  4 ++--
 examples/l2fwd-keepalive/main.c               |  3 +--
 lib/eal/common/eal_common_launch.c            |  7 ++-----
 lib/eal/freebsd/eal_thread.c                  |  4 ++--
 lib/eal/include/rte_launch.h                  |  9 +++++----
 lib/eal/include/rte_service.h                 |  4 +---
 lib/eal/linux/eal_thread.c                    | 10 ++--------
 lib/eal/windows/eal_thread.c                  | 10 ++--------
 10 files changed, 19 insertions(+), 36 deletions(-)

diff --git a/drivers/event/dpaa2/dpaa2_eventdev_selftest.c b/drivers/event/dpaa2/dpaa2_eventdev_selftest.c
index cd7311a94d..bbbd20951f 100644
--- a/drivers/event/dpaa2/dpaa2_eventdev_selftest.c
+++ b/drivers/event/dpaa2/dpaa2_eventdev_selftest.c
@@ -468,7 +468,7 @@ wait_workers_to_join(int lcore, const rte_atomic32_t *count)
 	RTE_SET_USED(count);
 
 	print_cycles = cycles = rte_get_timer_cycles();
-	while (rte_eal_get_lcore_state(lcore) != FINISHED) {
+	while (rte_eal_get_lcore_state(lcore) != WAIT) {
 		uint64_t new_cycles = rte_get_timer_cycles();
 
 		if (new_cycles - print_cycles > rte_get_timer_hz()) {
diff --git a/drivers/event/octeontx/ssovf_evdev_selftest.c b/drivers/event/octeontx/ssovf_evdev_selftest.c
index 528f99dd84..d7b0d22111 100644
--- a/drivers/event/octeontx/ssovf_evdev_selftest.c
+++ b/drivers/event/octeontx/ssovf_evdev_selftest.c
@@ -579,7 +579,7 @@ wait_workers_to_join(int lcore, const rte_atomic32_t *count)
 	RTE_SET_USED(count);
 
 	print_cycles = cycles = rte_get_timer_cycles();
-	while (rte_eal_get_lcore_state(lcore) != FINISHED) {
+	while (rte_eal_get_lcore_state(lcore) != WAIT) {
 		uint64_t new_cycles = rte_get_timer_cycles();
 
 		if (new_cycles - print_cycles > rte_get_timer_hz()) {
diff --git a/drivers/event/sw/sw_evdev_selftest.c b/drivers/event/sw/sw_evdev_selftest.c
index d53e903129..9768d3a0c7 100644
--- a/drivers/event/sw/sw_evdev_selftest.c
+++ b/drivers/event/sw/sw_evdev_selftest.c
@@ -3140,8 +3140,8 @@ worker_loopback(struct test *t, uint8_t disable_implicit_release)
 	rte_eal_remote_launch(worker_loopback_worker_fn, t, w_lcore);
 
 	print_cycles = cycles = rte_get_timer_cycles();
-	while (rte_eal_get_lcore_state(p_lcore) != FINISHED ||
-			rte_eal_get_lcore_state(w_lcore) != FINISHED) {
+	while (rte_eal_get_lcore_state(p_lcore) != WAIT ||
+			rte_eal_get_lcore_state(w_lcore) != WAIT) {
 
 		rte_service_run_iter_on_app_lcore(t->service_id, 1);
 
diff --git a/examples/l2fwd-keepalive/main.c b/examples/l2fwd-keepalive/main.c
index 4e1a17cfe4..b4f9d7334b 100644
--- a/examples/l2fwd-keepalive/main.c
+++ b/examples/l2fwd-keepalive/main.c
@@ -507,8 +507,7 @@ dead_core(__rte_unused void *ptr_data, const int id_core)
 	if (terminate_signal_received)
 		return;
 	printf("Dead core %i - restarting..\n", id_core);
-	if (rte_eal_get_lcore_state(id_core) == FINISHED) {
-		rte_eal_wait_lcore(id_core);
+	if (rte_eal_get_lcore_state(id_core) == WAIT) {
 		rte_eal_remote_launch(l2fwd_launch_one_lcore, NULL, id_core);
 	} else {
 		printf("..false positive!\n");
diff --git a/lib/eal/common/eal_common_launch.c b/lib/eal/common/eal_common_launch.c
index 34f854ad80..78fd940267 100644
--- a/lib/eal/common/eal_common_launch.c
+++ b/lib/eal/common/eal_common_launch.c
@@ -26,14 +26,11 @@ rte_eal_wait_lcore(unsigned worker_id)
 	if (lcore_config[worker_id].state == WAIT)
 		return 0;
 
-	while (lcore_config[worker_id].state != WAIT &&
-	       lcore_config[worker_id].state != FINISHED)
+	while (lcore_config[worker_id].state != WAIT)
 		rte_pause();
 
 	rte_rmb();
 
-	/* we are in finished state, go to wait state */
-	lcore_config[worker_id].state = WAIT;
 	return lcore_config[worker_id].ret;
 }
 
@@ -62,7 +59,7 @@ rte_eal_mp_remote_launch(int (*f)(void *), void *arg,
 
 	if (call_main == CALL_MAIN) {
 		lcore_config[main_lcore].ret = f(arg);
-		lcore_config[main_lcore].state = FINISHED;
+		lcore_config[main_lcore].state = WAIT;
 	}
 
 	return 0;
diff --git a/lib/eal/freebsd/eal_thread.c b/lib/eal/freebsd/eal_thread.c
index 17b8f39966..e5e3edf79b 100644
--- a/lib/eal/freebsd/eal_thread.c
+++ b/lib/eal/freebsd/eal_thread.c
@@ -28,7 +28,7 @@
 /*
  * Send a message to a worker lcore identified by worker_id to call a
  * function f with argument arg. Once the execution is done, the
- * remote lcore switch in FINISHED state.
+ * remote lcore switches to WAIT state.
  */
 int
 rte_eal_remote_launch(int (*f)(void *), void *arg, unsigned worker_id)
@@ -140,7 +140,7 @@ eal_thread_loop(__rte_unused void *arg)
 		lcore_config[lcore_id].f = NULL;
 		lcore_config[lcore_id].arg = NULL;
 		rte_wmb();
-		lcore_config[lcore_id].state = FINISHED;
+		lcore_config[lcore_id].state = WAIT;
 	}
 
 	/* never reached */
diff --git a/lib/eal/include/rte_launch.h b/lib/eal/include/rte_launch.h
index 22a901ce62..ed0bb4762a 100644
--- a/lib/eal/include/rte_launch.h
+++ b/lib/eal/include/rte_launch.h
@@ -19,9 +19,10 @@ extern "C" {
  * State of an lcore.
  */
 enum rte_lcore_state_t {
-	WAIT,       /**< waiting a new command */
-	RUNNING,    /**< executing command */
-	FINISHED,   /**< command executed */
+	WAIT,
+	/**< waiting for new command */
+	RUNNING,
+	/**< executing command */
 };
 
 /**
@@ -41,7 +42,7 @@ typedef int (lcore_function_t)(void *);
  *
  * When the remote lcore receives the message, it switches to
  * the RUNNING state, then calls the function f with argument arg. Once the
- * execution is done, the remote lcore switches to a FINISHED state and
+ * execution is done, the remote lcore switches to WAIT state and
  * the return value of f is stored in a local variable to be read using
  * rte_eal_wait_lcore().
  *
diff --git a/lib/eal/include/rte_service.h b/lib/eal/include/rte_service.h
index c7d037d862..646533e871 100644
--- a/lib/eal/include/rte_service.h
+++ b/lib/eal/include/rte_service.h
@@ -321,9 +321,7 @@ int32_t rte_service_lcore_count(void);
  * from duty, just unmaps all services / cores, and stops() the service cores.
  * The runstate of services is not modified.
  *
- * The cores that are stopped with this call, are in FINISHED state and
- * the application must take care of bringing them back to a launchable state:
- * e.g. call *rte_eal_lcore_wait* on the lcore_id.
+ * The cores that are stopped with this call, are in WAIT state.
  *
  * @retval 0 Success
  */
diff --git a/lib/eal/linux/eal_thread.c b/lib/eal/linux/eal_thread.c
index a0a0091040..c79e09c9ad 100644
--- a/lib/eal/linux/eal_thread.c
+++ b/lib/eal/linux/eal_thread.c
@@ -28,7 +28,7 @@
 /*
  * Send a message to a worker lcore identified by worker_id to call a
  * function f with argument arg. Once the execution is done, the
- * remote lcore switch in FINISHED state.
+ * remote lcore switches to WAIT state.
  */
 int
 rte_eal_remote_launch(int (*f)(void *), void *arg, unsigned int worker_id)
@@ -141,13 +141,7 @@ eal_thread_loop(__rte_unused void *arg)
 		lcore_config[lcore_id].arg = NULL;
 		rte_wmb();
 
-		/* when a service core returns, it should go directly to WAIT
-		 * state, because the application will not lcore_wait() for it.
-		 */
-		if (lcore_config[lcore_id].core_role == ROLE_SERVICE)
-			lcore_config[lcore_id].state = WAIT;
-		else
-			lcore_config[lcore_id].state = FINISHED;
+		lcore_config[lcore_id].state = WAIT;
 	}
 
 	/* never reached */
diff --git a/lib/eal/windows/eal_thread.c b/lib/eal/windows/eal_thread.c
index e08abcf21f..977911905e 100644
--- a/lib/eal/windows/eal_thread.c
+++ b/lib/eal/windows/eal_thread.c
@@ -19,7 +19,7 @@
 /*
  * Send a message to a worker lcore identified by worker_id to call a
  * function f with argument arg. Once the execution is done, the
- * remote lcore switch in FINISHED state.
+ * remote lcore switches to WAIT state.
  */
 int
 rte_eal_remote_launch(lcore_function_t *f, void *arg, unsigned int worker_id)
@@ -125,13 +125,7 @@ eal_thread_loop(void *arg __rte_unused)
 		lcore_config[lcore_id].arg = NULL;
 		rte_wmb();
 
-		/* when a service core returns, it should go directly to WAIT
-		 * state, because the application will not lcore_wait() for it.
-		 */
-		if (lcore_config[lcore_id].core_role == ROLE_SERVICE)
-			lcore_config[lcore_id].state = WAIT;
-		else
-			lcore_config[lcore_id].state = FINISHED;
+		lcore_config[lcore_id].state = WAIT;
 	}
 }
 
-- 
2.25.1


  parent reply	other threads:[~2021-09-09 23:13 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-24 21:20 [dpdk-dev] [RFC 0/5] Use correct memory ordering in eal functions Honnappa Nagarahalli
2021-02-24 21:20 ` [dpdk-dev] [RFC 1/5] eal: reset lcore function pointer and argument Honnappa Nagarahalli
2021-02-24 21:20 ` [dpdk-dev] [RFC 2/5] eal: ensure memory operations are visible to worker Honnappa Nagarahalli
2021-02-24 21:20 ` [dpdk-dev] [RFC 3/5] eal: lcore state FINISHED is not required Honnappa Nagarahalli
     [not found]   ` <AM5PR0802MB2465B62994239817E0AC46C59E9E9@AM5PR0802MB2465.eurprd08.prod.outlook.com>
2021-02-25  8:44     ` [dpdk-dev] 回复: " Feifei Wang
2021-02-25 23:33       ` [dpdk-dev] " Honnappa Nagarahalli
2021-02-26  8:26         ` Thomas Monjalon
2021-03-02  3:13           ` Honnappa Nagarahalli
2021-03-19 13:42             ` Ananyev, Konstantin
2021-03-30  2:54               ` Honnappa Nagarahalli
2021-03-01  5:55         ` [dpdk-dev] 回复: " Feifei Wang
2021-02-24 21:20 ` [dpdk-dev] [RFC 4/5] eal: ensure memory operations are visible to main Honnappa Nagarahalli
2021-02-24 21:20 ` [dpdk-dev] [RFC 5/5] test/ring: use relaxed barriers for ring stress test Honnappa Nagarahalli
2021-03-01 16:41 ` [dpdk-dev] [RFC 0/5] Use correct memory ordering in eal functions Stephen Hemminger
2021-03-02 16:06   ` Honnappa Nagarahalli
2021-09-09 23:13 ` [dpdk-dev] [PATCH v2 0/6] " Honnappa Nagarahalli
2021-09-09 23:13   ` [dpdk-dev] [PATCH v2 1/6] eal: reset lcore function pointer and argument Honnappa Nagarahalli
2021-09-10  7:49     ` Bruce Richardson
2021-09-10  8:12       ` David Marchand
2021-09-11 22:19         ` Honnappa Nagarahalli
2021-09-09 23:13   ` [dpdk-dev] [PATCH v2 2/6] eal: ensure memory operations are visible to worker Honnappa Nagarahalli
2021-09-09 23:13   ` Honnappa Nagarahalli [this message]
2021-09-09 23:13   ` [dpdk-dev] [PATCH v2 4/6] eal: update rte_eal_wait_lcore definition Honnappa Nagarahalli
2021-09-09 23:37     ` Honnappa Nagarahalli
2021-09-09 23:13   ` [dpdk-dev] [PATCH v2 5/6] eal: ensure memory operations are visible to main Honnappa Nagarahalli
2021-09-09 23:13   ` [dpdk-dev] [PATCH v2 6/6] test/ring: use relaxed barriers for ring stress test Honnappa Nagarahalli
2021-10-07 11:55     ` Ananyev, Konstantin
2021-10-07 23:40       ` Honnappa Nagarahalli
2021-10-25  4:52 ` [dpdk-dev] [PATCH v3 0/4] Use correct memory ordering in eal functions Honnappa Nagarahalli
2021-10-25  4:52   ` [dpdk-dev] [PATCH v3 1/4] eal: reset lcore function pointer and argument Honnappa Nagarahalli
2021-10-25  4:52   ` [dpdk-dev] [PATCH v3 2/4] eal: lcore state FINISHED is not required Honnappa Nagarahalli
2021-10-25  4:52   ` [dpdk-dev] [PATCH v3 3/4] eal: use correct memory ordering Honnappa Nagarahalli
2021-10-25  4:52   ` [dpdk-dev] [PATCH v3 4/4] test/ring: use relaxed barriers for ring stress test Honnappa Nagarahalli
2021-10-25 16:23   ` [dpdk-dev] [PATCH v3 0/4] Use correct memory ordering in eal functions David Marchand

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=20210909231312.2572006-4-honnappa.nagarahalli@arm.com \
    --to=honnappa.nagarahalli@arm.com \
    --cc=david.marchand@redhat.com \
    --cc=dev@dpdk.org \
    --cc=feifei.wang2@arm.com \
    --cc=feifei.wang@arm.com \
    --cc=konstantin.ananyev@intel.com \
    --cc=nd@arm.com \
    --cc=ola.liljedahl@arm.com \
    --cc=ruifeng.wang@arm.com \
    /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).