netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Willy Tarreau <w@1wt.eu>
To: David Laight <David.Laight@ACULAB.COM>
Cc: "davem@davemloft.net" <davem@davemloft.net>,
	"netdev@vger.kernel.org" <netdev@vger.kernel.org>,
	Thomas Petazzoni <thomas.petazzoni@free-electrons.com>,
	Gregory CLEMENT <gregory.clement@free-electrons.com>
Subject: Re: [PATCH net-next 6/6] net: mvneta: implement rx_copybreak
Date: Mon, 13 Jan 2014 11:49:38 +0100	[thread overview]
Message-ID: <20140113104938.GB20202@1wt.eu> (raw)
In-Reply-To: <063D6719AE5E284EB5DD2968C1650D6D458FB3@AcuExch.aculab.com>

Hi David,

On Mon, Jan 13, 2014 at 10:13:16AM +0000, David Laight wrote:
> From: Willy Tarreau
> > calling dma_map_single()/dma_unmap_single() is quite expensive compared
> > to copying a small packet. So let's copy short frames and keep the buffers
> > mapped. We set the limit to 256 bytes which seems to give good results both
> > on the XP-GP board and on the AX3/4.
> 
> Which architecture is this?

It's an ARMv7.

> I presume it is one that needs iommu setup and/or cache flushing.

Just wait for cache snoop completion.

> > The Rx small packet rate increased by 16.4% doing this, from 486kpps to
> > 573kpps. It is worth noting that even the call to the function
> > dma_sync_single_range_for_cpu() is expensive (300 ns) although less
> > than dma_unmap_single(). Without it, the packet rate raises to 711kpps
> > (+24% more). Thus on systems where coherency from device to CPU is
> > guaranteed by a snoop control unit, this patch should provide even more
> > gains, and probably rx_copybreak could be increased.
> 
> Is that the right way around?
> If cache coherency is guaranteed then I'd have thought that the dma sync
> would be a nop.

It's a bit more tricky. I found that the DMA API is not optimal for such
an architecture, because we need to wait *once* for the cache snooping to
complete at the beginning of the Rx loop, and then all other access may be
done with a NOP. However, since we don't currently have the ability to do
a first call and replace the other ones with a NOP, we still have to do
a dma_sync_single_for_cpu() for each packet, resulting in waiting for cache
snoop completion for each packet.
 
I've hacked the DMA API to add support for ops->iobarrier and test for it
at the beginning of the loop, call it, then avoid doing dma_sync_* afterwards
if it's defined. That way I reach the higher performance mentionned above.

But in my opinion, this is only material for future discussions.

> ...
> > +			memcpy(skb_put(skb, rx_bytes),
> > +			       data + MVNETA_MH_SIZE + NET_SKB_PAD,
> > +			       rx_bytes);
> 
> You can probably arrange for the copy to be fully aligned since
> the partial words at both ends can be safely read and written.
> That might speed things up further.

In fact it does not, this is what the very first patch did but I did not
see any difference.

Thanks,
Willy

  reply	other threads:[~2014-01-13 10:49 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-01-12 11:24 [PATCH net-next 0/6] mvneta driver performance improvements Willy Tarreau
2014-01-12 11:24 ` [PATCH net-next 1/6] net: mvneta: remove tests for impossible cases in the tx_done path Willy Tarreau
2014-01-12 11:24 ` [PATCH net-next 2/6] net: mvneta: factor rx refilling code Willy Tarreau
2014-01-12 11:24 ` [PATCH net-next 3/6] net: mvneta: simplify access to the rx descriptor status Willy Tarreau
2014-01-12 11:24 ` [PATCH net-next 4/6] net: mvneta: prefetch next rx descriptor instead of current one Willy Tarreau
2014-01-12 11:24 ` [PATCH net-next 5/6] net: mvneta: convert to build_skb() Willy Tarreau
2014-01-12 11:24 ` [PATCH net-next 6/6] net: mvneta: implement rx_copybreak Willy Tarreau
2014-01-13 10:13   ` David Laight
2014-01-13 10:49     ` Willy Tarreau [this message]
2014-01-15  1:00 ` [PATCH net-next 0/6] mvneta driver performance improvements David Miller
2014-01-15  7:25   ` Willy Tarreau
2014-01-15  7:48   ` Willy Tarreau
2014-01-15  8:05     ` David Miller
2014-01-15  8:18       ` Willy Tarreau

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=20140113104938.GB20202@1wt.eu \
    --to=w@1wt.eu \
    --cc=David.Laight@ACULAB.COM \
    --cc=davem@davemloft.net \
    --cc=gregory.clement@free-electrons.com \
    --cc=netdev@vger.kernel.org \
    --cc=thomas.petazzoni@free-electrons.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;
as well as URLs for NNTP newsgroup(s).