Skip to contentSkip to conversation

pktgen: adding prefetchw() call

PATCH In review Junchang Wang 3 participants 5 messages Dec 6, 2010 – Dec 10, 2010

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 pktgen: adding prefetchw() call

We know for sure pktgen is going to write skb->data right after *_alloc_skb, causing unnecessary cache misses.

Idea is to add a prefetchw() call to prefetch the first cache line indicated by skb->data. On systems with Adjacent Cache Line Prefetch, it's probably two cache lines are prefetched.

With this prefetch, pktgen on Intel SR1625 server with two E5530 quad-core processors and a single ixgbe-based NIC went from 8.63Mpps to 9.03Mpps, with 4.6% improvement.

---
 net/core/pktgen.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
net/core/pktgen.c +2 -1
index 2953b2a..18fe20d 100644
@@ -2660,6 +2660,7 @@ static struct sk_buff *fill_packet_ipv4(struct net_device *odev,
 		sprintf(pkt_dev->result, "No memory");
 		return NULL;
 	}
+	prefetchw(skb->data);
 
 	skb_reserve(skb, datalen);
 
@@ -3007,6 +3008,7 @@ static struct sk_buff *fill_packet_ipv6(struct net_device *odev,
 		sprintf(pkt_dev->result, "No memory");
 		return NULL;
 	}
+	prefetchw(skb->data);
 
 	skb_reserve(skb, 16);
--

--Junchang

Acked-by on v1 1/1
#1 lore raw
Quoted 11 lines · Junchang Wang

We know for sure pktgen is going to write skb->data right after *_alloc_skb, causing unnecessary cache misses.

Idea is to add a prefetchw() call to prefetch the first cache line indicated by skb->data. On systems with Adjacent Cache Line Prefetch, it's probably two cache lines are prefetched.
With this prefetch, pktgen on Intel SR1625 server with two E5530 quad-core processors and a single ixgbe-based NIC went from 8.63Mpps to 9.03Mpps, with 4.6% improvement.

Quoted 2 lines

---

maintainer
#2 lore raw
In reply to Junchang Wang

From: Junchang Wang <[email protected]>
Date: Mon, 6 Dec 2010 14:33:52 +0800

Quoted 8 lines

We know for sure pktgen is going to write skb->data right after *_alloc_skb, causing unnecessary cache misses.

Idea is to add a prefetchw() call to prefetch the first cache line indicated by skb->data. On systems with Adjacent Cache Line Prefetch, it's probably two cache lines are prefetched.

Quoted 6 lines

With this prefetch, pktgen on Intel SR1625 server with two E5530 quad-core processors and a single ixgbe-based NIC went from 8.63Mpps to 9.03Mpps, with 4.6% improvement.

Your patch was corrupted by your email client, please fix this up and resubmit.

#3 lore raw

PATCH 1/1 pktgen: adding prefetchw() call

Quoted 2 lines · David Miller

Your patch was corrupted by your email client, please fix this up and resubmit.

Sorry. I'll avoid this next time. Here's a new version, and I had tested it. Thanks David and Eric.

We know for sure pktgen is going to write skb->data right after *_alloc_skb, causing unnecessary cache misses.

Idea is to add a prefetchw() call to prefetch the first cache line indicated by skb->data. On systems with Adjacent Cache Line Prefetch, it's probably two cache lines are prefetched.

With this patch, pktgen on Intel SR1625 server with two E5530 quad-core processors and a single ixgbe-based NIC went from 8.63Mpps to 9.03Mpps, with 4.6% improvement.

---
 net/core/pktgen.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
net/core/pktgen.c +2 -0
index 2953b2a..18fe20d 100644
@@ -2660,6 +2660,7 @@ static struct sk_buff *fill_packet_ipv4(struct net_device *odev,
 		sprintf(pkt_dev->result, "No memory");
 		return NULL;
 	}
+	prefetchw(skb->data);
 
 	skb_reserve(skb, datalen);
 
@@ -3007,6 +3008,7 @@ static struct sk_buff *fill_packet_ipv6(struct net_device *odev,
 		sprintf(pkt_dev->result, "No memory");
 		return NULL;
 	}
+	prefetchw(skb->data);
 
 	skb_reserve(skb, 16);
 

--

maintainer Applied
#4 lore raw

From: Junchang Wang <[email protected]>
Date: Thu, 9 Dec 2010 10:55:16 +0800

Quoted 7 lines

We know for sure pktgen is going to write skb->data right after *_alloc_skb, causing unnecessary cache misses.

Idea is to add a prefetchw() call to prefetch the first cache line indicated by skb->data. On systems with Adjacent Cache Line Prefetch, it's probably two cache lines are prefetched.

Quoted 6 lines

With this patch, pktgen on Intel SR1625 server with two E5530 quad-core processors and a single ixgbe-based NIC went from 8.63Mpps to 9.03Mpps, with 4.6% improvement.

Applied, thanks.