netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jesper Dangaard Brouer <brouer@redhat.com>
To: Tariq Toukan <tariqt@mellanox.com>
Cc: "David S. Miller" <davem@davemloft.net>,
	netdev@vger.kernel.org, Eran Ben Elisha <eranbe@mellanox.com>,
	brouer@redhat.com
Subject: Re: [PATCH net-next 2/2] pktgen: Specify the index of first thread
Date: Wed, 14 Jun 2017 13:29:51 +0200	[thread overview]
Message-ID: <20170614132951.2c86d1cf@redhat.com> (raw)
In-Reply-To: <61690488-f20e-6768-e007-bd8b89cc0bf7@mellanox.com>

On Wed, 14 Jun 2017 14:10:37 +0300
Tariq Toukan <tariqt@mellanox.com> wrote:

> >> +export L_THREAD="$THREADS + $F_THREAD - 1"
> >> +  
> > 
> > This is sort of bad-shell coding.  This will first get expanded at the
> > usage point.  The way you use it, it will work, because of the for loop
> > uses an expansion like "((xxx))".
> > 
> > If you echo the $L_THREAD variable you will see: "1 + 0 - 1"
> > 
> > IMHO the right thing is to use:
> > 
> >    export L_THREAD=$(( THREADS + F_THREAD - 1 ))
> > 
> > (I tested this also works for dash + ksh + zsh)
> >   
> Thanks, I'll use the suggested command.
> >   
> >> diff --git a/samples/pktgen/pktgen_bench_xmit_mode_netif_receive.sh b/samples/pktgen/pktgen_bench_xmit_mode_netif_receive.sh
> >> index d2694a12de61..e5bfe759a0fb 100755
> >> --- a/samples/pktgen/pktgen_bench_xmit_mode_netif_receive.sh
> >> +++ b/samples/pktgen/pktgen_bench_xmit_mode_netif_receive.sh
> >> @@ -48,7 +48,7 @@ DELAY="0"        # Zero means max speed
> >>   pg_ctrl "reset"
> >>   
> >>   # Threads are specified with parameter -t value in $THREADS
> >> -for ((thread = 0; thread < $THREADS; thread++)); do
> >> +for ((thread = $F_THREAD; thread <= $L_THREAD; thread++)); do
> >>       # The device name is extended with @name, using thread number to
> >>       # make then unique, but any name will do.
> >>       dev=${DEV}@${thread}  
> > 
> > The expansion/use of $L_THREAD only works because "for-loop" expanded
> > it by using ""(("" arithmetic evaluation.
> >   
> After changing the one above, this one should still be OK, right?

Yes, this part is still correct.

-- 
Best regards,
  Jesper Dangaard Brouer
  MSc.CS, Principal Kernel Engineer at Red Hat
  LinkedIn: http://www.linkedin.com/in/brouer

      reply	other threads:[~2017-06-14 11:30 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-13 15:04 [PATCH net-next 0/2] pktgen new parameters Tariq Toukan
2017-06-13 15:04 ` [PATCH net-next 1/2] pktgen: Specify num packets per thread Tariq Toukan
2017-06-14  7:26   ` Jesper Dangaard Brouer
2017-06-13 15:04 ` [PATCH net-next 2/2] pktgen: Specify the index of first thread Tariq Toukan
2017-06-14  7:09   ` Jesper Dangaard Brouer
2017-06-14 11:10     ` Tariq Toukan
2017-06-14 11:29       ` Jesper Dangaard Brouer [this message]

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=20170614132951.2c86d1cf@redhat.com \
    --to=brouer@redhat.com \
    --cc=davem@davemloft.net \
    --cc=eranbe@mellanox.com \
    --cc=netdev@vger.kernel.org \
    --cc=tariqt@mellanox.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).