From: Eric Dumazet <eric.dumazet@gmail.com>
To: Or Gerlitz <or.gerlitz@gmail.com>
Cc: "David S. Miller" <davem@davemloft.net>,
netdev@vger.kernel.org, Or Gerlitz <ogerlitz@mellanox.com>,
Eugenia Emantayev <eugenia@mellanox.com>,
Saeed Mahameed <saeedm@mellanox.com>
Subject: Re: [PATCH net-next] mlx4: allow order-0 memory allocations in RX path
Date: Sun, 23 Jun 2013 14:13:23 -0700 [thread overview]
Message-ID: <1372022003.3301.47.camel@edumazet-glaptop> (raw)
In-Reply-To: <CAJZOPZ+-StTDm0D-jaeWGfQqOzz5e3C92zPmQf=0_mPV3MukCQ@mail.gmail.com>
On Sun, 2013-06-23 at 23:17 +0300, Or Gerlitz wrote:
> On Sun, Jun 23, 2013 at 6:17 PM, Eric Dumazet <eric.dumazet@gmail.com> wrote:
> > Signed-off-by: Eric Dumazet <edumazet@google.com>
> >
> > mlx4 exclusively uses order-2 allocations in RX path, which are
> > likely to fail under memory pressure.
> >
> > We therefore drop frames more than needed.
> >
> > This patch tries order-3, order-2, order-1 and finally order-0
> > allocations to keep good performance, yet allow allocations if/when
> > memory gets fragmented.
> >
> > By using larger pages, and avoiding unnecessary get_page()/put_page()
> > on compound pages, this patch improves performance as well, lowering
> > false sharing on struct page.
>
> Hi Eric, thanks for the patch, both Amir and Yevgeny are OOO, so it
> will take us a bit more time to conduct the review... but lets start:
> could you explain a little further what do you exactly refer to by
> "false sharing" in this context?
Every time mlx4 prepared a page frag into a skb, it did :
- a get_page() in mlx4_en_alloc_frags()
- a get_page() in mlx4_en_complete_rx_desc()
- a put_page() in mlx4_en_free_frag()
-> lot of changes of page->_count
When this skb is consumed, frag is freed -> put_page()
-> decrement of page->_count
If the consumer is on a different cpu, this adds false sharing on
"struct page"
After my patch, mlx4 driver touches this "struct page" only once,
and the consumers will do their get_page() without being slowed down by
mlx4 driver/cpu. This reduces latencies.
>
> Also, I am not fully sure, but I think the current driver code doesn't
> support splice and this somehow relates to how RX skbs are spread over
> pages. In that repsect, I wonder if this patch goes in the direction
> that would allow to support splice, or maybe takes us a bit back, as
> of moving to use order-3 allocations?
splice is supported by core networking, no worries ;)
It doesn't depend on order-whatever allocations.
BTW, splice() works well for TCP over loopback, and TX already uses
fragments in order-3 pages.
>
> You've mentioned performance improvement, could you be more specific?
> what's the scheme under which you saw the improvement and what was
> that improvement.
A cpu might be fully dedicated to softirq handling, and skb consumed on
other cpus.
My patch removes ~60 atomic operations per allocated page
(21 frags, and for each frag, two get_page() and one put_page())
>
> Last, as Amir wrote you, we're looking on re-using skbs on the RX
> patch to avoid sever performance hits when IOMMU is enabled. The team
> has not provided me yet the patch, but basically, if you look on the
> ixgbe patch that was made largely for that very same purpose
> (improving perf under IOMMU) f800326dca7bc158f4c886aa92f222de37993c80
> "ixgbe: Replace standard receive path with a page based receive" ,
> they use there order-0 or order-1 allocations, but not order-2 or
> order-3, also here I have some more catch up to conduct, so we'll
> see...
ixgbe do not support frag_size of 1536 bytes, but 2048 or 4096 bytes.
So using order-3 pages is not win for it.
But for mlx4, we gain 5% occupancy using order-3 pages (21 frags per
32K) over order-2 pages (10 frags per 16K), and 30 % over order-0 pages
(2 frags per 4K)
I don't know, current mlx4 driver is barely usable as is, unless you
make sure the host has enough memory, with plenty of order-2 pages.
And unless you have really specialized applications, there is never
enough memory.
next prev parent reply other threads:[~2013-06-23 21:13 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-06-20 19:40 [PATCH net-next 00/11] Mellanox driver updates 2013-06-20 Amir Vadai
2013-06-20 19:40 ` [PATCH net-next 01/11] net/mlx4_en: Suppress page allocation failure warnings Amir Vadai
2013-06-20 21:28 ` Eric Dumazet
2013-06-21 5:35 ` Amir Vadai
2013-06-23 8:46 ` Amir Vadai
2013-06-23 15:14 ` Eric Dumazet
2013-06-23 15:17 ` [PATCH net-next] mlx4: allow order-0 memory allocations in RX path Eric Dumazet
2013-06-23 20:17 ` Or Gerlitz
2013-06-23 21:13 ` Eric Dumazet [this message]
2013-06-24 14:10 ` Or Gerlitz
2013-06-24 14:09 ` Or Gerlitz
2013-06-25 8:53 ` Or Gerlitz
2013-06-25 23:19 ` David Miller
2013-06-20 19:40 ` [PATCH net-next 02/11] net/mlx4_en: Fix resource leak in error flow Amir Vadai
2013-06-20 19:40 ` [PATCH net-next 03/11] net/mlx4_en: Do not query stats when device port is down Amir Vadai
2013-06-20 19:40 ` [PATCH net-next 04/11] net/mlx4_en: Move register_netdev() to the end of initialization function Amir Vadai
2013-06-20 19:40 ` [PATCH net-next 05/11] net/mlx4_en: Change log level from error to debug for vlan related messages Amir Vadai
2013-06-20 19:40 ` [PATCH net-next 06/11] net/mlx4_en: Fix a race between napi poll function and RX ring cleanup Amir Vadai
2013-06-20 19:40 ` [PATCH net-next 07/11] net/mlx4_en: Add prints when TX timeout occurs Amir Vadai
2013-06-20 19:55 ` Joe Perches
2013-06-21 5:31 ` Amir Vadai
2013-06-20 19:40 ` [PATCH net-next 08/11] net/mlx4_en: Remove an unnecessary test Amir Vadai
2013-06-20 19:40 ` [PATCH net-next 09/11] net/mlx4_core: Replace sscanf() with kstrtoint() Amir Vadai
2013-06-20 19:40 ` [PATCH net-next 10/11] net/mlx4_core: Add warning in case of command timeouts Amir Vadai
2013-06-20 19:40 ` [PATCH net-next 11/11] net/mlx4_core: Fail device init if num_vfs is negative Amir Vadai
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=1372022003.3301.47.camel@edumazet-glaptop \
--to=eric.dumazet@gmail.com \
--cc=davem@davemloft.net \
--cc=eugenia@mellanox.com \
--cc=netdev@vger.kernel.org \
--cc=ogerlitz@mellanox.com \
--cc=or.gerlitz@gmail.com \
--cc=saeedm@mellanox.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