[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <d3dcd3e1-c6ba-4756-bd8e-273e727b635a@intel.com>
Date: Tue, 1 Apr 2025 13:56:36 +0200
From: Alexander Lobakin <aleksander.lobakin@...el.com>
To: Yunsheng Lin <linyunsheng@...wei.com>
CC: Zhu Yanjun <yanjun.zhu@...ux.dev>,
Toke Høiland-Jørgensen <toke@...hat.com>, "David S.
Miller" <davem@...emloft.net>, Jakub Kicinski <kuba@...nel.org>, "Jesper
Dangaard Brouer" <hawk@...nel.org>, Saeed Mahameed <saeedm@...dia.com>, "Leon
Romanovsky" <leon@...nel.org>, Tariq Toukan <tariqt@...dia.com>, Andrew Lunn
<andrew+netdev@...n.ch>, Eric Dumazet <edumazet@...gle.com>, Paolo Abeni
<pabeni@...hat.com>, Ilias Apalodimas <ilias.apalodimas@...aro.org>, "Simon
Horman" <horms@...nel.org>, Andrew Morton <akpm@...ux-foundation.org>, "Mina
Almasry" <almasrymina@...gle.com>, Yonglong Liu <liuyonglong@...wei.com>,
Pavel Begunkov <asml.silence@...il.com>, Matthew Wilcox
<willy@...radead.org>, <netdev@...r.kernel.org>, <bpf@...r.kernel.org>,
<linux-rdma@...r.kernel.org>, <linux-mm@...ck.org>, Qiuling Ren
<qren@...hat.com>, Yuying Ma <yuma@...hat.com>
Subject: Re: [PATCH net-next v5 2/2] page_pool: Track DMA-mapped pages and
unmap them when destroying the pool
From: Yunsheng Lin <linyunsheng@...wei.com>
Date: Tue, 1 Apr 2025 17:24:43 +0800
> On 2025/4/1 1:27, Zhu Yanjun wrote:
>> 在 2025/3/31 18:35, Alexander Lobakin 写道:
>>> From: Toke Høiland-Jørgensen <toke@...hat.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?
>>
>> Perhaps test_bit series functions can test the bit atomically. Maybe there are more good options about this testing the bit atomically. But test_bit should implement the task that tests the bit atomically.
>
> There are two reading of dma_sync in this patch, the first reading is not
> under rcu read lock and doing the reading without READ_ONCE(), the second
> reading is under rcu read lock and do the reading with READ_ONCE().
>
> The first one seems an optimization to avoid taking the rcu read lock,
> why might need READ_ONCE() to make KCSAN happy if we do care about making
> KCSAN happy.
>
> The second one does not seems to need the atomicity by using the READ_ONCE()
> as it is always under RCU read lock(implicit or explicit one), and there is
> a rcu sync after the clearing of that bit.
IOW, are you saying this change is not needed at all?
Thanks,
Olek
Powered by blists - more mailing lists