diff mbox series

[2/2] net/ice: fix leak on thread termination

Message ID 20210506094452.1689-3-david.marchand@redhat.com (mailing list archive)
State Superseded, archived
Delegated to: Ferruh Yigit
Headers show
Series Thread termination leak fixes | expand

Checks

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

Commit Message

David Marchand May 6, 2021, 9:44 a.m. UTC
A terminated pthread should be joined or detached so that its associated
resources are released.

The "ice-reset-<vf_id>" threads are used to service some reset task in the
background, but they are never joined by the thread that created them.
The easiest solution is to detach new threads.

Fixes: 3b3757bda3c3 ("net/ice: get VF hardware index in DCF")
Cc: stable@dpdk.org

Signed-off-by: David Marchand <david.marchand@redhat.com>
---
 drivers/net/ice/ice_dcf_parent.c | 2 ++
 1 file changed, 2 insertions(+)

Comments

Wang, Haiyue May 6, 2021, 10:31 a.m. UTC | #1
> -----Original Message-----
> From: David Marchand <david.marchand@redhat.com>
> Sent: Thursday, May 6, 2021 17:45
> To: dev@dpdk.org
> Cc: stable@dpdk.org; Yang, Qiming <qiming.yang@intel.com>; Zhang, Qi Z <qi.z.zhang@intel.com>; Wang,
> Haiyue <haiyue.wang@intel.com>
> Subject: [PATCH 2/2] net/ice: fix leak on thread termination
> 
> A terminated pthread should be joined or detached so that its associated
> resources are released.
> 
> The "ice-reset-<vf_id>" threads are used to service some reset task in the
> background, but they are never joined by the thread that created them.
> The easiest solution is to detach new threads.
> 
> Fixes: 3b3757bda3c3 ("net/ice: get VF hardware index in DCF")
> Cc: stable@dpdk.org
> 
> Signed-off-by: David Marchand <david.marchand@redhat.com>
> ---
>  drivers/net/ice/ice_dcf_parent.c | 2 ++
>  1 file changed, 2 insertions(+)
> 

Got it, thanks!

Acked-by: Haiyue Wang <haiyue.wang@intel.com>

> --
> 2.23.0
David Marchand May 7, 2021, 8:13 a.m. UTC | #2
On Thu, May 6, 2021 at 11:45 AM David Marchand
<david.marchand@redhat.com> wrote:
>
> A terminated pthread should be joined or detached so that its associated
> resources are released.
>
> The "ice-reset-<vf_id>" threads are used to service some reset task in the
> background, but they are never joined by the thread that created them.
> The easiest solution is to detach new threads.

Not so "easy" for Windows.

I think I'll simply #ifndef WINDOWS my addition.
Maybe the leak does not exist on Windows? but if it does, the
situation won't change by doing nothing on Windows.

If there is strong objection, I'll need some help to add a
pthread_detach() wrapper in windows EAL.
From my quick read at the API, I'd say I need to find the current
thread handle (via OpenThread) then CloseHandle it.
But does it work from "pthread_self()" ?


Since a new API thread is in preparation, the "thread detaching" from
the pthread API is something to consider.
I could not find it in Narcissa series.
Dmitry Kozlyuk May 7, 2021, 5:14 p.m. UTC | #3
2021-05-07 10:13 (UTC+0200), David Marchand:
> On Thu, May 6, 2021 at 11:45 AM David Marchand
> <david.marchand@redhat.com> wrote:
> >
> > A terminated pthread should be joined or detached so that its associated
> > resources are released.
> >
> > The "ice-reset-<vf_id>" threads are used to service some reset task in the
> > background, but they are never joined by the thread that created them.
> > The easiest solution is to detach new threads.  
> 
> Not so "easy" for Windows.
> 
> I think I'll simply #ifndef WINDOWS my addition.
> Maybe the leak does not exist on Windows? but if it does, the
> situation won't change by doing nothing on Windows.
>
> If there is strong objection, I'll need some help to add a
> pthread_detach() wrapper in windows EAL.
> From my quick read at the API, I'd say I need to find the current
> thread handle (via OpenThread) then CloseHandle it.
> But does it work from "pthread_self()" ?
> 
> 
> Since a new API thread is in preparation, the "thread detaching" from
> the pthread API is something to consider.
> I could not find it in Narcissa series.

There is no leak.
On Windows, pthread_t is just a number, not a handle.
pthread_detach can be implemented as a no-op and added to new API.
See also: https://devblogs.microsoft.com/oldnewthing/20100827-00/?p=13023
diff mbox series

Patch

diff --git a/drivers/net/ice/ice_dcf_parent.c b/drivers/net/ice/ice_dcf_parent.c
index c8e433239b..1d7aa8bc87 100644
--- a/drivers/net/ice/ice_dcf_parent.c
+++ b/drivers/net/ice/ice_dcf_parent.c
@@ -121,6 +121,8 @@  ice_dcf_vsi_update_service_handler(void *param)
 	struct ice_dcf_hw *hw = reset_param->dcf_hw;
 	struct ice_dcf_adapter *adapter;
 
+	pthread_detach(pthread_self());
+
 	rte_delay_us(ICE_DCF_VSI_UPDATE_SERVICE_INTERVAL);
 
 	rte_spinlock_lock(&vsi_update_lock);