Re: [PATCH net-next v3 2/5] mm: add a signature in struct page
From: Jesper Dangaard Brouer <hidden>
Date: 2021-04-14 19:42:06
Also in:
bpf, linux-mm, linux-rdma, lkml
On Sat, 10 Apr 2021 21:27:31 +0300 Ilias Apalodimas [off-list ref] wrote:
On Sat, Apr 10, 2021 at 10:42:30AM -0700, Shakeel Butt wrote:quoted
On Sat, Apr 10, 2021 at 9:16 AM Ilias Apalodimas [off-list ref] wrote:quoted
Hi Matthew On Sat, Apr 10, 2021 at 04:48:24PM +0100, Matthew Wilcox wrote:quoted
On Sat, Apr 10, 2021 at 12:37:58AM +0200, Matteo Croce wrote:quoted
This is needed by the page_pool to avoid recycling a page not allocated via page_pool.Is the PageType mechanism more appropriate to your needs? It wouldn't be if you use page->_mapcount (ie mapping it to userspace).Interesting! Please keep in mind this was written ~2018 and was stale on my branches for quite some time. So back then I did try to use PageType, but had not free bits. Looking at it again though, it's cleaned up. So yes I think this can be much much cleaner. Should we go and define a new PG_pagepool?Can this page_pool be used for TCP RX zerocopy? If yes then PageType can not be used.Yes it can, since it's going to be used as your default allocator for payloads, which might end up on an SKB.
I'm not sure we want or should "allow" page_pool be used for TCP RX zerocopy. For several reasons. (1) This implies mapping these pages page to userspace, which AFAIK means using page->mapping and page->index members (right?). (2) It feels wrong (security wise) to keep the DMA-mapping (for the device) and also map this page into userspace. (3) The page_pool is optimized for refcnt==1 case, and AFAIK TCP-RX zerocopy will bump the refcnt, which means the page_pool will not recycle the page when it see the elevated refcnt (it will instead release its DMA-mapping). (4) I remember vaguely that this code path for (TCP RX zerocopy) uses page->private for tricks. And our patch [3/5] use page->private for storing xdp_mem_info. IMHO when the SKB travel into this TCP RX zerocopy code path, we should call page_pool_release_page() to release its DMA-mapping.
-- Best regards, Jesper Dangaard Brouer MSc.CS, Principal Kernel Engineer at Red Hat LinkedIn: http://www.linkedin.com/in/brouer