netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Eric Dumazet <eric.dumazet@gmail.com>
To: eilong@broadcom.com
Cc: David Miller <davem@davemloft.net>,
	"bhutchings@solarflare.com" <bhutchings@solarflare.com>,
	"pstaszewski@itcare.pl" <pstaszewski@itcare.pl>,
	"netdev@vger.kernel.org" <netdev@vger.kernel.org>
Subject: Re: [PATCH net-next] bnx2x: reduce skb truesize by 50%
Date: Thu, 10 Nov 2011 16:27:58 +0100	[thread overview]
Message-ID: <1320938878.2310.15.camel@edumazet-HP-Compaq-6005-Pro-SFF-PC> (raw)
In-Reply-To: <1320937526.307.0.camel@lb-tlvb-eilong.il.broadcom.com>

Le jeudi 10 novembre 2011 à 17:05 +0200, Eilon Greenstein a écrit :
> On Wed, 2011-11-09 at 16:29 -0800, Eric Dumazet wrote:
> > Le mercredi 09 novembre 2011 à 23:03 +0100, Eric Dumazet a écrit :
> > 
> > > BTW, on my bnx2x adapter, even small UDP frames use more than PAGE_SIZE
> > > bytes :
> > > 
> > > skb->truesize=4352 len=26 (payload only)
> > > 
> > 
> > > I wonder if we shouldnt increase SK_MEM_QUANTUM a bit to avoid
> > > ping/pong...
> > > 
> > > -#define SK_MEM_QUANTUM ((int)PAGE_SIZE)
> > > +#define SK_MEM_QUANTUM ((int)PAGE_SIZE * 2)
> > > 
> > 
> > Following patch also helps a lot, even with only two cpus (one handling
> > device interrupts, one running the application thread)
> > 
> > [PATCH net-next] bnx2x: reduce skb truesize by ~50%
> > 
> > bnx2x uses following formula to compute its rx_buf_sz :
> > 
> > dev->mtu + 2*L1_CACHE_BYTES + 14 + 8 + 8
> > 
> > Then core network adds NET_SKB_PAD and SKB_DATA_ALIGN(sizeof(struct
> > skb_shared_info))
> > 
> > Final allocated size for skb head on x86_64 (L1_CACHE_BYTES = 64,
> > MTU=1500) : 2112 bytes : SLUB/SLAB round this to 4096 bytes.
> > 
> > Since skb truesize is then bigger than SK_MEM_QUANTUM, we have lot of
> > false sharing because of mem_reclaim in UDP stack.
> > 
> > One possible way to half truesize is to lower the need by 64 bytes (2112
> > -> 2048 bytes)
> > 
> > This way, skb->truesize is lower than SK_MEM_QUANTUM and we get better
> > performance.
> > 
> > (760.000 pps on a rx UDP monothread benchmark, instead of 720.000 pps)
> > 
> > 
> > Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
> > CC: Eilon Greenstein <eilong@broadcom.com>
> > ---
> >  drivers/net/ethernet/broadcom/bnx2x/bnx2x.h |   11 ++++++++---
> >  1 file changed, 8 insertions(+), 3 deletions(-)
> > 
> > diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x.h
> > index aec7212..ebbdc55 100644
> > --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x.h
> > +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x.h
> > @@ -1185,9 +1185,14 @@ struct bnx2x {
> >  #define ETH_MAX_PACKET_SIZE		1500
> >  #define ETH_MAX_JUMBO_PACKET_SIZE	9600
> >  
> > -	/* Max supported alignment is 256 (8 shift) */
> > -#define BNX2X_RX_ALIGN_SHIFT		((L1_CACHE_SHIFT < 8) ? \
> > -					 L1_CACHE_SHIFT : 8)
> > +/* Max supported alignment is 256 (8 shift)
> > + * It should ideally be min(L1_CACHE_SHIFT, 8)
> > + * Choosing 5 (32 bytes) permits to get skb heads of 2048 bytes
> > + * instead of 4096 bytes.
> > + * With SLUB/SLAB allocators, data will be cache line aligned anyway.
> > + */
> > +#define BNX2X_RX_ALIGN_SHIFT		5
> > +
> 
> Hi Eric,
> 
> This can seriously hurt the PCI utilization. So in scenarios in which
> the PCI is the bottle neck, you will see performance degradation. We are
> looking at alternatives to reduce the allocation, but it is taking a
> while. Please hold off with this patch.

What do you mean exactly ?

This patch doesnt change skb->data alignment, its still 64 bytes
aligned. (cqe_fp->placement_offset == 2). PCI utilization is the same.

Only SLOB could get a misalignement, but who uses SLOB for performance ?

Alternative would be to check why hardware need 2*L1_CACHE_BYTES extra
room for alignment... Normaly it could be 1*L1_CACHE_BYTES ?

 	/* FW use 2 Cache lines Alignment for start packet and size  */
-#define BNX2X_FW_RX_ALIGN              (2 << BNX2X_RX_ALIGN_SHIFT)
+#define BNX2X_FW_RX_ALIGN              (1 << BNX2X_RX_ALIGN_SHIFT)

  reply	other threads:[~2011-11-10 15:28 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-11-06 15:57 Linux Route Cache performance tests Paweł Staszewski
2011-11-06 17:29 ` Eric Dumazet
2011-11-06 18:28   ` Paweł Staszewski
2011-11-06 18:48     ` Eric Dumazet
2011-11-06 19:20       ` Paweł Staszewski
2011-11-06 19:38         ` Eric Dumazet
2011-11-06 20:25           ` Paweł Staszewski
2011-11-06 21:26             ` Eric Dumazet
2011-11-06 21:57               ` Paweł Staszewski
2011-11-06 23:08                 ` Eric Dumazet
2011-11-07  8:36                   ` Paweł Staszewski
2011-11-07  9:08                     ` Eric Dumazet
2011-11-07  9:16                       ` Eric Dumazet
2011-11-07 22:12                         ` Paweł Staszewski
2011-11-07 13:42           ` Ben Hutchings
2011-11-07 14:33             ` Eric Dumazet
2011-11-09 17:24               ` [PATCH net-next] ipv4: PKTINFO doesnt need dst reference Eric Dumazet
2011-11-09 21:37                 ` David Miller
2011-11-09 22:03                   ` Eric Dumazet
2011-11-10  0:29                     ` [PATCH net-next] bnx2x: reduce skb truesize by 50% Eric Dumazet
2011-11-10 15:05                       ` Eilon Greenstein
2011-11-10 15:27                         ` Eric Dumazet [this message]
2011-11-10 16:27                           ` Eilon Greenstein
2011-11-10 16:45                             ` Eric Dumazet
2011-11-13 18:53                               ` Eilon Greenstein
2011-11-13 19:42                                 ` Eric Dumazet
2011-11-13 20:08                                   ` Eilon Greenstein
2011-11-13 22:00                                     ` Eric Dumazet
2011-11-14  5:08                                       ` David Miller
2011-11-14  6:25                                         ` Eric Dumazet
2011-11-14 15:57                                           ` Eric Dumazet
2011-11-14 19:21                                             ` David Miller

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=1320938878.2310.15.camel@edumazet-HP-Compaq-6005-Pro-SFF-PC \
    --to=eric.dumazet@gmail.com \
    --cc=bhutchings@solarflare.com \
    --cc=davem@davemloft.net \
    --cc=eilong@broadcom.com \
    --cc=netdev@vger.kernel.org \
    --cc=pstaszewski@itcare.pl \
    /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;
as well as URLs for NNTP newsgroup(s).