From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by dpdk.org (Postfix) with ESMTP id 8DCEC2C5D for ; Mon, 13 Jun 2016 11:12:05 +0200 (CEST) Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga104.fm.intel.com with ESMTP; 13 Jun 2016 02:12:04 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.26,466,1459839600"; d="scan'208";a="996428633" Received: from fmsmsx107.amr.corp.intel.com ([10.18.124.205]) by orsmga002.jf.intel.com with ESMTP; 13 Jun 2016 02:12:04 -0700 Received: from FMSMSX109.amr.corp.intel.com (10.18.116.9) by fmsmsx107.amr.corp.intel.com (10.18.124.205) with Microsoft SMTP Server (TLS) id 14.3.248.2; Mon, 13 Jun 2016 02:12:03 -0700 Received: from shsmsx102.ccr.corp.intel.com (10.239.4.154) by fmsmsx109.amr.corp.intel.com (10.18.116.9) with Microsoft SMTP Server (TLS) id 14.3.248.2; Mon, 13 Jun 2016 02:12:03 -0700 Received: from shsmsx103.ccr.corp.intel.com ([169.254.4.181]) by shsmsx102.ccr.corp.intel.com ([169.254.2.147]) with mapi id 14.03.0248.002; Mon, 13 Jun 2016 17:11:58 +0800 From: "Tan, Jianfeng" To: Yuanhan Liu CC: "dev@dpdk.org" , "Xie, Huawei" Thread-Topic: [PATCH] virito: fix reuse index in nested loop Thread-Index: AQHRxJIIZKrNbYKxQEe4Ji5Hv83r0Z/mlBGAgACGnTA= Date: Mon, 13 Jun 2016 09:11:57 +0000 Message-ID: References: <1465725945-95964-1-git-send-email-jianfeng.tan@intel.com> <20160613085749.GM10038@yliu-dev.sh.intel.com> In-Reply-To: <20160613085749.GM10038@yliu-dev.sh.intel.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: [dpdk-dev] [PATCH] virito: fix reuse index in nested loop X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 13 Jun 2016 09:12:06 -0000 > -----Original Message----- > From: Yuanhan Liu [mailto:yuanhan.liu@linux.intel.com] > Sent: Monday, June 13, 2016 4:58 PM > To: Tan, Jianfeng > Cc: dev@dpdk.org; Xie, Huawei > Subject: Re: [PATCH] virito: fix reuse index in nested loop >=20 > On Sun, Jun 12, 2016 at 10:05:45AM +0000, Jianfeng Tan wrote: > > This patches fixes problem of reusing index of outmost loop in nested > > loops. This bug will lead to failure when starting a multi queue > > virtio device: rx queues (except from the first one) cannot be started, > > expecially their vq_ring cannot be initialized, so that when invoking > > rx func on these queues, segment fault happens. > > > > Fixes: a900472aedef ("virtio: split virtio Rx/Tx queue") >=20 > Good catch! >=20 > > Signed-off-by: Jianfeng Tan > > --- > > drivers/net/virtio/virtio_rxtx.c | 36 ++++++++++++++++++++------------= ---- > > 1 file changed, 20 insertions(+), 16 deletions(-) > > > > diff --git a/drivers/net/virtio/virtio_rxtx.c b/drivers/net/virtio/virt= io_rxtx.c > > index 2e7205b..b96d0cb 100644 > > --- a/drivers/net/virtio/virtio_rxtx.c > > +++ b/drivers/net/virtio/virtio_rxtx.c > > @@ -331,7 +331,7 @@ virtio_dev_rxtx_start(struct rte_eth_dev *dev) > > * - Allocate blank mbufs for the each rx descriptor > > * > > */ > > - int i; > > + int i, j; >=20 > However, I don't quite like using "i, j, k" stuff. So, how about > renaming "j" to "ring_idx"? >=20 > > PMD_INIT_FUNC_TRACE(); > > > > @@ -352,15 +352,18 @@ virtio_dev_rxtx_start(struct rte_eth_dev *dev) > > error =3D ENOSPC; > > > > #ifdef RTE_MACHINE_CPUFLAG_SSSE3 > > - if (use_simple_rxtx) > > - for (i =3D 0; i < vq->vq_nentries; i++) { > > - vq->vq_ring.avail->ring[i] =3D i; > > - vq->vq_ring.desc[i].flags =3D > VRING_DESC_F_WRITE; > > + if (use_simple_rxtx) { > > + uint16_t k; >=20 > We could reuse "ring_idx" here; no need to define yet another iterate var > for that. Make sense. Besides, since comparison between unsigned and signed is a viol= ation to static code analyzer, I'll redefine these variables as unsigned. Such as, int i -> uint16_t q_idx int j -> uint16_t r_idx k -> r_idx Thanks, Jianfeng >=20 > --yliu