From: Jesper Dangaard Brouer <brouer@redhat.com>
To: Alexei Starovoitov <ast@plumgrid.com>
Cc: "David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
John Fastabend <john.r.fastabend@intel.com>,
netdev@vger.kernel.org, brouer@redhat.com
Subject: Re: [RFC PATCH net-next] net: pktgen: packet bursting via skb->xmit_more
Date: Fri, 26 Sep 2014 10:05:42 +0200 [thread overview]
Message-ID: <20140926100542.7e543c4e@redhat.com> (raw)
In-Reply-To: <1411692382-8898-1-git-send-email-ast@plumgrid.com>
On Thu, 25 Sep 2014 17:46:22 -0700
Alexei Starovoitov <ast@plumgrid.com> wrote:
> This patch demonstrates the effect of delaying update of HW tailptr.
> (based on earlier patch by Jesper)
>
> burst=1 is a default. It sends one packet with xmit_more=false
> burst=2 sends one packet with xmit_more=true and
> 2nd copy of the same packet with xmit_more=false
> burst=3 sends two copies of the same packet with xmit_more=true and
> 3rd copy with xmit_more=false
>
> Performance with ixgbe:
>
> usec 30:
> burst=1 tx:9.2 Mpps
> burst=2 tx:13.6 Mpps
> burst=3 tx:14.5 Mpps full 10G line rate
Perfect, full wirespeed! :-)
> usec 1 (default):
> burst=1,4,100 tx:3.9 Mpps
Here you are being limited by the TX ring queue cleanup, being too slow.
As desc here:
http://netoptimizer.blogspot.dk/2014/06/pktgen-for-network-overload-testing.html
> usec 0:
> burst=1 tx:4.9 Mpps
> burst=2 tx:6.6 Mpps
> burst=3 tx:7.9 Mpps
> burst=4 tx:8.7 Mpps
> burst=8 tx:10.3 Mpps
> burst=128 tx:12.4 Mpps
>
> Cc: Jesper Dangaard Brouer <brouer@redhat.com>
> Signed-off-by: Alexei Starovoitov <ast@plumgrid.com>
> ---
Acked-by: Jesper Dangaard Brouer <brouer@redhat.com>
> tx queue size, irq affinity left in default.
> pause frames are off.
>
> Nice to finally see line rate generated by one cpu
Yes,
> Comparing to Jesper patch this one amortizes the cost
> of spin_lock and atomic_inc by doing HARD_TX_LOCK and
> atomic_add(N) once across N packets.
Nice additional optimizations :-)
> net/core/pktgen.c | 33 ++++++++++++++++++++++++++++++---
> 1 file changed, 30 insertions(+), 3 deletions(-)
>
> diff --git a/net/core/pktgen.c b/net/core/pktgen.c
> index 5c728aa..47557ba 100644
> --- a/net/core/pktgen.c
> +++ b/net/core/pktgen.c
> @@ -387,6 +387,7 @@ struct pktgen_dev {
> u16 queue_map_min;
> u16 queue_map_max;
> __u32 skb_priority; /* skb priority field */
> + int burst; /* number of duplicated packets to burst */
> int node; /* Memory node */
>
> #ifdef CONFIG_XFRM
[...]
> @@ -3299,7 +3313,8 @@ static void pktgen_xmit(struct pktgen_dev *pkt_dev)
> {
> struct net_device *odev = pkt_dev->odev;
> struct netdev_queue *txq;
> - int ret;
> + int burst_cnt, ret;
> + bool more;
>
> /* If device is offline, then don't send */
> if (unlikely(!netif_running(odev) || !netif_carrier_ok(odev))) {
> @@ -3347,8 +3362,14 @@ static void pktgen_xmit(struct pktgen_dev *pkt_dev)
> pkt_dev->last_ok = 0;
> goto unlock;
> }
> - atomic_inc(&(pkt_dev->skb->users));
> - ret = netdev_start_xmit(pkt_dev->skb, odev, txq, false);
> + atomic_add(pkt_dev->burst, &pkt_dev->skb->users);
> +
> + burst_cnt = 0;
> +
> +xmit_more:
> + more = ++burst_cnt < pkt_dev->burst;
> +
> + ret = netdev_start_xmit(pkt_dev->skb, odev, txq, more);
>
> switch (ret) {
> case NETDEV_TX_OK:
> @@ -3356,6 +3377,8 @@ static void pktgen_xmit(struct pktgen_dev *pkt_dev)
> pkt_dev->sofar++;
> pkt_dev->seq_num++;
> pkt_dev->tx_bytes += pkt_dev->last_pkt_size;
> + if (more)
> + goto xmit_more;
I think this will break my VLAN hack mode, that allows me to shoot
pktgen after the qdisc layer, but I'm okay with that, as I can just
avoid using this new burst mode and then it will still work for me.
> break;
> case NET_XMIT_DROP:
> case NET_XMIT_CN:
> @@ -3374,6 +3397,9 @@ static void pktgen_xmit(struct pktgen_dev *pkt_dev)
> atomic_dec(&(pkt_dev->skb->users));
> pkt_dev->last_ok = 0;
> }
> +
> + if (unlikely(pkt_dev->burst - burst_cnt > 0))
> + atomic_sub(pkt_dev->burst - burst_cnt, &pkt_dev->skb->users);
> unlock:
> HARD_TX_UNLOCK(odev, txq);
>
--
Best regards,
Jesper Dangaard Brouer
MSc.CS, Sr. Network Kernel Developer at Red Hat
Author of http://www.iptv-analyzer.org
LinkedIn: http://www.linkedin.com/in/brouer
next prev parent reply other threads:[~2014-09-26 8:05 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-09-26 0:46 [RFC PATCH net-next] net: pktgen: packet bursting via skb->xmit_more Alexei Starovoitov
2014-09-26 1:20 ` Eric Dumazet
2014-09-26 7:42 ` Eric Dumazet
2014-09-26 15:44 ` Eric Dumazet
2014-09-26 15:59 ` Alexei Starovoitov
2014-09-26 16:06 ` Eric Dumazet
2014-09-27 20:43 ` Eric Dumazet
2014-09-27 20:55 ` Or Gerlitz
2014-09-27 21:30 ` Eric Dumazet
2014-09-27 22:56 ` [PATCH net-next] mlx4: optimize xmit path Eric Dumazet
2014-09-27 23:44 ` Hannes Frederic Sowa
2014-09-28 0:05 ` Eric Dumazet
2014-09-28 0:22 ` Hannes Frederic Sowa
2014-09-28 12:42 ` Eric Dumazet
2014-09-28 14:35 ` Or Gerlitz
2014-09-28 16:03 ` Eric Dumazet
2014-09-29 4:19 ` [PATCH v2 " Eric Dumazet
2014-09-30 12:01 ` Amir Vadai
2014-09-30 12:11 ` Eric Dumazet
2014-10-02 4:35 ` Eric Dumazet
2014-10-02 8:03 ` Amir Vadai
2014-10-02 8:29 ` Jesper Dangaard Brouer
2014-10-02 8:57 ` Amir Vadai
2014-10-02 11:45 ` Eric Dumazet
2014-10-02 11:56 ` Amir Vadai
2014-10-02 12:07 ` Eric Dumazet
2014-10-02 12:45 ` Amir Vadai
2014-09-26 8:05 ` Jesper Dangaard Brouer [this message]
2014-09-27 20:59 ` [RFC PATCH net-next] net: pktgen: packet bursting via skb->xmit_more Or Gerlitz
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=20140926100542.7e543c4e@redhat.com \
--to=brouer@redhat.com \
--cc=ast@plumgrid.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=john.r.fastabend@intel.com \
--cc=netdev@vger.kernel.org \
/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).