From mboxrd@z Thu Jan 1 00:00:00 1970 From: Wisam Monther Subject: Re: [PATCH v5 1/6] app/testpmd: fix ports list after removing several at once Date: Thu, 18 Oct 2018 11:49:13 +0000 Message-ID: References: <20180907233929.21950-1-thomas@monjalon.net> <20181018012402.1240-2-thomas@monjalon.net> <8CEF83825BEC744B83065625E567D7C260D12CD2@IRSMSX107.ger.corp.intel.com>, <4896325.UA0OBGhyO2@xps> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Cc: "dev@dpdk.org" , "Yigit, Ferruh" , "arybchenko@solarflare.com" , Ophir Munk , "rahul.lakkireddy@chelsio.com" To: Thomas Monjalon , "Iremonger, Bernard" Return-path: Received: from EUR04-HE1-obe.outbound.protection.outlook.com (mail-eopbgr70041.outbound.protection.outlook.com [40.107.7.41]) by dpdk.org (Postfix) with ESMTP id 069A15F1C for ; Thu, 18 Oct 2018 13:49:18 +0200 (CEST) In-Reply-To: <4896325.UA0OBGhyO2@xps> Content-Language: en-US List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Are we saving cycles by set it to be <=3D instead of < _ +1? BRs, Wisam Jaddo From: Thomas Monjalon Sent: Thursday, October 18, 2018 2:29 PM To: Iremonger, Bernard Cc: dev@dpdk.org; Yigit, Ferruh; arybchenko@solarflare.com; Ophi= r Munk; rahul.lakkireddy@chelsio.com; Wisam Monther Subject: Re: [dpdk-dev] [PATCH v5 1/6] app/testpmd: fix ports list after re= moving several at once 18/10/2018 12:40, Iremonger, Bernard: > From: Thomas Monjalon [mailto:thomas@monjalon.net] > > > > From: Wisam Jaddo > > > > When detaching a port, the full rte_device is removed. > > If the rte_device was hosting several ports, the testpmd list of ports = must be > > updated for multiple removals. > > ./devtools/check-git-log.sh -1 > Missing 'Fixes' tag: > app/testpmd: fix ports list after removing several at once I think it is OK. It is fixing a case which was not tested before. And we don't really need to backport it. > > Signed-off-by: Wisam Jaddo > > --- > > app/test-pmd/testpmd.c | 36 +++++++++++++++++++++++++----------- > > 1 file changed, 25 insertions(+), 11 deletions(-) > > > > diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c index > > 5dbbf783f..c4109417a 100644 > > --- a/app/test-pmd/testpmd.c > > +++ b/app/test-pmd/testpmd.c > > @@ -2186,6 +2186,30 @@ stop_port(portid_t pid) > > printf("Done\n"); > > } > > > > +static void > > +remove_unused_fwd_ports(void) > > +{ > > + int i; > > + int last_port_idx =3D nb_ports - 1; > > + > > + for (i =3D 0; i < last_port_idx + 1; i++) { /* iterate in ports_ids= */ > > Why not use " i <=3D last_port_index" instead of adding back 1 If Wisam agrees, I can fix it in v6. > > + if (rte_eth_devices[ports_ids[i]].state =3D=3D > > RTE_ETH_DEV_UNUSED) { > > + /* skip unused ports at the end */ > > + while (rte_eth_devices[ports_ids[last_port_idx]].st= ate > > + =3D=3D RTE_ETH_DEV_UNUSED && i <=3D > > last_port_idx) > > WARNING:LONG_LINE: line over 80 characters > #48: FILE: app/test-pmd/testpmd.c:2199: > + =3D=3D RTE_ETH_DEV_UNUSED && i <= =3D last_port_idx) Will fix it. Anyway, we should reverse the order of this check in order to avoid accessing ports_ids[-1]. > > + last_port_idx--;