From: Mina Almasry <almasrymina@google.com>
To: Yunsheng Lin <linyunsheng@huawei.com>
Cc: "Willem de Bruijn" <willemdebruijn.kernel@gmail.com>,
"Jakub Kicinski" <kuba@kernel.org>,
davem@davemloft.net, pabeni@redhat.com, netdev@vger.kernel.org,
linux-kernel@vger.kernel.org,
"Willem de Bruijn" <willemb@google.com>,
"Kaiyuan Zhang" <kaiyuanz@google.com>,
"Jesper Dangaard Brouer" <hawk@kernel.org>,
"Ilias Apalodimas" <ilias.apalodimas@linaro.org>,
"Eric Dumazet" <edumazet@google.com>,
"Christian König" <christian.koenig@amd.com>,
"Jason Gunthorpe" <jgg@nvidia.com>,
"Matthew Wilcox" <willy@infradead.org>,
Linux-MM <linux-mm@kvack.org>
Subject: Re: [PATCH RFC 3/8] memory-provider: dmabuf devmem memory provider
Date: Wed, 15 Nov 2023 10:07:11 -0800 [thread overview]
Message-ID: <CAHS8izOBe2X3iPHmvc7JQGiawgm7Gyxov8xq62SShUTXDRguFw@mail.gmail.com> (raw)
In-Reply-To: <8b7d25eb-1f10-3e37-8753-92b42da3fb34@huawei.com>
On Wed, Nov 15, 2023 at 1:29 AM Yunsheng Lin <linyunsheng@huawei.com> wrote:
>
> On 2023/11/14 23:41, Willem de Bruijn wrote:
> >>
> >> I am not sure dma-buf maintainer's concern is still there with this patchset.
> >>
> >> Whatever name you calling it for the struct, however you arrange each field
> >> in the struct, some metadata is always needed for dmabuf to intergrate into
> >> page pool.
> >>
> >> If the above is true, why not utilize the 'struct page' to have more unified
> >> handling?
> >
> > My understanding is that there is a general preference to simplify struct
> > page, and at the least not move in the other direction by overloading the
> > struct in new ways.
>
> As my understanding, the new struct is just mirroring the struct page pool
> is already using, see:
> https://elixir.free-electrons.com/linux/v6.7-rc1/source/include/linux/mm_types.h#L119
>
> If there is simplifying to the struct page_pool is using, I think the new
> stuct the devmem memory provider is using can adjust accordingly.
>
> As a matter of fact, I think the way 'struct page' for devmem is decoupled
> from mm subsystem may provide a way to simplify or decoupled the already
> existing 'struct page' used in netstack from mm subsystem, before this
> patchset, it seems we have the below types of 'struct page':
> 1. page allocated in the netstack using page pool.
> 2. page allocated in the netstack using buddy allocator.
> 3. page allocated in other subsystem and passed to the netstack, such as
> zcopy or spliced page?
>
> If we can decouple 'struct page' for devmem from mm subsystem, we may be able
> to decouple the above 'struct page' from mm subsystem one by one.
>
> >
> > If using struct page for something that is not memory, there is ZONE_DEVICE.
> > But using that correctly is non-trivial:
> >
> > https://lore.kernel.org/all/ZKyZBbKEpmkFkpWV@ziepe.ca/
> >
> > Since all we need is a handle that does not leave the network stack,
> > a network specific struct like page_pool_iov entirely avoids this issue.
>
> Yes, I am agree about the network specific struct.
> I am wondering if we can make the struct more generic if we want to
> intergrate it into page_pool and use it in net stack.
>
> > RFC v3 seems like a good simplification over RFC v1 in that regard to me.
> > I was also pleasantly surprised how minimal the change to the users of
> > skb_frag_t actually proved to be.
>
> Yes, I am agreed about that too. Maybe we can make it simpler by using
> a more abstract struct as page_pool, and utilize some features of
> page_pool too.
>
> For example, from the page_pool doc, page_pool have fast cache and
> ptr-ring cache as below, but if napi_frag_unref() call
> page_pool_page_put_many() and return the dmabuf chunk directly to
> gen_pool in the memory provider, then it seems we are bypassing the
> below caches in the page_pool.
>
I think you're just misunderstanding the code. The page recycling
works with my patchset. napi_frag_unref() calls napi_pp_put_page() if
recycle == true, and that works the same with devmem as with regular
pages.
If recycle == false, we call page_pool_page_put_many() which will call
put_page() for regular pages and page_pool_iov_put_many() for devmem
pages. So, the memory recycling works exactly the same as before with
devmem as with regular pages. In my tests I do see the devmem being
recycled correctly. We are not bypassing any caches.
> +------------------+
> | Driver |
> +------------------+
> ^
> |
> |
> |
> v
> +--------------------------------------------+
> | request memory |
> +--------------------------------------------+
> ^ ^
> | |
> | Pool empty | Pool has entries
> | |
> v v
> +-----------------------+ +------------------------+
> | alloc (and map) pages | | get page from cache |
> +-----------------------+ +------------------------+
> ^ ^
> | |
> | cache available | No entries, refill
> | | from ptr-ring
> | |
> v v
> +-----------------+ +------------------+
> | Fast cache | | ptr-ring cache |
> +-----------------+ +------------------+
>
>
> >
> > .
> >
--
Thanks,
Mina
next prev parent reply other threads:[~2023-11-15 18:07 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20231113130041.58124-1-linyunsheng@huawei.com>
[not found] ` <20231113130041.58124-4-linyunsheng@huawei.com>
[not found] ` <CAHS8izMjmj0DRT_vjzVq5HMQyXtZdVK=o4OP0gzbaN=aJdQ3ig@mail.gmail.com>
[not found] ` <20231113180554.1d1c6b1a@kernel.org>
2023-11-14 8:23 ` Yunsheng Lin
2023-11-14 12:21 ` Mina Almasry
2023-11-14 12:49 ` Yunsheng Lin
2023-11-14 12:58 ` Mina Almasry
2023-11-14 13:19 ` Yunsheng Lin
2023-11-14 15:41 ` Willem de Bruijn
2023-11-15 9:29 ` Yunsheng Lin
2023-11-15 18:07 ` Mina Almasry [this message]
2023-11-15 19:05 ` Mina Almasry
2023-11-16 11:12 ` Yunsheng Lin
2023-11-16 11:30 ` Mina Almasry
2023-11-14 13:16 ` Jason Gunthorpe
2023-11-15 6:46 ` Christian König
2023-11-15 9:21 ` Yunsheng Lin
2023-11-15 13:38 ` Jason Gunthorpe
2023-11-16 11:10 ` Yunsheng Lin
2023-11-16 15:31 ` Jason Gunthorpe
2023-11-15 17:44 ` Mina Almasry
2023-11-16 11:11 ` Yunsheng Lin
2023-11-15 17:57 ` David Ahern
2023-11-16 11:12 ` Yunsheng Lin
2023-11-16 15:58 ` David Ahern
2023-11-17 11:27 ` Yunsheng Lin
2023-11-14 22:25 ` Jakub Kicinski
2023-11-15 9:33 ` Yunsheng Lin
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=CAHS8izOBe2X3iPHmvc7JQGiawgm7Gyxov8xq62SShUTXDRguFw@mail.gmail.com \
--to=almasrymina@google.com \
--cc=christian.koenig@amd.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=hawk@kernel.org \
--cc=ilias.apalodimas@linaro.org \
--cc=jgg@nvidia.com \
--cc=kaiyuanz@google.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=linyunsheng@huawei.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=willemb@google.com \
--cc=willemdebruijn.kernel@gmail.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