DPDK patches and discussions
 help / color / mirror / Atom feed
From: Stephen Hemminger <stephen@networkplumber.org>
To: dev@dpdk.org
Cc: Stephen Hemminger <stephen@networkplumber.org>
Subject: [dpdk-dev] [PATCH] eal: detach interrupt and worker threads
Date: Wed, 18 Aug 2021 19:41:00 -0700	[thread overview]
Message-ID: <20210819024100.1710184-1-stephen@networkplumber.org> (raw)

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(+)

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;
 }
 
-- 
2.30.2


             reply	other threads:[~2021-08-19  2:41 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-19  2:41 Stephen Hemminger [this message]
2021-09-29  6:21 ` 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=20210819024100.1710184-1-stephen@networkplumber.org \
    --to=stephen@networkplumber.org \
    --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).