[04/14] eal: cleanup threads

Message ID 20200104013341.19809-5-stephen@networkplumber.org (mailing list archive)
State Superseded, archived
Delegated to: David Marchand
Headers
Series cleanup resources on shutdown |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation fail Compilation issues

Commit Message

Stephen Hemminger Jan. 4, 2020, 1:33 a.m. UTC
  When rte_eal_cleanup is called it should stop all the child threads
and close the pipes between threads.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/librte_eal/linux/eal/eal.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)
  

Comments

Aaron Conole Feb. 4, 2020, 2:48 p.m. UTC | #1
Stephen Hemminger <stephen@networkplumber.org> writes:

> When rte_eal_cleanup is called it should stop all the child threads
> and close the pipes between threads.
>
> Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
> ---

Acked-by: Aaron Conole <aconole@redhat.com>
  

Patch

diff --git a/lib/librte_eal/linux/eal/eal.c b/lib/librte_eal/linux/eal/eal.c
index a1b928820b11..d98a2afe85da 100644
--- a/lib/librte_eal/linux/eal/eal.c
+++ b/lib/librte_eal/linux/eal/eal.c
@@ -1319,11 +1319,24 @@  mark_freeable(const struct rte_memseg_list *msl, const struct rte_memseg *ms,
 int
 rte_eal_cleanup(void)
 {
+	int i;
+
 	/* if we're in a primary process, we need to mark hugepages as freeable
 	 * so that finalization can release them back to the system.
 	 */
 	if (rte_eal_process_type() == RTE_PROC_PRIMARY)
 		rte_memseg_walk(mark_freeable, NULL);
+
+	RTE_LCORE_FOREACH_SLAVE(i) {
+		pthread_cancel(lcore_config[i].thread_id);
+		pthread_join(lcore_config[i].thread_id, NULL);
+
+		close(lcore_config[i].pipe_master2slave[0]);
+		close(lcore_config[i].pipe_master2slave[1]);
+		close(lcore_config[i].pipe_slave2master[0]);
+		close(lcore_config[i].pipe_slave2master[1]);
+	}
+
 	rte_service_finalize();
 	rte_eal_alarm_cleanup();
 	rte_mp_channel_cleanup();