linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Pavel Begunkov <asml.silence@gmail.com>
To: "Paolo Abeni" <pabeni@redhat.com>,
	"Alexander Lobakin" <aleksander.lobakin@intel.com>,
	"Toke Høiland-Jørgensen" <toke@redhat.com>
Cc: "David S. Miller" <davem@davemloft.net>,
	Jakub Kicinski <kuba@kernel.org>,
	Jesper Dangaard Brouer <hawk@kernel.org>,
	Saeed Mahameed <saeedm@nvidia.com>,
	Leon Romanovsky <leon@kernel.org>,
	Tariq Toukan <tariqt@nvidia.com>,
	Andrew Lunn <andrew+netdev@lunn.ch>,
	Eric Dumazet <edumazet@google.com>,
	Ilias Apalodimas <ilias.apalodimas@linaro.org>,
	Simon Horman <horms@kernel.org>,
	Andrew Morton <akpm@linux-foundation.org>,
	Mina Almasry <almasrymina@google.com>,
	Yonglong Liu <liuyonglong@huawei.com>,
	Yunsheng Lin <linyunsheng@huawei.com>,
	Matthew Wilcox <willy@infradead.org>,
	netdev@vger.kernel.org, bpf@vger.kernel.org,
	linux-rdma@vger.kernel.org, linux-mm@kvack.org,
	Qiuling Ren <qren@redhat.com>, Yuying Ma <yuma@redhat.com>
Subject: Re: [PATCH net-next v5 2/2] page_pool: Track DMA-mapped pages and unmap them when destroying the pool
Date: Tue, 1 Apr 2025 10:51:46 +0100	[thread overview]
Message-ID: <6d1e3c98-e28e-4d30-bff5-1dada745f722@gmail.com> (raw)
In-Reply-To: <7488e6cf-e68b-4404-aaa9-f4892b2ff94b@redhat.com>

On 4/1/25 09:56, Paolo Abeni wrote:
> On 3/31/25 6:35 PM, Alexander Lobakin wrote:
>> From: Toke Høiland-Jørgensen <toke@redhat.com>
>> Date: Fri, 28 Mar 2025 13:19:09 +0100
>>
>>> 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.
>>
>> [...]
>>
>>> @@ -173,10 +212,10 @@ struct page_pool {
>>>   	int cpuid;
>>>   	u32 pages_state_hold_cnt;
>>>   
>>> -	bool has_init_callback:1;	/* slow::init_callback is set */
>>> +	bool dma_sync;			/* Perform DMA sync for device */
>>
>> Have you seen my comment under v3 (sorry but I missed that there was v4
>> already)? Can't we just test the bit atomically?
> 
> My understanding is that to make such operation really atomic, we will
> need to access all the other bits within the same bitfield with atomic
> bit ops, leading to a significant code churn (and possibly some overhead).
> 
> I think that using a full bool field is a better option.

I agree, it's better not to overcomplicate a fix, and we can always
return to it later.

-- 
Pavel Begunkov



  reply	other threads:[~2025-04-01  9:50 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-03-28 12:19 [PATCH net-next v5 0/2] Fix late DMA unmap crash for page pool Toke Høiland-Jørgensen
2025-03-28 12:19 ` [PATCH net-next v5 1/2] page_pool: Move pp_magic check into helper functions Toke Høiland-Jørgensen
2025-03-28 12:19 ` [PATCH net-next v5 2/2] page_pool: Track DMA-mapped pages and unmap them when destroying the pool Toke Høiland-Jørgensen
2025-03-31 16:35   ` Alexander Lobakin
2025-03-31 17:27     ` Zhu Yanjun
2025-04-01  9:24       ` Yunsheng Lin
2025-04-01 11:56         ` Alexander Lobakin
2025-04-02 11:15           ` Yunsheng Lin
2025-04-01  8:56     ` Paolo Abeni
2025-04-01  9:51       ` Pavel Begunkov [this message]
2025-04-01 12:06         ` Jesper Dangaard Brouer
2025-04-01  8:52   ` Paolo Abeni
2025-04-01  9:12     ` Toke Høiland-Jørgensen

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=6d1e3c98-e28e-4d30-bff5-1dada745f722@gmail.com \
    --to=asml.silence@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=aleksander.lobakin@intel.com \
    --cc=almasrymina@google.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=bpf@vger.kernel.org \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=hawk@kernel.org \
    --cc=horms@kernel.org \
    --cc=ilias.apalodimas@linaro.org \
    --cc=kuba@kernel.org \
    --cc=leon@kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=linux-rdma@vger.kernel.org \
    --cc=linyunsheng@huawei.com \
    --cc=liuyonglong@huawei.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=qren@redhat.com \
    --cc=saeedm@nvidia.com \
    --cc=tariqt@nvidia.com \
    --cc=toke@redhat.com \
    --cc=willy@infradead.org \
    --cc=yuma@redhat.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