diff mbox series

eal: detach interrupt and worker threads

Message ID 20210819024100.1710184-1-stephen@networkplumber.org (mailing list archive)
State Changes Requested
Delegated to: David Marchand
Headers show
Series eal: detach interrupt and worker threads | expand

Checks

Context Check Description
ci/intel-Testing success Testing PASS
ci/Intel-compilation success Compilation OK
ci/iol-aarch64-compile-testing success Testing PASS
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-x86_64-compile-testing success Testing PASS
ci/iol-x86_64-unit-testing fail Testing issues
ci/iol-aarch64-unit-testing fail Testing issues
ci/iol-intel-Functional success Functional Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-broadcom-Functional success Functional Testing PASS
ci/iol-broadcom-Performance success Performance Testing PASS
ci/github-robot: build success github build: passed
ci/checkpatch success coding style OK

Commit Message

Stephen Hemminger Aug. 19, 2021, 2:41 a.m. UTC
The EAL library does not wait (pthread_join) these threads
so the should be detached so that library can release resources.
This shows up when looking for memory leaks with tools like
valgrind.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/eal/freebsd/eal.c          | 3 +++
 lib/eal/linux/eal.c            | 6 ++++++
 lib/eal/linux/eal_interrupts.c | 3 +++
 3 files changed, 12 insertions(+)

Comments

David Marchand Sept. 29, 2021, 6:21 a.m. UTC | #1
On Thu, Aug 19, 2021 at 4:41 AM Stephen Hemminger
<stephen@networkplumber.org> wrote:
>
> The EAL library does not wait (pthread_join) these threads
> so the should be detached so that library can release resources.
> This shows up when looking for memory leaks with tools like
> valgrind.

The FreeBSD interrupt thread can be detached too.

There is also the hpet-msb-inc thread in Linux that could be detached,
maybe in a followup patch?

>
> Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>

With FreeBSD interrupt thread addition, you can add:
Reviewed-by: David Marchand <david.marchand@redhat.com>
diff mbox series

Patch

diff --git a/lib/eal/freebsd/eal.c b/lib/eal/freebsd/eal.c
index 6cee5ae369db..039e5fba4bd4 100644
--- a/lib/eal/freebsd/eal.c
+++ b/lib/eal/freebsd/eal.c
@@ -899,6 +899,9 @@  rte_eal_init(int argc, char **argv)
 			sizeof(rte_cpuset_t), &lcore_config[i].cpuset);
 		if (ret != 0)
 			rte_panic("Cannot set affinity\n");
+
+		/* worker threads are never joined */
+		pthread_detach(lcore_config[i].thread_id);
 	}
 
 	/*
diff --git a/lib/eal/linux/eal.c b/lib/eal/linux/eal.c
index 3577eaeaa4f4..ad64557d453e 100644
--- a/lib/eal/linux/eal.c
+++ b/lib/eal/linux/eal.c
@@ -1267,6 +1267,12 @@  rte_eal_init(int argc, char **argv)
 			sizeof(rte_cpuset_t), &lcore_config[i].cpuset);
 		if (ret != 0)
 			rte_panic("Cannot set affinity\n");
+
+		/* worker threads are never joined */
+		ret = pthread_detach(lcore_config[i].thread_id);
+		if (ret != 0)
+			RTE_LOG(DEBUG, EAL,
+				"Cannot detach lcore thread\n");
 	}
 
 	/*
diff --git a/lib/eal/linux/eal_interrupts.c b/lib/eal/linux/eal_interrupts.c
index 22b3b7bcd9a7..53a7bf5fbd4e 100644
--- a/lib/eal/linux/eal_interrupts.c
+++ b/lib/eal/linux/eal_interrupts.c
@@ -1175,6 +1175,9 @@  rte_eal_intr_init(void)
 			"Failed to create thread for interrupt handling\n");
 	}
 
+	/* the interrupt thread is never joined */
+	pthread_detach(intr_thread);
+
 	return ret;
 }