From: Eric Dumazet <eric.dumazet@gmail.com>
To: Ming Lei <tom.leiming@gmail.com>
Cc: Network Development <netdev@vger.kernel.org>,
David Miller <davem@davemloft.net>
Subject: Re: TCP transmit performance regression
Date: Fri, 06 Jul 2012 07:16:04 +0200 [thread overview]
Message-ID: <1341551764.3265.47.camel@edumazet-glaptop> (raw)
In-Reply-To: <1341550714.3265.44.camel@edumazet-glaptop>
On Fri, 2012-07-06 at 06:58 +0200, Eric Dumazet wrote:
> On Fri, 2012-07-06 at 08:45 +0800, Ming Lei wrote:
>
> > Unfortunately, the patch still hasn't any improvement on the transmit
> > performance of beagle-xm.
>
> Ah yes, I need to change usbnet as well to be able to fully recycle the
> big skbs allocated in turbo mode.
>
> Right now they are constantly allocated/freed and this sucks if SLAB
> wants to check poison bytes in debug mode.
In the mean time, you also can use the following patch I have to polish,
but this should give you a nice boost, since the big skb skb->head wont
be checked by SLAB debug :
diff --git a/net/core/skbuff.c b/net/core/skbuff.c
index 5b21522..d31efa2 100644
--- a/net/core/skbuff.c
+++ b/net/core/skbuff.c
@@ -296,9 +296,18 @@ EXPORT_SYMBOL(build_skb);
struct netdev_alloc_cache {
struct page *page;
unsigned int offset;
+ unsigned int pagecnt_bias;
};
static DEFINE_PER_CPU(struct netdev_alloc_cache, netdev_alloc_cache);
+#if PAGE_SIZE > 32768
+#define MAX_NETDEV_FRAGSIZE PAGE_SIZE
+#else
+#define MAX_NETDEV_FRAGSIZE 32768
+#endif
+
+#define NETDEV_PAGECNT_BIAS (MAX_NETDEV_FRAGSIZE / \
+ SKB_DATA_ALIGN(sizeof(struct skb_shared_info)))
/**
* netdev_alloc_frag - allocate a page fragment
* @fragsz: fragment size
@@ -316,18 +325,25 @@ void *netdev_alloc_frag(unsigned int fragsz)
nc = &__get_cpu_var(netdev_alloc_cache);
if (unlikely(!nc->page)) {
refill:
- nc->page = alloc_page(GFP_ATOMIC | __GFP_COLD);
+ nc->page = alloc_pages(GFP_ATOMIC | __GFP_COLD | __GFP_COMP,
+ get_order(MAX_NETDEV_FRAGSIZE));
+ if (unlikely(!nc->page))
+ goto end;
+recycle:
+ atomic_set(&nc->page->_count, NETDEV_PAGECNT_BIAS);
+ nc->pagecnt_bias = NETDEV_PAGECNT_BIAS;
nc->offset = 0;
}
- if (likely(nc->page)) {
- if (nc->offset + fragsz > PAGE_SIZE) {
- put_page(nc->page);
- goto refill;
- }
- data = page_address(nc->page) + nc->offset;
- nc->offset += fragsz;
- get_page(nc->page);
+ if (nc->offset + fragsz > MAX_NETDEV_FRAGSIZE) {
+ if (!atomic_sub_return(nc->pagecnt_bias,
+ &nc->page->_count))
+ goto recycle;
+ goto refill;
}
+ data = page_address(nc->page) + nc->offset;
+ nc->offset += fragsz;
+ nc->pagecnt_bias--; /* avoid get_page()/get_page() false sharing */
+end:
local_irq_restore(flags);
return data;
}
@@ -353,7 +369,7 @@ struct sk_buff *__netdev_alloc_skb(struct net_device *dev,
unsigned int fragsz = SKB_DATA_ALIGN(length + NET_SKB_PAD) +
SKB_DATA_ALIGN(sizeof(struct skb_shared_info));
- if (fragsz <= PAGE_SIZE && !(gfp_mask & __GFP_WAIT)) {
+ if (fragsz <= MAX_NETDEV_FRAGSIZE && !(gfp_mask & __GFP_WAIT)) {
void *data = netdev_alloc_frag(fragsz);
if (likely(data)) {
next prev parent reply other threads:[~2012-07-06 5:16 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-07-05 1:45 TCP transmit performance regression Ming Lei
2012-07-05 7:43 ` Eric Dumazet
2012-07-05 8:27 ` Ming Lei
2012-07-05 8:33 ` Eric Dumazet
2012-07-05 8:42 ` Ming Lei
2012-07-05 9:49 ` Eric Dumazet
2012-07-05 10:02 ` David Miller
2012-07-05 10:32 ` Ming Lei
2012-07-05 10:41 ` Eric Dumazet
2012-07-05 14:01 ` Ming Lei
2012-07-05 14:28 ` Eric Dumazet
2012-07-05 14:56 ` Eric Dumazet
2012-07-06 0:45 ` Ming Lei
2012-07-06 4:58 ` Eric Dumazet
2012-07-06 5:16 ` Eric Dumazet [this message]
2012-07-09 5:13 ` Ming Lei
2012-07-09 13:23 ` Ming Lei
2012-07-09 13:54 ` Eric Dumazet
[not found] ` <CACVXFVNdiwVn1Mo--N4N0HdYrEJizExtd_cppT4tS=mjog2PKw@mail.gmail.com>
[not found] ` <1341895143.3265.4049.camel@edumazet-glaptop>
2012-07-10 7:22 ` Ming Lei
2012-07-10 8:28 ` Eric Dumazet
2012-07-10 13:37 ` Ming Lei
2012-07-10 14:02 ` Eric Dumazet
2012-07-10 14:22 ` Ming Lei
2012-07-10 14:45 ` 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=1341551764.3265.47.camel@edumazet-glaptop \
--to=eric.dumazet@gmail.com \
--cc=davem@davemloft.net \
--cc=netdev@vger.kernel.org \
--cc=tom.leiming@gmail.com \
/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