Netdev List
 help / color / mirror / Atom feed
* Performance problem in network namespaces
@ 2010-05-03  9:25 Martín Ferrari
  2010-05-04  9:48 ` Benny Amorsen
  0 siblings, 1 reply; 3+ messages in thread
From: Martín Ferrari @ 2010-05-03  9:25 UTC (permalink / raw)
  To: netdev; +Cc: Mathieu Lacage

Hi,

When running some benchmarks to test the feasibility of using
namespaces for emulating networks, I have found a big drop in
performance when one of the namespaces is performing routing of
packets.

After some search, we found that  in ip_forward() the skb is being
copied. It seems that (ICMP and UDP, does not happen with TCP) packets
start with a small headroom (16 bytes in our observation) but skb_cow
always allocates at least NET_SKB_PAD (32 in x86) bytes of headroom,
thus triggering this unnecessary memcpy.

We made two crude attempts at fixing this, which are surely incorrect,
but hopefully somebody here could come up with a correct solution.

Our attempts are: 1. remove the lower bound in headroom size at
skb_cow, and 2. set needed_headroom in veth.c to NET_SKB_PAD; patches
included below.

Thanks.


diff -Naurp linux-2.6.34-rc5/include/linux/skbuff.h
../linux-2.6.34-rc5/include/linux/skbuff.h
--- linux-2.6.34-rc5/include/linux/skbuff.h	2010-04-20 01:29:56.000000000 +0200
+++ ../linux-2.6.34-rc5/include/linux/skbuff.h	2010-05-03
11:17:13.000000000 +0200
@@ -1526,8 +1526,6 @@ static inline int __skb_cow(struct sk_bu
 {
 	int delta = 0;

-	if (headroom < NET_SKB_PAD)
-		headroom = NET_SKB_PAD;
 	if (headroom > skb_headroom(skb))
 		delta = headroom - skb_headroom(skb);


diff -Naurp linux-2.6.34-rc5/drivers/net/veth.c
../linux-2.6.34-rc5/drivers/net/veth.c
--- linux-2.6.34-rc5/drivers/net/veth.c	2010-04-20 01:29:56.000000000 +0200
+++ ../linux-2.6.34-rc5/drivers/net/veth.c	2010-04-30 11:29:39.000000000 +0200
@@ -303,6 +303,8 @@ static void veth_setup(struct net_device
 	dev->ethtool_ops = &veth_ethtool_ops;
 	dev->features |= NETIF_F_LLTX;
 	dev->destructor = veth_dev_free;
+	/* Try to avoid skb copies when passing packets around */
+	dev->needed_headroom = NET_SKB_PAD;
 }

 /*


-- 
Martín Ferrari

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2010-05-05  7:37 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-05-03  9:25 Performance problem in network namespaces Martín Ferrari
2010-05-04  9:48 ` Benny Amorsen
2010-05-05  7:37   ` Martín Ferrari

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox