From: "Toke Høiland-Jørgensen" <toke@redhat.com>
To: Yunsheng Lin <linyunsheng@huawei.com>,
Yunsheng Lin <yunshenglin0825@gmail.com>,
Andrew Morton <akpm@linux-foundation.org>,
Jesper Dangaard Brouer <hawk@kernel.org>,
Ilias Apalodimas <ilias.apalodimas@linaro.org>,
"David S. Miller" <davem@davemloft.net>
Cc: Yonglong Liu <liuyonglong@huawei.com>,
Mina Almasry <almasrymina@google.com>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Simon Horman <horms@kernel.org>,
linux-mm@kvack.org, netdev@vger.kernel.org
Subject: Re: [RFC PATCH net-next] page_pool: Track DMA-mapped pages and unmap them when destroying the pool
Date: Wed, 12 Mar 2025 13:27:14 +0100 [thread overview]
Message-ID: <871pv2igd9.fsf@toke.dk> (raw)
In-Reply-To: <ae07144c-9295-4c9d-a400-153bb689fe9e@huawei.com>
Yunsheng Lin <linyunsheng@huawei.com> writes:
> On 2025/3/11 21:26, Toke Høiland-Jørgensen wrote:
>> Yunsheng Lin <linyunsheng@huawei.com> writes:
>>
>>> On 2025/3/10 23:24, Toke Høiland-Jørgensen wrote:
>>>
>>>>>
>>>>> I guess that is one of the disadvantages that an advanced struct like
>>>>> Xarray is used:(
>>>>
>>>> Sure, there will be some overhead from using xarray, but I think the
>>>> simplicity makes up for it; especially since we can limit this to the
>>>
>>> As my understanding, it is more complicated, it is just that
>>> complexity is hidden before xarray now.
>>
>> Yes, which encapsulates the complexity into a shared abstraction that is
>> widely used in the kernel, so it does not add new complexity to the
>> kernel as a whole. Whereas your series adds a whole bunch of new
>> complexity to the kernel in the form of a new slab allocator.
>>
>>> Even if there is no space in 'struct page' to store the id, the
>>> 'struct page' pointer itself can be used as id if the xarray can
>>> use pointer as id. But it might mean the memory utilization might
>>> not be as efficient as it should be, and performance hurts too if
>>> there is more memory to be allocated and freed.
>>
>> I don't think it can. But sure, there can be other ways around this.
>>
>> FWIW, I don't think your idea of allocating page_pool_items to use as an
>> indirection is totally crazy, but all the complexity around it (the
>> custom slab allocator etc) is way too much. And if we can avoid the item
>> indirection that is obviously better.
>>
>>> It seems it is just a matter of choices between using tailor-made
>>> page_pool specific optimization and using some generic advanced
>>> struct like xarray.
>>
>> Yup, basically.
>>
>>> I chose the tailor-made one because it ensure least overhead as
>>> much as possibe from performance and memory utilization perspective,
>>> for example, the 'single producer, multiple consumer' guarantee
>>> offered by NAPI context can avoid some lock and atomic operation.
>>
>> Right, and my main point is that the complexity of this is not worth it :)
>
> Without the complexity, there is about 400ns performance overhead
> for Xarray compared to about 10ns performance overhead for the
> tailor-made one, which means there is about more than 200% performance
> degradation for page_pool03_slow test case:
Great, thanks for testing! I will include this in the non-RFC posting of
this series :)
>>>> cases where it's absolutely needed.
>>>
>>> The above can also be done for using page_pool_item too as the
>>> lower 2 bits can be used to indicate the pointer in 'struct page'
>>> is 'page_pool_item' or 'page_pool', I just don't think it is
>>> necessary yet as it might add more checking in the fast path.
>>
>> Yup, did think about using the lower bits to distinguish if it does turn
>> out that we can't avoid an indirection. See above; it's not actually the
>
> The 'memdesc' seems like an indirection to me when using that to shrink
> 'struct page' to a smaller size.
Yes, it does seem like we'll end up with an indirection of some kind
eventually. But let's cross that bridge when we get to it...
-Toke
next prev parent reply other threads:[~2025-03-12 12:27 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-08 14:54 [RFC PATCH net-next] page_pool: Track DMA-mapped pages and unmap them when destroying the pool Toke Høiland-Jørgensen
2025-03-08 19:22 ` Mina Almasry
2025-03-09 12:42 ` Toke Høiland-Jørgensen
2025-03-11 13:25 ` Pavel Begunkov
2025-03-11 13:44 ` Toke Høiland-Jørgensen
2025-03-11 13:56 ` Pavel Begunkov
2025-03-11 15:49 ` Toke Høiland-Jørgensen
2025-03-11 16:46 ` Matthew Wilcox
2025-03-12 10:56 ` Toke Høiland-Jørgensen
2025-03-12 12:55 ` Pavel Begunkov
2025-03-10 7:17 ` Pavel Begunkov
2025-03-09 13:27 ` Yunsheng Lin
2025-03-10 9:13 ` Toke Høiland-Jørgensen
2025-03-10 12:35 ` Yunsheng Lin
2025-03-10 15:24 ` Toke Høiland-Jørgensen
2025-03-11 12:19 ` Yunsheng Lin
2025-03-11 13:26 ` Toke Høiland-Jørgensen
2025-03-12 12:04 ` Yunsheng Lin
2025-03-12 12:27 ` Toke Høiland-Jørgensen [this message]
2025-03-12 12:53 ` Pavel Begunkov
2025-03-10 15:42 ` Matthew Wilcox
2025-03-10 17:26 ` Toke Høiland-Jørgensen
2025-03-11 15:03 ` Matthew Wilcox
2025-03-11 15:32 ` Toke Høiland-Jørgensen
2025-03-11 12:25 ` Yunsheng Lin
2025-03-11 15:11 ` Matthew Wilcox
2025-03-12 12:05 ` Yunsheng Lin
2025-03-12 18:35 ` Shuah
2025-03-12 18:48 ` shuah
2025-03-12 18:56 ` Matthew Wilcox
2025-03-12 22:25 ` Shuah Khan
2025-03-14 18:09 ` Matthew Wilcox
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=871pv2igd9.fsf@toke.dk \
--to=toke@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=almasrymina@google.com \
--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=linux-mm@kvack.org \
--cc=linyunsheng@huawei.com \
--cc=liuyonglong@huawei.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=yunshenglin0825@gmail.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.