All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alexander Duyck <alexander.h.duyck@intel.com>
To: netdev@vger.kernel.org
Cc: davem@davemloft.net, eric.dumazet@gmail.com, jeffrey.t.kirsher@intel.com
Subject: [PATCH 1/3] skb: Drop bad code from pskb_expand_head
Date: Fri, 04 May 2012 17:26:46 -0700	[thread overview]
Message-ID: <20120505002645.21292.38368.stgit@gitlad.jf.intel.com> (raw)
In-Reply-To: <20120505001059.21292.31647.stgit@gitlad.jf.intel.com>

The fast-path for pskb_expand_head contains a check where the size plus the
unaligned size of skb_shared_info is compared against the size of the data
buffer.  This code path has two issues.  First is the fact that after the
recent changes by Eric Dumazet to __alloc_skb and build_skb the shared info
is always placed in the optimal spot for a buffer size making this check
unnecessary.  The second issue is the fact that the check doesn't take into
account the aligned size of shared info.  As a result the code burns cycles
doing a memcpy with nothing actually being shifted.

Signed-off-by: Alexander Duyck <alexander.h.duyck@intel.com>
---

 net/core/skbuff.c |   12 ------------
 1 files changed, 0 insertions(+), 12 deletions(-)

diff --git a/net/core/skbuff.c b/net/core/skbuff.c
index c199aa4..4d085d4 100644
--- a/net/core/skbuff.c
+++ b/net/core/skbuff.c
@@ -951,17 +951,6 @@ int pskb_expand_head(struct sk_buff *skb, int nhead, int ntail,
 		fastpath = atomic_read(&skb_shinfo(skb)->dataref) == delta;
 	}
 
-	if (fastpath && !skb->head_frag &&
-	    size + sizeof(struct skb_shared_info) <= ksize(skb->head)) {
-		memmove(skb->head + size, skb_shinfo(skb),
-			offsetof(struct skb_shared_info,
-				 frags[skb_shinfo(skb)->nr_frags]));
-		memmove(skb->head + nhead, skb->head,
-			skb_tail_pointer(skb) - skb->head);
-		off = nhead;
-		goto adjust_others;
-	}
-
 	data = kmalloc(size + SKB_DATA_ALIGN(sizeof(struct skb_shared_info)),
 		       gfp_mask);
 	if (!data)
@@ -997,7 +986,6 @@ int pskb_expand_head(struct sk_buff *skb, int nhead, int ntail,
 
 	skb->head     = data;
 	skb->head_frag = 0;
-adjust_others:
 	skb->data    += off;
 #ifdef NET_SKBUFF_DATA_USES_OFFSET
 	skb->end      = size;

  reply	other threads:[~2012-05-05  0:26 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-05-05  0:26 [PATCH 0/3] First pass of cleanups for pskb_expand_head Alexander Duyck
2012-05-05  0:26 ` Alexander Duyck [this message]
2012-05-05  5:35   ` [PATCH 1/3] skb: Drop bad code from pskb_expand_head Eric Dumazet
2012-05-06 17:13     ` David Miller
2012-05-05  0:26 ` [PATCH 2/3] skb: Drop "fastpath" variable for skb_cloned check in pskb_expand_head Alexander Duyck
2012-05-05  5:37   ` Eric Dumazet
2012-05-06 17:13     ` David Miller
2012-05-05  0:26 ` [PATCH 3/3] skb: Add inline helper for getting the skb end offset from head Alexander Duyck
2012-05-05  5:39   ` Eric Dumazet
2012-05-06 17:13     ` David Miller
2012-05-05  5:44 ` [PATCH 0/3] First pass of cleanups for pskb_expand_head Eric Dumazet
2012-05-05  6:51   ` Alexander Duyck

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=20120505002645.21292.38368.stgit@gitlad.jf.intel.com \
    --to=alexander.h.duyck@intel.com \
    --cc=davem@davemloft.net \
    --cc=eric.dumazet@gmail.com \
    --cc=jeffrey.t.kirsher@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 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.