From: Eric Dumazet <eric.dumazet@gmail.com>
To: Junchang Wang <junchangwang@gmail.com>
Cc: netdev@vger.kernel.org
Subject: Re: Question about __alloc_skb() speedup
Date: Fri, 03 Dec 2010 11:50:29 +0100 [thread overview]
Message-ID: <1291373429.2897.96.camel@edumazet-laptop> (raw)
In-Reply-To: <20101203101450.GA9573@Desktop-Junchang>
Le vendredi 03 décembre 2010 à 18:14 +0800, Junchang Wang a écrit :
> Hi Eric,
>
> I'm reading your patch (ec7d2f2cf3a1 __alloc_skb() speedup),
> in which you prefetch skb and the shinfo part. I'm very
> curious why we don't prefetch skb->data. It seems that will
> help tx path a lot.
>
> I added the following code
>
> diff --git a/net/core/skbuff.c b/net/core/skbuff.c
> index 104f844..c60a808 100644
> --- a/net/core/skbuff.c
> +++ b/net/core/skbuff.c
> @@ -222,6 +222,8 @@ struct sk_buff *__alloc_skb(unsigned int size, gfp_t gfp_mask,
>
> child->fclone = SKB_FCLONE_UNAVAILABLE;
> }
> + prefetchw(data);
> +
> out:
> return skb;
> nodata:
>
> and the pktgen in my server (A Intel SR1625 server with two E5530
> 4-core processors and a single ixgbe-based NIC) goes from 7.6Mpps to
> 8.4Mpps (64 byte), with 10% performance gain.
>
> For rx path, I did experiments on both ixgbe and igb with pktgen+kute,
> and there is no change in system performance.
>
> welcome any suggestions and corrections.
>
> Thanks.
This is because __alloc_skb() is generic :
We dont know if the skb->data is going to be used right after or not at
all.
For example, NIC drivers call __alloc_skb() to refill their RX ring
buffer. There is no gain to prefetch data in this case since the data is
going to be written by the NIC hardware. The reverse would be needed
actually : ask to local cpu to evict data from its cache, so that device
can DMA it faster (less bus transactions)
By the way, adding prefetchw() right before the "return skb;" is
probably not very useful. You can certainly try to add the prefetchw()
in pktgen itself, since you know for sure you are going to write the
data.
I dont understand your 10% speedup because pktgen actually uses
__netdev_alloc_skb(), so it calls skb_reserve(skb, NET_SKB_PAD) : your
prefetchw is bringing a cache line that wont be used at all by pktgen.
I would say 10% sounds highly suspect to me...
next prev parent reply other threads:[~2010-12-03 10:50 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-12-03 10:14 Question about __alloc_skb() speedup Junchang Wang
2010-12-03 10:50 ` Eric Dumazet [this message]
2010-12-04 14:18 ` Junchang Wang
2010-12-04 14:47 ` Eric Dumazet
2010-12-04 14:49 ` Eric Dumazet
2010-12-05 10:56 ` Junchang Wang
2010-12-05 16:49 ` Eric Dumazet
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=1291373429.2897.96.camel@edumazet-laptop \
--to=eric.dumazet@gmail.com \
--cc=junchangwang@gmail.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox