From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <dev-bounces@dpdk.org>
Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124])
	by inbox.dpdk.org (Postfix) with ESMTP id C7E9FA0A02;
	Fri, 15 Jan 2021 10:21:57 +0100 (CET)
Received: from [217.70.189.124] (localhost [127.0.0.1])
	by mails.dpdk.org (Postfix) with ESMTP id B36A4140E2F;
	Fri, 15 Jan 2021 10:21:57 +0100 (CET)
Received: from mga02.intel.com (mga02.intel.com [134.134.136.20])
 by mails.dpdk.org (Postfix) with ESMTP id DC22A140E21;
 Fri, 15 Jan 2021 10:21:55 +0100 (CET)
IronPort-SDR: Xw9T7XP3v7x8HMHfL4HLxRuqnKlR4Y53yb8FCUNc+L+59bzHFqy37G82m5T6uJuHq6QV2sSlzg
 OuzIXmZLjyRw==
X-IronPort-AV: E=McAfee;i="6000,8403,9864"; a="165609646"
X-IronPort-AV: E=Sophos;i="5.79,349,1602572400"; d="scan'208";a="165609646"
Received: from fmsmga001.fm.intel.com ([10.253.24.23])
 by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384;
 15 Jan 2021 01:21:52 -0800
IronPort-SDR: 1U48pMkGU1lBSSS1uqRBzNSMKQpgyuoRwvy0PJWfZZqYxDA11PL+WZHU54+X/RAbf/r9UXwH27
 3VEugqq7514A==
X-ExtLoop1: 1
X-IronPort-AV: E=Sophos;i="5.79,349,1602572400"; d="scan'208";a="465533567"
Received: from fmsmsx605.amr.corp.intel.com ([10.18.126.85])
 by fmsmga001.fm.intel.com with ESMTP; 15 Jan 2021 01:21:51 -0800
Received: from fmsmsx610.amr.corp.intel.com (10.18.126.90) by
 fmsmsx605.amr.corp.intel.com (10.18.126.85) with Microsoft SMTP Server
 (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id
 15.1.1713.5; Fri, 15 Jan 2021 01:21:51 -0800
Received: from fmsedg602.ED.cps.intel.com (10.1.192.136) by
 fmsmsx610.amr.corp.intel.com (10.18.126.90) with Microsoft SMTP Server
 (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5
 via Frontend Transport; Fri, 15 Jan 2021 01:21:51 -0800
Received: from NAM12-BN8-obe.outbound.protection.outlook.com (104.47.55.168)
 by edgegateway.intel.com (192.55.55.71) with Microsoft SMTP Server
 (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id
 15.1.1713.5; Fri, 15 Jan 2021 01:21:51 -0800
ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none;
 b=Nkaw2IJQvybuQBX7L9UgyC+5fJ34I2HDKIEju6OgpBn/cSyNgOZKEtAqiYAl+EOt3tWC2b8xAUQ568PDppp21/GNuHOdeGax9XspKeg9Vy4IKA5dcrpQkSV0K3MOWIF8xhWbGK071wlEXL+5uJs+xDoCReL/s/M6lL6mLi/poaw0wTMmBtzXmsKO7nI5J/ipdrnNl+gqFDl3MioEPGVMWc2ZthkJbdPMJihkNAeA3KSopj33sJ4Qe4odoWvcPQRUYmAEMQ+LcEBIHcWIljJnIEkmXuaejElA2n2+mN/e2Vs1ucx0V6zNIvHbmj2fxGem+Xgm9J9hihKhu8vfp/Ahvg==
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=ZLNVyFK+TObrZId5igSPaX4uRm+Xx7OspR4fwdZNU94=;
 b=kNtwQbimBrcnhg4YtUS7oFmcdUS/B2Hs4msg1IyBbEFHGYivUvwe6wK4M9XoX5Umk40zHdWFsPs64vfW0veTXbCTG65a3wHVGUTC2grpoRJa1fv9lUcSWTrYXSSOVRBvPGV/wO8FSIVpLZJD4C4YIeiDnhCdb0K7U+hyk5vqYzxDtROrQuY9EmoqC8PbtBEn3cN319S6BlYj5CVbgu1/7wAO2ENkH7TzW0Ob4BcakJmO6CoWoevMnfapAgacKPnhKzCC+uviZXgZTCeFpjr1Dlm23ayx8l20Sy/eZuWLxcWKhu6/hW318TemicGTO5L+Lng3nnndF83lzySby6rEEQ==
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=ZLNVyFK+TObrZId5igSPaX4uRm+Xx7OspR4fwdZNU94=;
 b=VyWBCkksy0efuEP7EKbYlTym1xtj2O4+OpJxHq6DMRAsqhJ0kfRmCyHuPjUDCNzKhY/018LQRfCRBxvMNscTZU4obOHAFJSnz/xJKzMjlukW4HM7knQRG7FNn8c5BBTLFYdaqUE5GiAr4HJoKt7LhuHEVOHVRZsh0nyIcZANtc0=
Received: from CY4PR11MB1750.namprd11.prod.outlook.com (2603:10b6:903:126::8)
 by CY4PR11MB0022.namprd11.prod.outlook.com (2603:10b6:910:79::19)
 with Microsoft SMTP Server (version=TLS1_2,
 cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3763.9; Fri, 15 Jan
 2021 09:21:46 +0000
Received: from CY4PR11MB1750.namprd11.prod.outlook.com
 ([fe80::4dd8:2689:73d4:43d3]) by CY4PR11MB1750.namprd11.prod.outlook.com
 ([fe80::4dd8:2689:73d4:43d3%7]) with mapi id 15.20.3742.012; Fri, 15 Jan 2021
 09:21:46 +0000
From: "Li, Xiaoyun" <xiaoyun.li@intel.com>
To: "Xing, Beilei" <beilei.xing@intel.com>, "Yu, DapengX"
 <dapengx.yu@intel.com>, "Lu, Wenzhuo" <wenzhuo.lu@intel.com>, "Iremonger,
 Bernard" <bernard.iremonger@intel.com>, Stephen Hemminger
 <stephen@networkplumber.org>
CC: "dev@dpdk.org" <dev@dpdk.org>, "stable@dpdk.org" <stable@dpdk.org>
Thread-Topic: [dpdk-dev] [PATCH] app/testpmd: avoid exit without resource
 release
Thread-Index: AQHW2nwz7nU5vL0nHkikC5faq4IKGKooKAcAgAAnk4CAADe/gA==
Date: Fri, 15 Jan 2021 09:21:45 +0000
Message-ID: <CY4PR11MB175016F66482F99FD2FB98D999A70@CY4PR11MB1750.namprd11.prod.outlook.com>
References: <20201224035748.67012-1-dapengx.yu@intel.com>
 <20201224190317.4bac8b59@hermes.local>
 <5a697c3c06324bdbbe7b2bef265df4a4@intel.com>
 <dba53630061c4485bc2869dbfbf954f5@intel.com>
 <MN2PR11MB380745B4CF52902E85D25CB0F7A70@MN2PR11MB3807.namprd11.prod.outlook.com>
In-Reply-To: <MN2PR11MB380745B4CF52902E85D25CB0F7A70@MN2PR11MB3807.namprd11.prod.outlook.com>
Accept-Language: en-US
Content-Language: en-US
X-Mentions: stephen@networkplumber.org
X-MS-Has-Attach: 
X-MS-TNEF-Correlator: 
authentication-results: intel.com; dkim=none (message not signed)
 header.d=none;intel.com; dmarc=none action=none header.from=intel.com;
x-originating-ip: [192.55.46.39]
x-ms-publictraffictype: Email
x-ms-office365-filtering-correlation-id: 9982e471-d32f-4ac3-711e-08d8b936fad3
x-ms-traffictypediagnostic: CY4PR11MB0022:
x-ld-processed: 46c98d88-e344-4ed4-8496-4ed7712e255d,ExtAddr
x-ms-exchange-transport-forked: True
x-microsoft-antispam-prvs: <CY4PR11MB00221111B9BBDFB322EC5D5699A70@CY4PR11MB0022.namprd11.prod.outlook.com>
x-ms-oob-tlc-oobclassifiers: OLM:2733;
x-ms-exchange-senderadcheck: 1
x-microsoft-antispam: BCL:0;
x-microsoft-antispam-message-info: bVtfqz4/McL9gogzPULXFbYAY/pf8/T4PNQFkzrUgofc+/fvf3y/mWRFmQhS+PyDcWqGaTrlqVAMMdYUA6tlK30R7WXvUeFKMJK4QwDpgQBdy6CE/v6BEJhhdcaMP1ISGLVIxtde9Q/5tBWd3HMTc+SrxomdorRnikLLUq1yQjFH2gRmunGUI5WpuQQwgfajSVJS2urhkAah64VXvnK7/U0SCseEWNO10IBza32ql2a+olOXkrMEEYTfT9swBDQUqaY7xQGyMp0TmqSOLLXfjeaMOE0RCdg/ErSjxX5O0Sc/vK1fY5Zl+eRihwH8cXZZyLbkKxC0jCQuWPBPiLDBhIt3XyN0yKMad0yIvfefjVLlmUQC1LDhOOZt1s25TFLZPGn26EnCfiG6kXwfOWHrXw==
x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:;
 IPV:NLI; SFV:NSPM; H:CY4PR11MB1750.namprd11.prod.outlook.com; PTR:; CAT:NONE;
 SFS:(4636009)(136003)(396003)(346002)(39860400002)(366004)(376002)(71200400001)(53546011)(26005)(66946007)(316002)(64756008)(6506007)(76116006)(52536014)(66556008)(186003)(5660300002)(66446008)(86362001)(9686003)(8676002)(54906003)(110136005)(8936002)(83380400001)(33656002)(4326008)(7696005)(66476007)(478600001)(2906002)(55016002);
 DIR:OUT; SFP:1102; 
x-ms-exchange-antispam-messagedata: =?us-ascii?Q?ZbV8BdOfVDW8Pzs6A/vYKr85c3A4n2N0Rjm0PCme31XajObJWFh+HlKeGneI?=
 =?us-ascii?Q?/GRDwmIOqkMn+8Lv6lFywyZ0YqZrkbt5P8AAdxkvrKrRtkTnPeO6ryELU1b0?=
 =?us-ascii?Q?hK7OCDAzzBJ4lcFYuZTFLRKywgOj4uWRB8H37BaOvNepjveEws6Br3GYyaf2?=
 =?us-ascii?Q?22IkVaka5rIIOMr1M5k0vYvFGNGcUQWSHWvORAXPw1pczW9/mUkjjobvlkIB?=
 =?us-ascii?Q?wrxi9aHuqA4kNjeS3PSsrb8i6B5wLI5uBS2mU6FallDB01KBoIE0rraVVxUN?=
 =?us-ascii?Q?/E91QNSFwTBKN4Ergu4lSQNh3KqUhGLnEwck6Alahc6ThNNv8PMhK8XxE0yC?=
 =?us-ascii?Q?Ym8HAw0GfCav/I+NQMHgPJzQOj7UMmeIFvl+ZqGb/mcBh2BisZmd2DZm/KjY?=
 =?us-ascii?Q?qWtXjwcvyESszfyWYkp2Muqon2Lh4Oo7knU3/btq0D3zjn8Is8fPP6wvEdDU?=
 =?us-ascii?Q?/v1pCJdm15/lbVHgcuIYvzTvO8jNWMUeLWy6HZsrxVGeTsapItUAvcicz9h1?=
 =?us-ascii?Q?SyaWYEbrKNJAfcCjZxNbBuGMjVDpitp8XDB8l6WGrQg/nhfL+LmxtkivNrdU?=
 =?us-ascii?Q?h2KNxhqL3821Grhd+zWKPH+Wl+UfbzkTFvdt/pi2MvYSB7Uje7ERdR4cY6PU?=
 =?us-ascii?Q?AeDeOnm5RxqSKE651/OqpKu7xDE8iQkPamRihGp0Ssws5bH90E7fWUeykfCQ?=
 =?us-ascii?Q?AzyZMCAo0zx1e0vMrpzM5c5llKFUg8qs6XFfVL8H+XPFq1qmy0v4wmGXPYSr?=
 =?us-ascii?Q?TnQC/NTThzaGGlKyTvEftdjz3Ark6Y7mbh6gmS6q9p3VC8Irv4pv7N2w+BHP?=
 =?us-ascii?Q?/6YlAhixvLpAGQCHw2OzHT6y6cXNJiBMvPmyzZf3sqpkC6AtOeNz3Qj8O7sB?=
 =?us-ascii?Q?1UyNtOW5cHLV2AgL7R90WSWp06HamYnuRXWDaCyEPvgNKI2VTIC/K/jRXM+z?=
 =?us-ascii?Q?UY0dXJgJV+f1EQA3HkKnAsiZAHkAfczwzKUQBYi7uig=3D?=
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: CY4PR11MB1750.namprd11.prod.outlook.com
X-MS-Exchange-CrossTenant-Network-Message-Id: 9982e471-d32f-4ac3-711e-08d8b936fad3
X-MS-Exchange-CrossTenant-originalarrivaltime: 15 Jan 2021 09:21:45.9629 (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: 2/D7ZhfoYywMy8XMdTplxDHGw5RF9KNL4lgSjAXUnn22jyVcNoDwL5t29JXSoOY6uXzH5Cl1/t6O3lPJwLTUaA==
X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR11MB0022
X-OriginatorOrg: intel.com
Subject: Re: [dpdk-dev] [PATCH] app/testpmd: avoid exit without resource
 release
X-BeenThere: dev@dpdk.org
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: DPDK patches and discussions <dev.dpdk.org>
List-Unsubscribe: <https://mails.dpdk.org/options/dev>,
 <mailto:dev-request@dpdk.org?subject=unsubscribe>
List-Archive: <http://mails.dpdk.org/archives/dev/>
List-Post: <mailto:dev@dpdk.org>
List-Help: <mailto:dev-request@dpdk.org?subject=help>
List-Subscribe: <https://mails.dpdk.org/listinfo/dev>,
 <mailto:dev-request@dpdk.org?subject=subscribe>
Errors-To: dev-bounces@dpdk.org
Sender: "dev" <dev-bounces@dpdk.org>

Hi
Actually, you can just type "stty echo" to solve the problem you met.

But anyway, if you want to fix it in DPDK
I think you misunderstood stephan's solution.
You don't need to implement atexit() yourself in eal. It's a common functio=
n like exit() in rte_exit().
Then when exit() is called. Each function registered by atexit() will be ca=
lled in stack order.

The simplest way to solve this problem is to register a function with atexi=
t() in prompt() in each app which uses cmdline.
Then when exit() in rte_exit() is called, the registered clean function wil=
l be called directly.

Registering in prompt() is because that prompt() is the function which star=
ts cmdline in each app.

@Stephen Hemminger What do you think of this about atexit() in prompt() in =
each app?
I understand it's cmdline and rte_exit problem. But atexit needs a function=
 without parameters.
And the cleanup for cmdline is cmdline_stdin_exit(struct cmdline *cl) which=
 needs cmdline as the parameter to restore original terminal setting.
Setting a global value will be too ugly to me.

BRs
Xiaoyun

> -----Original Message-----
> From: stable <stable-bounces@dpdk.org> On Behalf Of Xing, Beilei
> Sent: Friday, January 15, 2021 13:50
> To: Yu, DapengX <dapengx.yu@intel.com>; Lu, Wenzhuo
> <wenzhuo.lu@intel.com>; Iremonger, Bernard <bernard.iremonger@intel.com>
> Cc: Stephen Hemminger <stephen@networkplumber.org>; dev@dpdk.org;
> stable@dpdk.org
> Subject: Re: [dpdk-stable] [dpdk-dev] [PATCH] app/testpmd: avoid exit wit=
hout
> resource release
>=20
> > -----Original Message-----
> > From: Yu, DapengX <dapengx.yu@intel.com>
> > Sent: Friday, January 15, 2021 11:29 AM
> > To: Lu, Wenzhuo <wenzhuo.lu@intel.com>; Xing, Beilei
> > <beilei.xing@intel.com>; Iremonger, Bernard
> > <bernard.iremonger@intel.com>
> > Cc: Yu, DapengX <dapengx.yu@intel.com>; Stephen Hemminger
> > <stephen@networkplumber.org>; dev@dpdk.org; stable@dpdk.org
> > Subject: RE: [dpdk-dev] [PATCH] app/testpmd: avoid exit without
> > resource release
> >
> > Hi Wenzhuo, Beilei, Bernard
> >
> > I need testpmd app maintainers' comment :
> >     Do you prefer the simple solution in this patch or Stephen's
> > comprehensive and generic solution(which will modify librte_cmdline,
> > testpmd (and maybe rte_exit()))?
>=20
> The patch just workarounds a specific case, the issue exits in many cases=
, such
> as Rxonly mode and Rxq is 0.
> So It's better to investigate how to solve the generic problem according =
to
> Stephen's comments.
>=20
> > So I can continue resolving the defect.
> >
> > Thanks!
> >
> > -----Original Message-----
> > From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Yu, DapengX
> > Sent: Friday, December 25, 2020 1:09 PM
> > To: Stephen Hemminger <stephen@networkplumber.org>
> > Cc: Lu, Wenzhuo <wenzhuo.lu@intel.com>; Xing, Beilei
> > <beilei.xing@intel.com>; Iremonger, Bernard
> > <bernard.iremonger@intel.com>; dev@dpdk.org; stable@dpdk.org
> > Subject: Re: [dpdk-dev] [PATCH] app/testpmd: avoid exit without
> > resource release
> >
> > Hi Stephen,
> >
> > Do you mean this solution?
> > 1. support atexit() in librte_eal, other component can use it to
> > register a function to be called when rte_exit() is called.
> > 2. in librte_cmdline, use atexit() to register a function to release
> > resource
> >
> > I am looking forward to more comments from other maintainers, since
> > this solution will modify librte_eal and librte_cmdline, but not just t=
estpmd app.
> >
> >
> > -----Original Message-----
> > From: Stephen Hemminger [mailto:stephen@networkplumber.org]
> > Sent: Friday, December 25, 2020 11:03 AM
> > To: Yu, DapengX <dapengx.yu@intel.com>
> > Cc: Lu, Wenzhuo <wenzhuo.lu@intel.com>; Xing, Beilei
> > <beilei.xing@intel.com>; Iremonger, Bernard
> > <bernard.iremonger@intel.com>; dev@dpdk.org; stable@dpdk.org
> > Subject: Re: [dpdk-dev] [PATCH] app/testpmd: avoid exit without
> > resource release
> >
> > On Thu, 24 Dec 2020 11:57:48 +0800
> > dapengx.yu@intel.com wrote:
> >
> > > From: YU DAPENG <dapengx.yu@intel.com>
> > >
> > > In interactive mode, if testpmd exit by calling rte_exit without
> > > cmdline resource release, terminal will not echo keyboard input. So
> > > add code to just show error message, but not exit testpmd when
> > > unexpected happens on starting packet forwarding in interactive
> > > mode. User
> > can type "quit"
> > > to exit testpmd later.
> > >
> > > Fixes: 5a8fb55c48ab ("app/testpmd: support unidirectional
> > > configuration")
> > > Cc: stable@dpdk.org
> > >
> > > Signed-off-by: YU DAPENG <dapengx.yu@intel.com>
> >
> > Sounds like a more generic problem with rte_exit and librte_cmdline.
> > Would it better to fix it in librte_cmdline by adding an atexit() handl=
er.
> >