Re: [PATCH net-next v2 3/3] page_pool: Track DMA-mapped pages and unmap them when destroying the pool

From
Mina Almasry <hidden>
Date
2025-03-26 20:03:05
Also in
bpf, linux-mm, linux-rdma
Reply to
Saeed Mahameed, 2025-03-26
On Wed, Mar 26, 2025 at 11:22 AM Saeed Mahameed [off-list ref] wrote:
On 25 Mar 16:45, Toke Høiland-Jørgensen wrote:
quoted
When enabling DMA mapping in page_pool, pages are kept DMA mapped until
they are released from the pool, to avoid the overhead of re-mapping the
pages every time they are used. This causes resource leaks and/or
crashes when there are pages still outstanding while the device is torn
down, because page_pool will attempt an unmap through a non-existent DMA
device on the subsequent page return.
Why dynamically track when it is guaranteed the page_pool consumer (driver)
will return all outstanding pages before disabling the DMA device.
When a page pool is destroyed by the driver, just mark it as "DMA-inactive",
and on page_pool_return_page() if DMA-inactive don't recycle those pages
and immediately DMA unmap and release them.
That doesn't work, AFAIU. DMA unmaping after page_pool_destroy has
been called in what's causing the very bug this series is trying to
fix. What happens is:

1. Driver calls page_pool_destroy,
2. Driver removes the net_device (and I guess the associated iommu
structs go away with it).
3. Page-pool tries to unmap after page_pool_destroy is called, trying
to fetch iommu resources that have been freed due to the netdevice
gone away = bad stuff.

(but maybe I misunderstood your suggestion)

-- 
Thanks,
Mina
Thread (17 messages) 17 messages, 6 authors, last reply 2025-03-27
Keyboard shortcuts
hback out one level
jnext message in thread / next series-diff position
kprevious message in thread / previous series-diff position
ldrill in
Escclose help / fold thread tree
?toggle this help