[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1500276760.5566.5.camel@edumazet-glaptop3.roam.corp.google.com>
Date: Mon, 17 Jul 2017 00:32:40 -0700
From: Eric Dumazet <eric.dumazet@...il.com>
To: Lin Zhang <xiaolou4617@...il.com>
Cc: davem@...emloft.net, netdev@...r.kernel.org
Subject: Re: [PATCH net-next resubmit] skbuff: optimize the pull_pages code
in __pskb_pull_tail()
On Mon, 2017-07-17 at 10:22 +0800, Lin Zhang wrote:
> In the pull_pages code block, if the first frag size > eat,
> we can end the loop in advance to avoid extra copy.
>
> Signed-off-by: Lin Zhang <xiaolou4617@...il.com>
> ---
> net/core/skbuff.c | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/net/core/skbuff.c b/net/core/skbuff.c
> index f990eb8..c00a1df 100644
> --- a/net/core/skbuff.c
> +++ b/net/core/skbuff.c
> @@ -1720,6 +1720,10 @@ void *__pskb_pull_tail(struct sk_buff *skb, int delta)
> skb_shinfo(skb)->frags[k].page_offset += eat;
> skb_frag_size_sub(&skb_shinfo(skb)->frags[k], eat);
> eat = 0;
> + if (!i) {
> + k = skb_shinfo(skb)->nr_frags;
> + break;
> + }
> }
> k++;
> }
-CC lkml (no need to spam lkml for netdev patches )
Why even reading skb_shinfo(skb)->nr_frags to write it again ?
I would use something like :
diff --git a/net/core/skbuff.c b/net/core/skbuff.c
index 8b11341ed69ad97d34dd3e9b73c8c44ef7c452ff..a562b0e61afa3faf7abdd7f9209ae9096310fb7d 100644
--- a/net/core/skbuff.c
+++ b/net/core/skbuff.c
@@ -1719,13 +1719,15 @@ void *__pskb_pull_tail(struct sk_buff *skb, int delta)
if (eat) {
skb_shinfo(skb)->frags[k].page_offset += eat;
skb_frag_size_sub(&skb_shinfo(skb)->frags[k], eat);
+ if (!i)
+ goto end;
eat = 0;
}
k++;
}
}
skb_shinfo(skb)->nr_frags = k;
-
+end:
skb->tail += delta;
skb->data_len -= delta;
Powered by blists - more mailing lists