From: Yunsheng Lin <linyunsheng@huawei.com>
To: Mina Almasry <almasrymina@google.com>
Cc: "Saeed Mahameed" <saeedm@nvidia.com>,
"Toke Høiland-Jørgensen" <toke@redhat.com>,
"David S. Miller" <davem@davemloft.net>,
"Jakub Kicinski" <kuba@kernel.org>,
"Jesper Dangaard Brouer" <hawk@kernel.org>,
"Leon Romanovsky" <leon@kernel.org>,
"Tariq Toukan" <tariqt@nvidia.com>,
"Andrew Lunn" <andrew+netdev@lunn.ch>,
"Eric Dumazet" <edumazet@google.com>,
"Paolo Abeni" <pabeni@redhat.com>,
"Ilias Apalodimas" <ilias.apalodimas@linaro.org>,
"Simon Horman" <horms@kernel.org>,
"Andrew Morton" <akpm@linux-foundation.org>,
"Yonglong Liu" <liuyonglong@huawei.com>,
"Pavel Begunkov" <asml.silence@gmail.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 v2 3/3] page_pool: Track DMA-mapped pages and unmap them when destroying the pool
Date: Thu, 27 Mar 2025 15:21:22 +0800 [thread overview]
Message-ID: <77cd9e2d-da66-4e8f-831d-87915465f98a@huawei.com> (raw)
In-Reply-To: <CAHS8izPA+hmOkP=jZd3mm1Zux2uaqpOf0poEci-Jn1g7msfkbA@mail.gmail.com>
On 2025/3/27 12:59, Mina Almasry wrote:
> On Wed, Mar 26, 2025 at 8:54 PM Yunsheng Lin <linyunsheng@huawei.com> wrote:
>>>>
>>>> Since all the tracking added in this patch is performed on DMA
>>>> map/unmap, no additional code is needed in the fast path, meaning the
>>>> performance overhead of this tracking is negligible there. A
>>>> micro-benchmark shows that the total overhead of the tracking itself is
>>>> about 400 ns (39 cycles(tsc) 395.218 ns; sum for both map and unmap[2]).
>>>> Since this cost is only paid on DMA map and unmap, it seems like an
>>>> acceptable cost to fix the late unmap issue. Further optimisation can
>>>> narrow the cases where this cost is paid (for instance by eliding the
>>>> tracking when DMA map/unmap is a no-op).
See the above statement, and note the above optimisation was also discussed
before and it seemed unfeasible too.
>
> what time_bench_page_pool03_slow actually does each iteration:
> - Allocates a page *from the fast path*
> - Frees a page to through the slow path (recycling disabled).
>
> Notably it doesn't do anything in the slow path that I imagine is
> actually expensive: alloc_page, dma_map_page, & dma_unmap_page.
As above, for most arches, the DMA map/unmap seems to be almost no-op when
page_pool is created with PP_FLAG_DMA_MAP flag without IOMMU/swiotlb behind
the DMA MAPPING.
>
> We do not have an existing benchmark case that actually tests the full
> cost of the slow path (i.e full cost of page_pool_alloc from slow path
> with dma-mapping and page_pool_put_page to the slow path with
> dma-unmapping). That test case would have given us the full picture in
> terms of % regression.
>
> This is partly why I want to upstream the benchmark. Such cases can be
> added after it is upstreamed.
Why not add it now when you seemed to be arguing that exercising the code
path of dma_map_page() and dma_unmap_page() may change the full picture
here.
prev parent reply other threads:[~2025-03-27 7:21 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-25 15:45 [PATCH net-next v2 0/3] Fix late DMA unmap crash for page pool Toke Høiland-Jørgensen
2025-03-25 15:45 ` [PATCH net-next v2 1/3] page_pool: Move pp_magic check into helper functions Toke Høiland-Jørgensen
2025-03-25 15:45 ` [PATCH net-next v2 2/3] page_pool: Turn dma_sync and dma_sync_cpu fields into a bitmap Toke Høiland-Jørgensen
2025-03-25 22:17 ` Jakub Kicinski
2025-03-26 8:12 ` Toke Høiland-Jørgensen
2025-03-26 11:23 ` Jakub Kicinski
2025-03-26 11:29 ` Jakub Kicinski
2025-03-26 18:00 ` Saeed Mahameed
2025-03-25 15:45 ` [PATCH net-next v2 3/3] page_pool: Track DMA-mapped pages and unmap them when destroying the pool Toke Høiland-Jørgensen
2025-03-26 13:54 ` Jesper Dangaard Brouer
2025-03-26 18:22 ` Saeed Mahameed
2025-03-26 20:02 ` Mina Almasry
2025-03-27 0:29 ` Saeed Mahameed
2025-03-27 1:37 ` Mina Almasry
2025-03-27 3:53 ` Yunsheng Lin
2025-03-27 4:59 ` Mina Almasry
2025-03-27 7:21 ` Yunsheng Lin [this message]
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=77cd9e2d-da66-4e8f-831d-87915465f98a@huawei.com \
--to=linyunsheng@huawei.com \
--cc=akpm@linux-foundation.org \
--cc=almasrymina@google.com \
--cc=andrew+netdev@lunn.ch \
--cc=asml.silence@gmail.com \
--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=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