From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <stable-bounces@dpdk.org>
Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124])
	by inbox.dpdk.org (Postfix) with ESMTP id 8F1CFA054A
	for <public@inbox.dpdk.org>; Wed,  7 Sep 2022 10:53:44 +0200 (CEST)
Received: from [217.70.189.124] (localhost [127.0.0.1])
	by mails.dpdk.org (Postfix) with ESMTP id 808F8400D6;
	Wed,  7 Sep 2022 10:53:44 +0200 (CEST)
Received: from mga04.intel.com (mga04.intel.com [192.55.52.120])
 by mails.dpdk.org (Postfix) with ESMTP id E712240042;
 Wed,  7 Sep 2022 10:53:41 +0200 (CEST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple;
 d=intel.com; i=@intel.com; q=dns/txt; s=Intel;
 t=1662540822; x=1694076822;
 h=from:to:cc:subject:date:message-id:references:
 in-reply-to:content-transfer-encoding:mime-version;
 bh=bMVEuqXM8kXQAWIqTuOou+YBihoXB1MMNRRPl6DSHtY=;
 b=GVv/tILRxPme0zviEpmZ2YoRapGpFaaw//wjnVc0s6IInuzi/RX0XTi0
 1HfWmheeNUFgUiu9AHVgCufAUjqdU1P/0IGh3s0n6v3E8ptp5ZqB6TZVa
 FvZDwPHqxSgS4HLuw1OM/x4ruI51J7w7ab1ZXeIJflDXMd/0ErUYznBaK
 R5L7F2N/vlCKHcIjIBjKovDJ70/QuwwE7TiA2nYMQeTGgJLdHdhfIL4Cd
 z+d01TPQvJo/ZABOqQqTruVMe831pbBJvaGc5yE65XpVnBPk84nG06Q2i
 IJGFrEOgdZfAwe20/HI9yXjidCLcx2o978rxPF508+90gYULdP1rPPBTB Q==;
X-IronPort-AV: E=McAfee;i="6500,9779,10462"; a="295554250"
X-IronPort-AV: E=Sophos;i="5.93,296,1654585200"; d="scan'208";a="295554250"
Received: from fmsmga001.fm.intel.com ([10.253.24.23])
 by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384;
 07 Sep 2022 01:53:41 -0700
X-ExtLoop1: 1
X-IronPort-AV: E=Sophos;i="5.93,296,1654585200"; d="scan'208";a="756692926"
Received: from orsmsx602.amr.corp.intel.com ([10.22.229.15])
 by fmsmga001.fm.intel.com with ESMTP; 07 Sep 2022 01:53:41 -0700
Received: from orsmsx611.amr.corp.intel.com (10.22.229.24) by
 ORSMSX602.amr.corp.intel.com (10.22.229.15) with Microsoft SMTP Server
 (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id
 15.1.2375.31; Wed, 7 Sep 2022 01:53:40 -0700
Received: from orsmsx601.amr.corp.intel.com (10.22.229.14) by
 ORSMSX611.amr.corp.intel.com (10.22.229.24) with Microsoft SMTP Server
 (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id
 15.1.2375.31; Wed, 7 Sep 2022 01:53:40 -0700
Received: from ORSEDG601.ED.cps.intel.com (10.7.248.6) by
 orsmsx601.amr.corp.intel.com (10.22.229.14) with Microsoft SMTP Server
 (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id
 15.1.2375.31 via Frontend Transport; Wed, 7 Sep 2022 01:53:40 -0700
Received: from NAM10-DM6-obe.outbound.protection.outlook.com (104.47.58.104)
 by edgegateway.intel.com (134.134.137.102) with Microsoft SMTP Server
 (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id
 15.1.2375.31; Wed, 7 Sep 2022 01:53:40 -0700
ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none;
 b=TUGX2mNfKCmWHMWDppHsQc8NsgeouKhQ5TSzGnBSHd51U7ybdeWCPEcFbYc5+9hGeYzxwHmR0w01FTziq7+Zg4mtRQYBZsRH72NyPy0fIwdcN3V+aK/UwL6HqKACq7gIFQBpVFkAEjnw2+es1yO6Urp8G4fbSIGLYOdWaYlg1STdJ0eCf70hEx2EUvnssEK/W7+D3Q8TEV7gyfkI73qOQsUswUQeeuwzQZGK4POVURVn/TRwHFUf3gXyauJA3EROYGri95B0FiP0pzNP2Hg2jCnmEESlLv/Sf33mC3R6egKo858fYRwJ7g+yhX0oWnkWz8pWoA64ZGhvsrapU/Oqmw==
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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1;
 bh=yVPicjolvexEK8avQHs5InDd6rUPGhWOPwQfcOJK0iE=;
 b=Nc0rP3AlocXbCVzHHa2K+eFvicYDGETWUTpGzeHFlm0j+mBgNhYHWkXexm6eJ/jOYUcttG2t4mjS4E6Fqv6kyplJHpXjFkFNTkoH+FLaEfxrfxx+CnO3EwDe48u4F9Z0tmo7DMCApCyhjW0+Uk63qNdfRLQIb+jnIA9s75oVpDFDSVZDVqzzZr9QoGWSCjElTX+tpG1gXlU0bp+Ju4kb5GjkYS3bqI52HqgGgWx1XZaEhzYprKFAU57ESB+sLrRZhoaApLAdCwT+AXp216KuGpUdvjDA4xD3B36tJkstxv7dJaXbmn7n+2qjCHVIh2iZao3kQka0PT8U7yqh1ZYQvg==
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
Received: from CO6PR11MB5602.namprd11.prod.outlook.com (2603:10b6:303:13a::5)
 by CY8PR11MB7267.namprd11.prod.outlook.com (2603:10b6:930:9a::13)
 with Microsoft SMTP Server (version=TLS1_2,
 cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5612.14; Wed, 7 Sep
 2022 08:53:38 +0000
Received: from CO6PR11MB5602.namprd11.prod.outlook.com
 ([fe80::c112:6e86:1bdf:66ed]) by CO6PR11MB5602.namprd11.prod.outlook.com
 ([fe80::c112:6e86:1bdf:66ed%3]) with mapi id 15.20.5588.017; Wed, 7 Sep 2022
 08:53:38 +0000
From: "Zeng, ZhichaoX" <zhichaox.zeng@intel.com>
To: Stephen Hemminger <stephen@networkplumber.org>
CC: "dev@dpdk.org" <dev@dpdk.org>, "david.marchand@redhat.com"
 <david.marchand@redhat.com>, "Yang, Qiming" <qiming.yang@intel.com>, "Zhou,
 YidingX" <yidingx.zhou@intel.com>, "stable@dpdk.org" <stable@dpdk.org>,
 "Richardson, Bruce" <bruce.richardson@intel.com>, Harman Kalra
 <hkalra@marvell.com>
Subject: RE: [PATCH v5] lib/eal: fix segfaults in exiting
Thread-Topic: [PATCH v5] lib/eal: fix segfaults in exiting
Thread-Index: AQHYwZuGSu2EXLcmsUaPzXZE0EBXh63SgHeAgAEBw0A=
Date: Wed, 7 Sep 2022 08:53:38 +0000
Message-ID: <CO6PR11MB5602B3E21902FA2FA0B046F5F1419@CO6PR11MB5602.namprd11.prod.outlook.com>
References: <20220615060154.6905-1-zhichaox.zeng@intel.com>
 <20220906025132.160801-1-zhichaox.zeng@intel.com>
 <20220906080337.25dc426d@hermes.local>
In-Reply-To: <20220906080337.25dc426d@hermes.local>
Accept-Language: zh-CN, en-US
Content-Language: en-US
X-MS-Has-Attach: 
X-MS-TNEF-Correlator: 
dlp-product: dlpe-windows
dlp-version: 11.6.500.17
dlp-reaction: no-action
authentication-results: dkim=none (message not signed)
 header.d=none;dmarc=none action=none header.from=intel.com;
x-ms-publictraffictype: Email
x-ms-office365-filtering-correlation-id: 04c89f6e-d58b-4904-a7da-08da90ae74da
x-ms-traffictypediagnostic: CY8PR11MB7267:EE_
x-ms-exchange-senderadcheck: 1
x-ms-exchange-antispam-relay: 0
x-microsoft-antispam: BCL:0;
x-microsoft-antispam-message-info: PraJ6BpR18e2JbJ3rcGZhjzrMYfM3HiNCJAKl2iIHA1nRDPJVgjMyXaoZBx/ys/KEV33q3WZRHCByM4L5blhrDzCLibYcjybTLFxvKydGLHb9PkpnNxJaCHvfcl+CehZEaj9b+DbKoE4V5nTBybsg3gUuAZZqEkoVLWaq5ysUyOaj+x5sjj1tMeb4TNduAigWb/AYNhEZFFafqeuu042FfMhV1zSHnfCg/v4PJTYHneWPmIdAzCgmThrbJbjUMMukWuRfCZSOp1lbXEIXX2aOf36uClFp8Xqf3jt7cs/wxUwg+DNN1UcPyJ6E7CpNNi8QvIJU362/94bkbZXLuFYhDzVKwKsnENsSWzwJlghXRCYaI4CQLzlpoJuEiXpWf5XZGayU892S7kTRAOWwqC+fc4kdCO0tvzmyKjGPoKeoHam6EA1tEUX+O1Q75RAc2zGo8Tps5FhqhGmI5EUiOUBpEhlT4C3sepGQea/YlE758Vnh2T2KXKeopw38wbPH+5Rsl1o2AtKx5O8bBDdXxCFZAbIky/IqGO/Ky/LfzH9Q5tugNalzmwNbQn6HzCuOH8NNsZTPgTK9eLq+a1VPciMwoMG6fy9dFNTdI/T9zgRmYHko7msAB/MJ6p7VwPCq8ycK97ZIpthymPc3k+PksprUHY3xGc+4eynHlARwOCSTbtJWAPAgpjxpgXSuzM/QqI/WXgCNjpWzM9eqXzgH22tvJW5DUb0ePducr4TazrG9tKQdCjAfP0Dheo5HEWkzxg5f/Ju35+eFPNhby51FzZA9g==
x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:;
 IPV:NLI; SFV:NSPM; H:CO6PR11MB5602.namprd11.prod.outlook.com; PTR:; CAT:NONE;
 SFS:(13230016)(396003)(366004)(136003)(39860400002)(376002)(346002)(6506007)(7696005)(86362001)(4744005)(4326008)(8676002)(64756008)(66946007)(66476007)(66556008)(76116006)(478600001)(186003)(66446008)(41300700001)(8936002)(52536014)(33656002)(5660300002)(55016003)(71200400001)(2906002)(316002)(6916009)(54906003)(38070700005)(82960400001)(26005)(9686003)(122000001)(38100700002);
 DIR:OUT; SFP:1102; 
x-ms-exchange-antispam-messagedata-chunkcount: 1
x-ms-exchange-antispam-messagedata-0: =?us-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TuJs67wkHjRCztR81xuQvT2g3+GDEzF2mP7qVzcvBRLLhNlixZHC?=
 =?us-ascii?Q?EFskGLbCtTN5WbBRPCWJTWTmaoCIJ6F3ySADJzbHT1OYWAFnNEnosMwnEjug?=
 =?us-ascii?Q?4bS2lBfPF9PCI0YFJnXZsuxZjlTgAKbksh5huWUq3duOYKy08em0OIomiwNC?=
 =?us-ascii?Q?65ZUrbf2rqax7BrD8uxp0CjWJ38mZlM5S49gRrDJvwlFTjEHAylvBZR3DAMn?=
 =?us-ascii?Q?e3POjpmou4T9+eq6YeTPpw7b/DT2ft7rOuAW/lGB0JhItoq0szx1wXRAVMv+?=
 =?us-ascii?Q?+IPaMme/R2dib1ssGmHPtkpBGYFRIwB8VILrE/F8Ms3xPkbJcfn+Bg/jSRN5?=
 =?us-ascii?Q?Qcpw0G7qWSniEcaLWeYsPBTwwJ7G5gNci4w4qlrP4+FmnRQ3zcwD8pIC90sc?=
 =?us-ascii?Q?UxgKbYTIpI+xch5/lyucM/AS/nr9LRQFAazf3hMmJ4xY6PNKAFQtG/X1ngyc?=
 =?us-ascii?Q?f4pAD9MztfafscoMICdmYJdF4EYI4eYeHlKeOWED/POwp8Eab4tL1LlPgyOJ?=
 =?us-ascii?Q?TtRqRvW1+iVjevt4JsaQhqmRfURlybMBg/hl7y47puVXuL0JmV8YRGSSbBXR?=
 =?us-ascii?Q?9it8JZk+/xWxHOxan7fTHDyP/x9plBnwmRawNyRpjCPrmonCfIdP/bG6wxjO?=
 =?us-ascii?Q?fiI+SoCbblf3m3emvhpjhq2ZmEsNX+gvmrh/uJLR78N38OI5JfMkVX/rWFJ1?=
 =?us-ascii?Q?LDJ+O4Qqsn6djA1+gaD/3OXW4dHGjo3tZO15MznV?=
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: quoted-printable
MIME-Version: 1.0
X-MS-Exchange-CrossTenant-AuthAs: Internal
X-MS-Exchange-CrossTenant-AuthSource: CO6PR11MB5602.namprd11.prod.outlook.com
X-MS-Exchange-CrossTenant-Network-Message-Id: 04c89f6e-d58b-4904-a7da-08da90ae74da
X-MS-Exchange-CrossTenant-originalarrivaltime: 07 Sep 2022 08:53:38.5230 (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: OndlFL45nK1/9zIBq9wS/8WKXw0fVdlwKNf66W3kzkxa7Sp+blZT5SOJSzehquBPkwPwsl96hESyduLYLI4dwg==
X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY8PR11MB7267
X-OriginatorOrg: intel.com
X-BeenThere: stable@dpdk.org
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: patches for DPDK stable branches <stable.dpdk.org>
List-Unsubscribe: <https://mails.dpdk.org/options/stable>,
 <mailto:stable-request@dpdk.org?subject=unsubscribe>
List-Archive: <http://mails.dpdk.org/archives/stable/>
List-Post: <mailto:stable@dpdk.org>
List-Help: <mailto:stable-request@dpdk.org?subject=help>
List-Subscribe: <https://mails.dpdk.org/listinfo/stable>,
 <mailto:stable-request@dpdk.org?subject=subscribe>
Errors-To: stable-bounces@dpdk.org

Hi Stephen,

> >
> > +static void mark_forked(void)
> > +{
> > +	is_forked++;
> > +}
> > +
>=20
> This will end up counting application threads as well.
>=20

I think it would be counted in the child process when 'fork()' is called,
and in the parent process, it would be zero.

> Also, it would need to be atomic.
>=20

Thanks for your advice.

> >  /* Launch threads, called at application init(). */  int
> > rte_eal_init(int argc, char **argv) @@ -1324,6 +1331,8 @@
> > rte_eal_init(int argc, char **argv)
> >
> >  	eal_mcfg_complete();
> >
> > +	pthread_atfork(NULL, NULL, mark_forked);
> > +
> >  	return fctret;
> >  }
>=20
> >  int
> >  rte_eal_cleanup(void)
> >  {
> > +	if (is_forked)
> > +		return 0;
> > +
>=20
> rte_eal_cleanup is supposed to be called only once by application.

Yes. But in some case(e.g. debug_autotest of dpdk-test), it would fork
a child process to test 'rte_exit()', then it would call 'rte_eal_cleanup()=
'.
So 'is_forked' is introduced to avoid this situation.

Regards
Zhichao