netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Tariq Toukan <tariqt@mellanox.com>
To: Jesper Dangaard Brouer <brouer@redhat.com>
Cc: Eric Dumazet <eric.dumazet@gmail.com>,
	Ilias Apalodimas <ilias.apalodimas@linaro.org>,
	Matthew Wilcox <willy@infradead.org>,
	David Miller <davem@davemloft.net>,
	"toke@redhat.com" <toke@redhat.com>,
	"netdev@vger.kernel.org" <netdev@vger.kernel.org>,
	"mgorman@techsingularity.net" <mgorman@techsingularity.net>,
	"linux-mm@kvack.org" <linux-mm@kvack.org>
Subject: Re: [RFC, PATCH] net: page_pool: Don't use page->private to store dma_addr_t
Date: Tue, 12 Feb 2019 14:58:34 +0000	[thread overview]
Message-ID: <8c12e15c-26b1-0028-e023-86bb62c7d60b@mellanox.com> (raw)
In-Reply-To: <20190212144938.36dd45b4@carbon>



On 2/12/2019 3:49 PM, Jesper Dangaard Brouer wrote:
> On Tue, 12 Feb 2019 12:39:59 +0000
> Tariq Toukan <tariqt@mellanox.com> wrote:
> 
>> On 2/11/2019 7:14 PM, Eric Dumazet wrote:
>>>
>>> On 02/11/2019 12:53 AM, Tariq Toukan wrote:
>>>>   
>>>    
>>>> Hi,
>>>>
>>>> It's great to use the struct page to store its dma mapping, but I am
>>>> worried about extensibility.
>>>> page_pool is evolving, and it would need several more per-page fields.
>>>> One of them would be pageref_bias, a planned optimization to reduce the
>>>> number of the costly atomic pageref operations (and replace existing
>>>> code in several drivers).
>>>>   
>>>
>>> But the point about pageref_bias is to place it in a different
>>> cache line than "struct page"
> 
> Yes, exactly.
> 
> 
>>> The major cost is having a cache line bouncing between producer and
>>> consumer.
>>
>> pageref_bias is meant to be dirtied only by the page requester, i.e. the
>> NIC driver / page_pool.
>> All other components (basically, SKB release flow / put_page) should
>> continue working with the atomic page_refcnt, and not dirty the
>> pageref_bias.
>>
>> However, what bothers me more is another issue.
>> The optimization doesn't cleanly combine with the new page_pool
>> direction for maintaining a queue for "available" pages, as the put_page
>> flow would need to read pageref_bias, asynchronously, and act accordingly.
>>
>> The suggested hook in put_page (to catch the 2 -> 1 "biased refcnt"
>> transition) causes a problem to the traditional pageref_bias idea, as it
>> implies a new point in which the pageref_bias field is read
>> *asynchronously*. This would risk missing the this critical 2 -> 1
>> transition! Unless pageref_bias is atomic...
> 
> I want to stop you here...
> 
> It seems to me that you are trying to shoehorn in a refcount
> optimization into page_pool.  The page_pool is optimized for the XDP
> case of one-frame-per-page, where we can avoid changing the refcount,
> and tradeoff memory usage for speed.  It is compatible with the elevated
> refcount usage, but that is not the optimization target.
> 
> If the case you are optimizing for is "packing" more frames in a page,
> then the page_pool might be the wrong choice.  To me it would make more
> sense to create another enum xdp_mem_type, that generalize the
> pageref_bias tricks also used by some drivers.
> 

Hi Jesper,

We share the same interest, I tried to combine the pageref_bias 
optimization on top of the put_page hook, but turns out it doesn't fit. 
That's all.

Of course, I am aware of the fact that page_pool is optimized for XDP 
use cases. But, as drivers prefer a single flow for their 
page-allocation management, rather than having several allocation/free 
methods depending on whether XDP program is loaded or not, the 
performance for non-XDP flow also matters.
I know you're not ignoring this, the fact that you're adding 
compatibility for the elevated refcount usage is a key step in this 
direction.

Another key benefit of page_pool is providing a netdev-optimized API 
that can replace the page allocation / dma mapping logic of the 
different drivers, and take it into one common shared unit.
This helps remove many LOCs from drivers, significantly improves 
modularity, and eases the support of new optimizations.
By improving the general non-XDP flow (packing several packets in a 
page) you encourage more and more drivers to do the transition.

We all look to further improve the page-pool performance. The 
pageref_bias idea does not fit, that's fine.
We can still introduce an API for bulk page-allocation, it will improve 
both XDP and non-XDP flows.

Regards,
Tariq

  reply	other threads:[~2019-02-12 14:58 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-07 14:36 [RFC, PATCH] net: page_pool: Don't use page->private to store dma_addr_t Ilias Apalodimas
2019-02-07 15:07 ` Matthew Wilcox
2019-02-07 15:20   ` Ilias Apalodimas
2019-02-07 21:25     ` David Miller
2019-02-07 21:34       ` Matthew Wilcox
2019-02-07 21:42         ` Ilias Apalodimas
2019-02-11  8:53           ` Tariq Toukan
2019-02-11 12:12             ` Matthew Wilcox
2019-02-11 15:38               ` Tariq Toukan
2019-02-11 17:14             ` Eric Dumazet
2019-02-12 12:39               ` Tariq Toukan
2019-02-12 13:49                 ` Jesper Dangaard Brouer
2019-02-12 14:58                   ` Tariq Toukan [this message]
2019-02-12 15:15                 ` Eric Dumazet
2019-02-12 18:13                   ` Alexander Duyck
2019-02-12 18:20                     ` Ilias Apalodimas
2019-02-13  8:50                       ` Tariq Toukan
2019-02-13  8:46                     ` Tariq Toukan
2019-02-07 21:37       ` Ilias Apalodimas

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=8c12e15c-26b1-0028-e023-86bb62c7d60b@mellanox.com \
    --to=tariqt@mellanox.com \
    --cc=brouer@redhat.com \
    --cc=davem@davemloft.net \
    --cc=eric.dumazet@gmail.com \
    --cc=ilias.apalodimas@linaro.org \
    --cc=linux-mm@kvack.org \
    --cc=mgorman@techsingularity.net \
    --cc=netdev@vger.kernel.org \
    --cc=toke@redhat.com \
    --cc=willy@infradead.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;
as well as URLs for NNTP newsgroup(s).