netdev: pktgen xmit packet through vlan interface
Subsystems (2)
PATCH 1/1 netdev: pktgen xmit packet through vlan interface
As http://www.spinics.net/lists/netdev/msg165015.html
pktgen generates shared packet through vlan interface will cause oops because of duplicate entering tc queue.
Try to solve this problem by means of packet clone instead of sharing.
--- net/core/pktgen.c | 20 +++++++++++++++++--- 1 files changed, 17 insertions(+), 3 deletions(-)
net/core/pktgen.c +17 -3
@@ -3297,6 +3297,7 @@ static void pktgen_xmit(struct pktgen_dev *pkt_dev)netdev_tx_t (*xmit)(struct sk_buff *,struct net_device *) = odev->netdev_ops->ndo_start_xmit;struct netdev_queue *txq; +struct sk_buff *nskb =NULL ;u16 queue_map;int ret;
@@ -3347,8 +3348,18 @@ static void pktgen_xmit(struct pktgen_dev *pkt_dev) pkt_dev->last_ok =0 ; goto unlock; } -atomic_inc (&(pkt_dev->skb->users)); - ret = (*xmit)(pkt_dev->skb, odev); + +if (pkt_dev->clone_skb &&is_vlan_dev (odev)) { + nskb =skb_clone (pkt_dev->skb,GFP_ATOMIC ); + ret = -ENOMEM ; +if (nskb) + ret = (*xmit)(nskb, odev); +else + nskb =ERR_PTR (ret); + }else { +atomic_inc (&(pkt_dev->skb->users)); + ret = (*xmit)(pkt_dev->skb, odev); + }switch (ret) {case NETDEV_TX_OK :
@@ -3372,7 +3383,10 @@ static void pktgen_xmit(struct pktgen_dev *pkt_dev)case NETDEV_TX_LOCKED :case NETDEV_TX_BUSY :/* Retry it next time */ -atomic_dec (&(pkt_dev->skb->users)); +if (nskb && !IS_ERR (nskb)) +kfree_skb (nskb); +else +atomic_dec (&(pkt_dev->skb->users)); pkt_dev->last_ok =0 ; } unlock:
Signature · 1 line
1.7.1
Quoted 5 lines · On Fri, 2 May 2014 15:18:12 +0800 Zhouyi Zhou <[email protected]> wrote:
As http://www.spinics.net/lists/netdev/msg165015.html
pktgen generates shared packet through vlan interface will cause oops because of duplicate entering tc queue.Try to solve this problem by means of packet clone instead of sharing.
I really don't like adding this stuff to the fast path of pktgen.
Why would you use pktgen on a VLAN?
Why don't you use the "vlan_id" feature available in pktgen, and send in the lower real device?
Quoted 50 lines
Signed-off-by Zhouyi Zhou <[email protected]>--- net/core/pktgen.c | 20 +++++++++++++++++--- 1 files changed, 17 insertions(+), 3 deletions(-)net/core/pktgen.c +17
-3@@ -3297,6 +3297,7 @@ static void pktgen_xmit(struct pktgen_dev *pkt_dev)netdev_tx_t (*xmit)(struct sk_buff *,struct net_device *) = odev->netdev_ops->ndo_start_xmit;struct netdev_queue *txq; +struct sk_buff *nskb =NULL ;u16 queue_map;int ret;@@ -3347,8 +3348,18 @@ static void pktgen_xmit(struct pktgen_dev *pkt_dev) pkt_dev->last_ok =0 ; goto unlock; } -atomic_inc (&(pkt_dev->skb->users)); - ret = (*xmit)(pkt_dev->skb, odev); + +if (pkt_dev->clone_skb &&is_vlan_dev (odev)) { + nskb =skb_clone (pkt_dev->skb,GFP_ATOMIC ); + ret = -ENOMEM ; +if (nskb) + ret = (*xmit)(nskb, odev); +else + nskb =ERR_PTR (ret); + }else { +atomic_inc (&(pkt_dev->skb->users)); + ret = (*xmit)(pkt_dev->skb, odev); + }switch (ret) {case NETDEV_TX_OK :@@ -3372,7 +3383,10 @@ static void pktgen_xmit(struct pktgen_dev *pkt_dev)case NETDEV_TX_LOCKED :case NETDEV_TX_BUSY :/* Retry it next time */ -atomic_dec (&(pkt_dev->skb->users)); +if (nskb && !IS_ERR (nskb)) +kfree_skb (nskb); +else +atomic_dec (&(pkt_dev->skb->users)); pkt_dev->last_ok =0 ; } unlock:
Signature · 5 lines
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
Quoted 7 lines · Jesper Dangaard Brouer
Quoted 4 lines · On Fri, 2 May 2014 15:18:12 +0800 Zhouyi Zhou <[email protected]> wrote:
As http://www.spinics.net/lists/netdev/msg165015.html
pktgen generates shared packet through vlan interface will cause oops because of duplicate entering tc queue.
Quoted 5 lines
Quoted 1 line
Try to solve this problem by means of packet clone instead of sharing.
I really don't like adding this stuff to the fast path of pktgen.
Why would you use pktgen on a VLAN?
Its a good way to test qdiscs. When you run pktgen over the VLAN you exercise the lower devices qdisc.
Although I never submitted a patch like this because I figured it was a corner case and we would want to keep the hotpath clean.
Quoted 59 lines
Why don't you use the "
vlan_id" feature available in pktgen, and send in the lower real device?Quoted 50 lines
Signed-off-by Zhouyi Zhou <[email protected]>--- net/core/pktgen.c | 20 +++++++++++++++++--- 1 files changed, 17 insertions(+), 3 deletions(-)net/core/pktgen.c +17
-3@@ -3297,6 +3297,7 @@ static void pktgen_xmit(struct pktgen_dev *pkt_dev)netdev_tx_t (*xmit)(struct sk_buff *,struct net_device *) = odev->netdev_ops->ndo_start_xmit;struct netdev_queue *txq; +struct sk_buff *nskb =NULL ;u16 queue_map;int ret;@@ -3347,8 +3348,18 @@ static void pktgen_xmit(struct pktgen_dev *pkt_dev) pkt_dev->last_ok =0 ; goto unlock; } -atomic_inc (&(pkt_dev->skb->users)); - ret = (*xmit)(pkt_dev->skb, odev); + +if (pkt_dev->clone_skb &&is_vlan_dev (odev)) { + nskb =skb_clone (pkt_dev->skb,GFP_ATOMIC ); + ret = -ENOMEM ; +if (nskb) + ret = (*xmit)(nskb, odev); +else + nskb =ERR_PTR (ret); + }else { +atomic_inc (&(pkt_dev->skb->users)); + ret = (*xmit)(pkt_dev->skb, odev); + }switch (ret) {case NETDEV_TX_OK :@@ -3372,7 +3383,10 @@ static void pktgen_xmit(struct pktgen_dev *pkt_dev)case NETDEV_TX_LOCKED :case NETDEV_TX_BUSY :/* Retry it next time */ -atomic_dec (&(pkt_dev->skb->users)); +if (nskb && !IS_ERR (nskb)) +kfree_skb (nskb); +else +atomic_dec (&(pkt_dev->skb->users)); pkt_dev->last_ok =0 ; } unlock:
Thanks for reviewing
Quoted 9 lines · John Fastabend
Quoted 8 lines · Jesper Dangaard Brouer
Quoted 4 lines · On Fri, 2 May 2014 15:18:12 +0800 Zhouyi Zhou <[email protected]> wrote:
As http://www.spinics.net/lists/netdev/msg165015.html
pktgen generates shared packet through vlan interface will cause oops because of duplicate entering tc queue.
Quoted 8 lines
Quoted 8 lines
Quoted 1 line
Try to solve this problem by means of packet clone instead of sharing.
I really don't like adding this stuff to the fast path of pktgen.
Why would you use pktgen on a VLAN?
I use pktgen on a VLAN under a special circumstance.
Quoted 8 lines
Its a good way to test qdiscs. When you run pktgen over the VLAN you exercise the lower devices qdisc.
Although I never submitted a patch like this because I figured it was a corner case and we would want to keep the hotpath clean.
I think is_vlan_dev(odev) have great chances to be in a cache line that seldom got reset. Could we only judge is_vlan_dev(odev) in my first if statement?
Also I guess if (nskb && !IS_ERR(nskb)) happens in rarely reached cases when the interface is not overload.
Quoted 4 lines
Quoted 4 lines
Why don't you use the "
vlan_id" feature available in pktgen, and send in the lower real device?
Could we automatically convert the VLAN device's joining effort to real device + vlan_id settings in pkt_dev.
or could we issue a warning or a suggestion
when user try to add a VLAN device to the pktgen thread?
Quoted 60 lines
Quoted 59 lines
Quoted 55 lines
Signed-off-by Zhouyi Zhou <[email protected]>--- net/core/pktgen.c | 20 +++++++++++++++++--- 1 files changed, 17 insertions(+), 3 deletions(-)net/core/pktgen.c +13
-2@@ -3297,6 +3297,7 @@ static void pktgen_xmit(struct pktgen_dev *pkt_dev)netdev_tx_t (*xmit)(struct sk_buff *,struct net_device *) = odev->netdev_ops->ndo_start_xmit;struct netdev_queue *txq; +struct sk_buff *nskb =NULL ;u16 queue_map;int ret;@@ -3347,8 +3348,18 @@ static void pktgen_xmit(struct pktgen_dev *pkt_dev) pkt_dev->last_ok =0 ; goto unlock; } -atomic_inc (&(pkt_dev->skb->users)); - ret = (*xmit)(pkt_dev->skb, odev); + +if (pkt_dev->clone_skb &&is_vlan_dev (odev)) { + nskb =skb_clone (pkt_dev->skb,GFP_ATOMIC ); + ret = -ENOMEM ; +if (nskb) + ret = (*xmit)(nskb, odev); +else + nskb =ERR_PTR (ret); + }else { +atomic_inc (&(pkt_dev->skb->users)); + ret = (*xmit)(pkt_dev->skb, odev); + }switch (ret) {case
NETDEV_TX_OK:net/core/pktgen.c +4
-1@@ -3372,7 +3383,10 @@ static void pktgen_xmit(struct pktgen_dev *pkt_dev)case NETDEV_TX_LOCKED :case NETDEV_TX_BUSY :/* Retry it next time */ -atomic_dec (&(pkt_dev->skb->users)); +if (nskb && !IS_ERR (nskb)) +kfree_skb (nskb); +else +atomic_dec (&(pkt_dev->skb->users)); pkt_dev->last_ok =0 ; }unlock:
Quoted 8 lines · On Fri, 02 May 2014 07:00:00 -0700 John Fastabend <[email protected]>…
Quoted 7 lines · Jesper Dangaard Brouer
Quoted 4 lines · On Fri, 2 May 2014 15:18:12 +0800 Zhouyi Zhou <[email protected]> wrote:
As http://www.spinics.net/lists/netdev/msg165015.html
pktgen generates shared packet through vlan interface will cause oops because of duplicate entering tc queue.
Quoted 8 lines
Quoted 5 lines
Quoted 1 line
Try to solve this problem by means of packet clone instead of sharing.
I really don't like adding this stuff to the fast path of pktgen.
Why would you use pktgen on a VLAN?
Its a good way to test qdiscs. When you run pktgen over the VLAN you exercise the lower devices qdisc.
I do (personally) need a faster way/tool to exercise the qdisc path. I'm currently using trafgen, but it is not fast enough for my 10G testing.
Perhaps we could add a pktgen option, that explicitly enable transmitting on qdisc path. And when adding a VLAN device, auto enable that mode?
Quoted 2 lines
Although I never submitted a patch like this because I figured it was a corner case and we would want to keep the hotpath clean.
I'm worried about the overhead of skb_clone() on for every pktgen pkt_dev->clone_skb counter... does it "invalidate" using the pktgen CLONE_SKB counter (kind-of confusing pktgen uses "clone_skb" for its counter).
Quoted 2 lines
Quoted 2 lines
Why don't you use the "
vlan_id" feature available in pktgen, and send in the lower real device?
Guess, we can use it for testing/stressing the qdisc code path.
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Signed-off-by Zhouyi Zhou <[email protected]>--- net/core/pktgen.c | 20 +++++++++++++++++--- 1 files changed, 17 insertions(+), 3 deletions(-)net/core/pktgen.c +0
-0
[...]
Quoted 18 lines
Quoted 18 lines
Quoted 18 lines
net/core/pktgen.c +12
-2@@ -3347,8 +3348,18 @@ static void pktgen_xmit(struct pktgen_dev *pkt_dev) pkt_dev->last_ok =0 ; goto unlock; } -atomic_inc (&(pkt_dev->skb->users)); - ret = (*xmit)(pkt_dev->skb, odev); + +if (pkt_dev->clone_skb &&is_vlan_dev (odev)) { + nskb =skb_clone (pkt_dev->skb,GFP_ATOMIC ); + ret = -ENOMEM ; +if (nskb) + ret = (*xmit)(nskb, odev); +else + nskb =ERR_PTR (ret); + }else { +atomic_inc (&(pkt_dev->skb->users)); + ret = (*xmit)(pkt_dev->skb, odev); + }
Signature · 5 lines
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
Quoted 20 lines · Jesper Dangaard Brouer
Quoted 8 lines · On Fri, 02 May 2014 07:00:00 -0700 John Fastabend <[email protected]>…
Quoted 7 lines · Jesper Dangaard Brouer
Quoted 4 lines · On Fri, 2 May 2014 15:18:12 +0800 Zhouyi Zhou <[email protected]> wrote:
As http://www.spinics.net/lists/netdev/msg165015.html
pktgen generates shared packet through vlan interface will cause oops because of duplicate entering tc queue.Quoted 8 lines
Quoted 5 lines
Quoted 1 line
Try to solve this problem by means of packet clone instead of sharing.
I really don't like adding this stuff to the fast path of pktgen.
Why would you use pktgen on a VLAN?
Its a good way to test qdiscs. When you run pktgen over the VLAN you exercise the lower devices qdisc.
Quoted 7 lines
I do (personally) need a faster way/tool to exercise the qdisc path. I'm currently using trafgen, but it is not fast enough for my 10G testing.
Perhaps we could add a pktgen option, that explicitly enable transmitting on qdisc path. And when adding a VLAN device, auto enable that mode?
You could just force pktgen to not support multi-skb on vlan interfaces?
I thought we went through this a year or two ago and came up with something like a 'pktgen-challenged' network interface flag?
Thanks,
Ben
Signature · 2 lines
Ben Greear <[email protected]> Candela Technologies Inc http://www.candelatech.com
Quoted 4 lines
You could just force pktgen to not support multi-skb on vlan interfaces?
I thought we went through this a year or two ago and came up with something like a 'pktgen-challenged' network interface flag?
Ah yes, IFF_TX_SKB_SHARING does the job, very sorry for missing that,
as matter of fact, I have
tailed pktgen model for my personal use.
By the way, would skb_clone save the CPU cycles for memset(skb_put(skb, datalen), 0, datalen) thing ? especially for Jesper's qdisc test scenery.
Quoted 9 lines
Thanks,
Ben--
Ben Greear <[email protected]>
Candela Technologies Inc http://www.candelatech.com
Hello.
Quoted 15 lines · Zhouyi Zhou
As http://www.spinics.net/lists/netdev/msg165015.html
pktgen generates shared packet through vlan interface will cause oops because of duplicate entering tc queue.Try to solve this problem by means of packet clone instead of sharing.
Signed-off-by Zhouyi Zhou <[email protected]>--- net/core/pktgen.c | 20 +++++++++++++++++--- 1 files changed, 17 insertions(+), 3 deletions(-)net/core/pktgen.c +0
-0
[...]
net/core/pktgen.c static void pktgen_xmit(struct pktgen_dev *pkt_dev) · line 3356
Quoted 12 lines
net/core/pktgen.c +6
-2@@ -3347,8 +3348,18 @@ static void pktgen_xmit(struct pktgen_dev *pkt_dev) pkt_dev->last_ok =0 ; goto unlock; } -atomic_inc (&(pkt_dev->skb->users)); - ret = (*xmit)(pkt_dev->skb, odev); + +if (pkt_dev->clone_skb &&is_vlan_dev (odev)) { + nskb =skb_clone (pkt_dev->skb,GFP_ATOMIC ); + ret = -ENOMEM ; +if (nskb) + ret = (*xmit)(nskb, odev);
You can just do:
ret = xmit(nskb, odev);
net/core/pktgen.c static void pktgen_xmit(struct pktgen_dev *pkt_dev) · line 3361
Quoted 5 lines
net/core/pktgen.c +5
-0+else + nskb =ERR_PTR (ret); + }else { +atomic_inc (&(pkt_dev->skb->users)); + ret = (*xmit)(pkt_dev->skb, odev);
Same here.
WBR, Sergei
Thank Sergei for reviewing.
I think
Quoted 6 lines · Sergei Shtylyov
net/core/pktgen.c static void pktgen_xmit(struct pktgen_dev *pkt_dev) · line 3356
Quoted 6 lines
net/core/pktgen.c +6
-0+ +if (pkt_dev->clone_skb &&is_vlan_dev (odev)) { + nskb =skb_clone (pkt_dev->skb,GFP_ATOMIC ); + ret = -ENOMEM ; +if (nskb) + ret = (*xmit)(nskb, odev);
if (is_vlan_dev(odev) && pkt_dev->clone_skb) {
nskb = skb_clone(pkt_dev->skb, GFP_ATOMIC);
ret = -ENOMEM;
if (nskb)
ret = (*xmit)(nskb, odev);
}Quoted 1 line
and
case NETDEV_TX_LOCKED:
case NETDEV_TX_BUSY:
/* Retry it next time */
atomic_dec(&(pkt_dev->skb->users));
if (is_vlan_dev(odev) && pkt_dev->clone_skb && nskb)
kfree_skb(nskb);
else
atomic_dec(&(pkt_dev->skb->users));is better, because is_vlan_dev(odev) is probably in read most cache line.
Zhouyi
Quoted 5 lines · Fri, May 02, 2014 at 09:18:12AM CEST, [email protected] wrote:
As http://www.spinics.net/lists/netdev/msg165015.html
pktgen generates shared packet through vlan interface will cause oops because of duplicate entering tc queue.Try to solve this problem by means of packet clone instead of sharing.
Isn't this prohibited by:dev->priv_flags &= ~(IFF_TX_SKB_SHARING);
?
Quoted 58 lines
Signed-off-by Zhouyi Zhou <[email protected]>---
net/core/pktgen.c| 20 +++++++++++++++++---1 files changed, 17 insertions(+), 3 deletions(-)net/core/pktgen.c +17
-3@@ -3297,6 +3297,7 @@ static void pktgen_xmit(struct pktgen_dev *pkt_dev)netdev_tx_t (*xmit)(struct sk_buff *,struct net_device *) = odev->netdev_ops->ndo_start_xmit;struct netdev_queue *txq; +struct sk_buff *nskb =NULL ;u16 queue_map;int ret;@@ -3347,8 +3348,18 @@ static void pktgen_xmit(struct pktgen_dev *pkt_dev) pkt_dev->last_ok =0 ; goto unlock; } -atomic_inc (&(pkt_dev->skb->users)); - ret = (*xmit)(pkt_dev->skb, odev); + +if (pkt_dev->clone_skb &&is_vlan_dev (odev)) { + nskb =skb_clone (pkt_dev->skb,GFP_ATOMIC ); + ret = -ENOMEM ; +if (nskb) + ret = (*xmit)(nskb, odev); +else + nskb =ERR_PTR (ret); + }else { +atomic_inc (&(pkt_dev->skb->users)); + ret = (*xmit)(pkt_dev->skb, odev); + }switch (ret) {case NETDEV_TX_OK :@@ -3372,7 +3383,10 @@ static void pktgen_xmit(struct pktgen_dev *pkt_dev)case NETDEV_TX_LOCKED :case NETDEV_TX_BUSY :/* Retry it next time */ -atomic_dec (&(pkt_dev->skb->users)); +if (nskb && !IS_ERR (nskb)) +kfree_skb (nskb); +else +atomic_dec (&(pkt_dev->skb->users)); pkt_dev->last_ok =0 ; }unlock:
Signature · 6 lines
1.7.1 -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html