telemetry: detach pthreads

Message ID 20210819023819.1709957-1-stephen@networkplumber.org (mailing list archive)
State Accepted, archived
Delegated to: Thomas Monjalon
Headers
Series telemetry: detach pthreads |

Checks

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

Commit Message

Stephen Hemminger Aug. 19, 2021, 2:38 a.m. UTC
  There are a number telemetry threads which are created and
there is nothing that does pthread_join() to wait for them.
Mark these threads as detached, so that the pthread library
can cleanup state when the thread exits.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/telemetry/telemetry.c        | 2 ++
 lib/telemetry/telemetry_legacy.c | 1 +
 2 files changed, 3 insertions(+)
  

Comments

Power, Ciara Aug. 20, 2021, 8:49 a.m. UTC | #1
Hi Stephen,

>-----Original Message-----
>From: Stephen Hemminger <stephen@networkplumber.org>
>Sent: Thursday 19 August 2021 03:38
>To: Power, Ciara <ciara.power@intel.com>
>Cc: dev@dpdk.org; Stephen Hemminger <stephen@networkplumber.org>
>Subject: [PATCH] telemetry: detach pthreads
>
>There are a number telemetry threads which are created and there is nothing
>that does pthread_join() to wait for them.
>Mark these threads as detached, so that the pthread library can cleanup state
>when the thread exits.
>
>Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
>---
> lib/telemetry/telemetry.c        | 2 ++
> lib/telemetry/telemetry_legacy.c | 1 +
> 2 files changed, 3 insertions(+)
>
<snip>

Thanks for catching this,

Acked-by: Ciara Power <ciara.power@intel.com>
  
Thomas Monjalon Oct. 1, 2021, 12:50 p.m. UTC | #2
> >There are a number telemetry threads which are created and there is nothing
> >that does pthread_join() to wait for them.
> >Mark these threads as detached, so that the pthread library can cleanup state
> >when the thread exits.
> >
> >Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
> >---
> > lib/telemetry/telemetry.c        | 2 ++
> > lib/telemetry/telemetry_legacy.c | 1 +
> > 2 files changed, 3 insertions(+)
> >
> <snip>
> 
> Thanks for catching this,
> 
> Acked-by: Ciara Power <ciara.power@intel.com>

Applied, thanks.
  

Patch

diff --git a/lib/telemetry/telemetry.c b/lib/telemetry/telemetry.c
index 8665db8d035b..976f0a21566e 100644
--- a/lib/telemetry/telemetry.c
+++ b/lib/telemetry/telemetry.c
@@ -490,6 +490,7 @@  telemetry_legacy_init(void)
 	pthread_setaffinity_np(t_old, sizeof(*thread_cpuset), thread_cpuset);
 	set_thread_name(t_old, "telemetry-v1");
 	TMTY_LOG(DEBUG, "Legacy telemetry socket initialized ok\n");
+	pthread_detach(t_old);
 	return 0;
 }
 
@@ -528,6 +529,7 @@  telemetry_v2_init(void)
 	}
 	pthread_setaffinity_np(t_new, sizeof(*thread_cpuset), thread_cpuset);
 	set_thread_name(t_new, "telemetry-v2");
+	pthread_detach(t_new);
 	atexit(unlink_sockets);
 
 	return 0;
diff --git a/lib/telemetry/telemetry_legacy.c b/lib/telemetry/telemetry_legacy.c
index b7cd1bdd6c7b..8aba44d689b7 100644
--- a/lib/telemetry/telemetry_legacy.c
+++ b/lib/telemetry/telemetry_legacy.c
@@ -121,6 +121,7 @@  register_client(const char *cmd __rte_unused, const char *params,
 		close(fd);
 		return -1;
 	}
+	pthread_detach(th);
 #endif /* !RTE_EXEC_ENV_WINDOWS */
 	return 0;
 }