DPDK patches and discussions
 help / color / mirror / Atom feed
From: "Tan, Jianfeng" <jianfeng.tan@intel.com>
To: Yuanhan Liu <yuanhan.liu@linux.intel.com>
Cc: "dev@dpdk.org" <dev@dpdk.org>, "Xie, Huawei" <huawei.xie@intel.com>
Subject: Re: [dpdk-dev] [PATCH] virito: fix reuse index in nested loop
Date: Mon, 13 Jun 2016 09:11:57 +0000	[thread overview]
Message-ID: <ED26CBA2FAD1BF48A8719AEF02201E3610601C6F@SHSMSX103.ccr.corp.intel.com> (raw)
In-Reply-To: <20160613085749.GM10038@yliu-dev.sh.intel.com>



> -----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
> 
> 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")
> 
> Good catch!
> 
> > Signed-off-by: Jianfeng Tan <jianfeng.tan@intel.com>
> > ---
> >  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/virtio_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;
> 
> However, I don't quite like using "i, j, k" stuff. So, how about
> renaming "j" to "ring_idx"?
> 
> >  	PMD_INIT_FUNC_TRACE();
> >
> > @@ -352,15 +352,18 @@ virtio_dev_rxtx_start(struct rte_eth_dev *dev)
> >  		error = ENOSPC;
> >
> >  #ifdef RTE_MACHINE_CPUFLAG_SSSE3
> > -		if (use_simple_rxtx)
> > -			for (i = 0; i < vq->vq_nentries; i++) {
> > -				vq->vq_ring.avail->ring[i] = i;
> > -				vq->vq_ring.desc[i].flags =
> VRING_DESC_F_WRITE;
> > +		if (use_simple_rxtx) {
> > +			uint16_t k;
> 
> 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 violation 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

> 
> 	--yliu

  reply	other threads:[~2016-06-13  9:12 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-06-12 10:05 Jianfeng Tan
2016-06-13  8:57 ` Yuanhan Liu
2016-06-13  9:11   ` Tan, Jianfeng [this message]
2016-06-13  9:31     ` Yuanhan Liu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ED26CBA2FAD1BF48A8719AEF02201E3610601C6F@SHSMSX103.ccr.corp.intel.com \
    --to=jianfeng.tan@intel.com \
    --cc=dev@dpdk.org \
    --cc=huawei.xie@intel.com \
    --cc=yuanhan.liu@linux.intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).