All of lore.kernel.org
 help / color / mirror / Atom feed
From: Herbert Xu <herbert@gondor.apana.org.au>
To: "David S. Miller" <davem@davemloft.net>, netdev@vger.kernel.org
Subject: [PATCH 8/14] gro: Optimise length comparison in skb_gro_header
Date: Wed, 27 May 2009 14:50:27 +1000	[thread overview]
Message-ID: <E1M9B5v-0001SU-M7@gondolin.me.apana.org.au> (raw)
In-Reply-To: 20090527044539.GA32372@gondor.apana.org.au

gro: Optimise length comparison in skb_gro_header

By caching frag0_len, we can avoid checking both frag0 and the
length separately in skb_gro_header.  This helps as skb_gro_header
is called four times per packet which amounts to a few million
times at 10Gb/s.

Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
---

 include/linux/netdevice.h |    7 +++++--
 net/core/dev.c            |    5 ++++-
 2 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index 38678bc..966c413 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -1011,6 +1011,9 @@ struct napi_gro_cb {
 	/* Virtual address of skb_shinfo(skb)->frags[0].page + offset. */
 	void *frag0;
 
+	/* Length of frag0. */
+	unsigned int frag0_len;
+
 	/* This indicates where we are processing relative to skb->data. */
 	int data_offset;
 
@@ -1134,9 +1137,9 @@ static inline void *skb_gro_header(struct sk_buff *skb, unsigned int hlen)
 	unsigned int offset = skb_gro_offset(skb);
 
 	hlen += offset;
-	if (!NAPI_GRO_CB(skb)->frag0 ||
-	    unlikely(skb_shinfo(skb)->frags[0].size < hlen)) {
+	if (NAPI_GRO_CB(skb)->frag0_len < hlen) {
 		NAPI_GRO_CB(skb)->frag0 = NULL;
+		NAPI_GRO_CB(skb)->frag0_len = 0;
 		return pskb_may_pull(skb, hlen) ? skb->data + offset : NULL;
 	}
 
diff --git a/net/core/dev.c b/net/core/dev.c
index 07ad237..e634c8a 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -2506,12 +2506,15 @@ void skb_gro_reset_offset(struct sk_buff *skb)
 {
 	NAPI_GRO_CB(skb)->data_offset = 0;
 	NAPI_GRO_CB(skb)->frag0 = NULL;
+	NAPI_GRO_CB(skb)->frag0_len = 0;
 
 	if (skb->mac_header == skb->tail &&
-	    !PageHighMem(skb_shinfo(skb)->frags[0].page))
+	    !PageHighMem(skb_shinfo(skb)->frags[0].page)) {
 		NAPI_GRO_CB(skb)->frag0 =
 			page_address(skb_shinfo(skb)->frags[0].page) +
 			skb_shinfo(skb)->frags[0].page_offset;
+		NAPI_GRO_CB(skb)->frag0_len = skb_shinfo(skb)->frags[0].size;
+	}
 }
 EXPORT_SYMBOL(skb_gro_reset_offset);
 

  parent reply	other threads:[~2009-05-27  4:50 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-05-27  4:45 [0/14] GRO: Lots of microoptimisations Herbert Xu
2009-05-27  4:50 ` [PATCH 1/14] gro: Open-code frags copy in skb_gro_receive Herbert Xu
2009-05-27  4:50 ` [PATCH 2/14] gro: Inline skb_gro_header and cache frag0 virtual address Herbert Xu
2009-05-27  4:50 ` [PATCH 3/14] gro: Localise offset/headlen in skb_gro_offset Herbert Xu
2009-05-27  4:50 ` [PATCH 4/14] gro: Only use skb_gro_header for completely non-linear packets Herbert Xu
2009-05-27  4:50 ` [PATCH 5/14] tcp: Optimise GRO port comparisons Herbert Xu
2009-05-27  4:50 ` [PATCH 6/14] tcp: Remove unnecessary window comparisons for GRO Herbert Xu
2009-05-27  4:50 ` [PATCH 7/14] tcp: Optimise len/mss comparison Herbert Xu
2009-05-27  4:50 ` Herbert Xu [this message]
2009-05-27  4:50 ` [PATCH 9/14] gro: Avoid unnecessary comparison after skb_gro_header Herbert Xu
2009-05-27  4:50 ` [PATCH 10/14] ipv4: Use 32-bit loads for ID and length in GRO Herbert Xu
2009-05-27 18:00   ` Andi Kleen
2009-05-27 21:26     ` Herbert Xu
2009-05-27  4:50 ` [PATCH 11/14] gro: Open-code final pskb_may_pull Herbert Xu
2009-05-27  4:50 ` [PATCH 12/14] gro: Nasty optimisations for page frags in skb_gro_receive Herbert Xu
2009-05-27  4:50 ` [PATCH 13/14] gro: Store shinfo in local variable " Herbert Xu
2009-05-27  4:50 ` [PATCH 14/14] tcp: Do not check flush when comparing options for GRO Herbert Xu
2009-05-27 10:42 ` [0/14] GRO: Lots of microoptimisations David Miller
2009-05-27 17:52 ` Benjamin LaHaise
2009-05-27 23:08   ` Herbert Xu
2009-05-28 15:21     ` Benjamin LaHaise
2009-05-29  9:28       ` Herbert Xu
2009-05-29  9:29         ` Herbert Xu
2009-05-29 16:23           ` Benjamin LaHaise
2009-06-10  5:44             ` Herbert Xu
2009-06-12 16:09               ` Benjamin LaHaise
2009-06-12 23:48                 ` David Miller
2009-06-16 16:35                   ` Benjamin LaHaise
2009-06-16 16:38                     ` Herbert Xu
2009-06-17  8:07                       ` Herbert Xu
2009-06-17  8:08                         ` Herbert Xu
2009-06-17 20:14                           ` Rick Jones

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=E1M9B5v-0001SU-M7@gondolin.me.apana.org.au \
    --to=herbert@gondor.apana.org.au \
    --cc=davem@davemloft.net \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.