From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 0B14AA057B for ; Tue, 14 Apr 2020 12:26:37 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id EC1941C1E5; Tue, 14 Apr 2020 12:26:36 +0200 (CEST) Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by dpdk.org (Postfix) with ESMTP id BF2EC1C1E5; Tue, 14 Apr 2020 12:26:34 +0200 (CEST) IronPort-SDR: AUGqHR7hxAwxCOwqivwTJPfOg73wDPjpviXyDm0qLVYb4Q+ck6TZmDNoy0qxKIeCPL3Wq3D0Rw SvxkHddIUH9Q== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Apr 2020 03:26:33 -0700 IronPort-SDR: +vAiGFdsXfcxG+IYpohHtR96PN147O9LNQcqP+qNjQ+uFseMqJ1hL4KZHKkyr8aY04bbTPiOZC a2qe7KqBXQwA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.72,382,1580803200"; d="scan'208";a="245382508" Received: from fmsmsx106.amr.corp.intel.com ([10.18.124.204]) by fmsmga008.fm.intel.com with ESMTP; 14 Apr 2020 03:26:33 -0700 Received: from fmsmsx111.amr.corp.intel.com (10.18.116.5) by FMSMSX106.amr.corp.intel.com (10.18.124.204) with Microsoft SMTP Server (TLS) id 14.3.439.0; Tue, 14 Apr 2020 03:26:33 -0700 Received: from FMSEDG002.ED.cps.intel.com (10.1.192.134) by fmsmsx111.amr.corp.intel.com (10.18.116.5) with Microsoft SMTP Server (TLS) id 14.3.439.0; Tue, 14 Apr 2020 03:26:32 -0700 Received: from NAM04-SN1-obe.outbound.protection.outlook.com (104.47.44.50) by edgegateway.intel.com (192.55.55.69) with Microsoft SMTP Server (TLS) id 14.3.439.0; Tue, 14 Apr 2020 03:26:00 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=XF7Pn3LVph0NXhFBaekQ4Dg+NrI4dJkePybFVs5odGSVD6ebVvsZywdz/gRrmRvnWlgTw7USv7j8RtrrIN6lDODK8VVFEgT/7ba3CvIm0r/Ljs+AzVTuHpZGEXIRPvQBcPusfLi6bddiBylA2wYG+k7qj7HwkJgWZTEe92QhTPudWt61JF70nmCd74aGxgK3QnIk02jPB/Gp7C0A/srFEoIOSXPuq80mDXDjrU7KShfF0dLMEz1qzg0fqLJv24VoXHKEV4pYqlSUhxcApmwyjwyl79V26gqDyBQkG6Xw2QYGitccxegf++YUGcRyqU3V8iQ6dPjED2ce8fFjoTEOQg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ehW3jLhfO5kJ+o7tLF+O8piQ+bwq+3F8d2l9M69V0DE=; b=NoYvi+RiJjZAeU/YEvFZTvHQFDeU9JM9JhL+Xk26TJDI38wUlgJzVak3r5cllJ3EalbOFm3hmgSVIIAtpb/6JtYBMsyUi6ZbBaPcddctPUXdBZcziMGo6OcmktFtPPanSABYxoNPJFi93D20CX9wTTrCCaS5/WWHfNc2RNJ4McAfKJvy/+AvlfDAUQPU1L79whE+vPcEsILgwVbiOD2U1CJ+EfQNsZKnoeJyzDi0qvD1fLPrYUUuOb4KcmTTGGleaY4FHJsG9jpmkXV1BeDmiCNxLpnyRZxSZAj7UbU+lT+06dl94H9tQOkOrDk1wI8DnGdK992DO21vBpa283BWIg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel.onmicrosoft.com; s=selector2-intel-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ehW3jLhfO5kJ+o7tLF+O8piQ+bwq+3F8d2l9M69V0DE=; b=WyZJMfjXLP7+ImAMZKOjToGZAwIP2GQFHORmtgXBAVXAW8VaW+CRtgiGc/FQOmtYr88auH1jcD1j9MzkAm4wXPjR5EqOODVDFBuN41HA7rNYYdQQaKAufOYVwc0pxyGt8AwtVIzdNY+BrY06lzidjJBQXMpDn4PnNZ3rI6Aitls= Received: from BYAPR11MB3301.namprd11.prod.outlook.com (2603:10b6:a03:7f::26) by BYAPR11MB3574.namprd11.prod.outlook.com (2603:10b6:a03:b1::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2900.20; Tue, 14 Apr 2020 10:25:47 +0000 Received: from BYAPR11MB3301.namprd11.prod.outlook.com ([fe80::f8cb:58cd:e958:fff4]) by BYAPR11MB3301.namprd11.prod.outlook.com ([fe80::f8cb:58cd:e958:fff4%6]) with mapi id 15.20.2900.028; Tue, 14 Apr 2020 10:25:47 +0000 From: "Ananyev, Konstantin" To: "Zhu, TaoX" , "Lu, Wenzhuo" , "Ye, Xiaolong" CC: "dev@dpdk.org" , "martin.weiser@allegro-packets.com" , "stable@dpdk.org" Thread-Topic: [PATCH v2] net/ixgbe: fix resource leak after thread exits normally Thread-Index: AQHWDwB2lbqMQzERmU2LHCAgEll6GqhyQPRggAWZ+oCAAJLo0A== Date: Tue, 14 Apr 2020 10:25:46 +0000 Message-ID: References: <1586495895-9610-1-git-send-email-taox.zhu@intel.com> <20200410062227.24201-1-taox.zhu@intel.com> <60652C6914E08D41B9AA1580751B3CA9015ED8D2@SHSMSX103.ccr.corp.intel.com> In-Reply-To: <60652C6914E08D41B9AA1580751B3CA9015ED8D2@SHSMSX103.ccr.corp.intel.com> Accept-Language: en-GB, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: dlp-product: dlpe-windows dlp-reaction: no-action dlp-version: 11.2.0.6 authentication-results: spf=none (sender IP is ) smtp.mailfrom=konstantin.ananyev@intel.com; x-originating-ip: [192.198.151.172] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 7f60599a-c797-4c91-5275-08d7e05e3237 x-ms-traffictypediagnostic: BYAPR11MB3574: x-ld-processed: 46c98d88-e344-4ed4-8496-4ed7712e255d,ExtAddr x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:1247; x-forefront-prvs: 0373D94D15 x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BYAPR11MB3301.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFTY:; SFS:(10019020)(366004)(346002)(376002)(39860400002)(136003)(396003)(316002)(9686003)(66446008)(64756008)(33656002)(76116006)(86362001)(66476007)(4326008)(8936002)(110136005)(66946007)(66556008)(71200400001)(55016002)(2906002)(54906003)(81156014)(8676002)(6506007)(7696005)(478600001)(26005)(186003)(53546011)(5660300002)(6636002)(52536014)(309714004); DIR:OUT; SFP:1102; x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: 4vIWTM8KxXrC3DX8X8Yc0+OHuCHBKrrfuV6je9fLttX6U4/t4LmpTzvRTfc8L2jPHEror7wQH1k9xCqOfw8HDH6c7I7DCm0/48wH8NeYj68bP+knwUcT/z5JRrAnKK5wB0f9Du9l6cV32vKRWsoTkZFtnWZAUOyHxVxc0hKb5UxIfhAgbeaaNY9lYfapef4ZOwqYQSvV2zOqA8NN7HYqaV5lhOcCGxb4hB1FzB3x2qam5A6Yv5a2yy9xZ/6ltkVMk+syyhLBy4RQXtPHlQHyBOToX9/v1V/1z+acZx/zdAHVeQB+IcGTlXWBAZqtwJY7IL5dtDhO9pbFtMBWMarMra9tlsqbjyBpj912EaIZt2+Us8UsLvzSraHQ8+fWM/vLiWaRjvl6uwzoFjOQhQF+adtc96RXmEHadXg7NJM+KrG14Fkok57gK3faQPJ5Ddl+m6jJekofRIbF9oF/jcBNjyPxMKaM/Q8W98Ak+6HIyag= x-ms-exchange-antispam-messagedata: jRamPf1NXudMSpu84YZAG28iTRFEKdA+CsaOCBp/Bpbe09TRLW0bspldRg8393KAZgstOHFHr/RgFE1DtdN/2L0LdMEjWQU1oasjm86yVllTGiQeuvgCj5i9cHolpWOqdbBE7xOo7IsappOP7u/mQA== Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-MS-Exchange-CrossTenant-Network-Message-Id: 7f60599a-c797-4c91-5275-08d7e05e3237 X-MS-Exchange-CrossTenant-originalarrivaltime: 14 Apr 2020 10:25:46.8529 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: glsbeHOwCZIH2Ab+3C8vZmEL70k/LqjlWybLuAKFnmGVPtOrudPk7Lc54r5hph/eBT+Yvcy49yZYL8CO/ljMsgXyb294LRfAPUMUk6V1ZsU= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR11MB3574 X-OriginatorOrg: intel.com Subject: Re: [dpdk-stable] [PATCH v2] net/ixgbe: fix resource leak after thread exits normally X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org Sender: "stable" Hi Tao, =20 > Because ixgbe_dev_wait_setup_link_complete() doesn't guarantee that the t= hread will always complete properly. So after the wait > timeout, need to call pthread_cancel() to cancel the thread. But pthread_cancel() also doesn't guarantee immediate thread termination. You'll have to wait for link_thread_running again to make sure. Another thing - in theory if link_thread was already terminated, then its TID can be reused by other thread and we will terminate different = thread (though chances are quite small).=20 > Definition of function ixgbe_dev_wait_setup_link_complete() as below: >=20 > /* return 1: setup complete, return 0: setup not complete, and wait timeo= ut*/ static int ixgbe_dev_wait_setup_link_complete(struct > rte_eth_dev *dev) { #define DELAY_INTERVAL 100 /* 100ms */ > #define MAX_TIMEOUT 90 /* 9s (90 * 100ms) in total */ > struct ixgbe_adapter *ad =3D dev->data->dev_private; > int timeout =3D MAX_TIMEOUT; >=20 > while (rte_atomic32_read(&ad->link_thread_running) && timeout) { > msec_delay(DELAY_INTERVAL); > timeout--; > } >=20 >=20 > return !!timeout; > } >=20 > BR, > Zhu, Tao >=20 > > -----Original Message----- > > From: Ananyev, Konstantin > > Sent: Friday, April 10, 2020 8:10 PM > > To: Zhu, TaoX ; Lu, Wenzhuo > > ; Ye, Xiaolong > > Cc: dev@dpdk.org; martin.weiser@allegro-packets.com; stable@dpdk.org > > Subject: RE: [PATCH v2] net/ixgbe: fix resource leak after thread exits > > normally > > > > Hi Tao, > > > > > From: Zhu Tao > > > > > > When the thread exits normally, pthread_join() is not called, which c= an > > > result in a resource leak. Therefore, the thread is set to separation > > > mode using function pthread_detach(), so that no program call > > > pthread_join() is required to recycle, and when the thread exits, > > > the system automatically reclaims resources. > > > > > > Fixes: 819d0d1d57f1 ("net/ixgbe: fix blocking system events") > > > Cc: stable@dpdk.org > > > > > > Signed-off-by: Zhu Tao > > > --- > > > drivers/net/ixgbe/ixgbe_ethdev.c | 3 +-- > > > 1 file changed, 1 insertion(+), 2 deletions(-) > > > > > > v2 changes: > > > commit log. > > > > > > diff --git a/drivers/net/ixgbe/ixgbe_ethdev.c > > b/drivers/net/ixgbe/ixgbe_ethdev.c > > > index 2c57976..f141ae4 100644 > > > --- a/drivers/net/ixgbe/ixgbe_ethdev.c > > > +++ b/drivers/net/ixgbe/ixgbe_ethdev.c > > > @@ -4165,11 +4165,9 @@ static int > > ixgbevf_dev_xstats_get_names(__rte_unused struct rte_eth_dev *dev, > > > ixgbe_dev_cancel_link_thread(struct rte_eth_dev *dev) > > > { > > > struct ixgbe_adapter *ad =3D dev->data->dev_private; > > > -void *retval; > > > > > > if (!ixgbe_dev_wait_setup_link_complete(dev)) { > > > pthread_cancel(ad->link_thread_tid); > > > -pthread_join(ad->link_thread_tid, &retval); > > > > As you already waiting for link thread termination in > > ixgbe_dev_wait_setup_link_complete(), do you still need > > pthread_cancel() here? > > > > > rte_atomic32_clear(&ad->link_thread_running); > > > PMD_DRV_LOG(ERR, "Link thread not complete, cancel it!"); > > > } > > > @@ -4186,6 +4184,7 @@ static int > > ixgbevf_dev_xstats_get_names(__rte_unused struct rte_eth_dev *dev, > > > u32 speed; > > > bool autoneg =3D false; > > > > > > +pthread_detach(pthread_self()); > > > speed =3D hw->phy.autoneg_advertised; > > > if (!speed) > > > ixgbe_get_link_capabilities(hw, &speed, &autoneg); > > > -- > > > 1.8.3.1 > > >=20