From: Yunsheng Lin <linyunsheng@huawei.com>
To: Alexander H Duyck <alexander.duyck@gmail.com>,
<davem@davemloft.net>, <kuba@kernel.org>, <pabeni@redhat.com>
Cc: <netdev@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
Lorenzo Bianconi <lorenzo@kernel.org>,
Jesper Dangaard Brouer <hawk@kernel.org>,
Ilias Apalodimas <ilias.apalodimas@linaro.org>,
Eric Dumazet <edumazet@google.com>
Subject: Re: [PATCH net-next v2 2/3] page_pool: support non-frag page for page_pool_alloc_frag()
Date: Wed, 31 May 2023 20:19:07 +0800 [thread overview]
Message-ID: <2e4f0359-151a-5cff-6d31-0ea0f014ef9a@huawei.com> (raw)
In-Reply-To: <977d55210bfcb4f454b9d740fcbe6c451079a086.camel@gmail.com>
On 2023/5/30 23:07, Alexander H Duyck wrote:
...
>> + if (PAGE_POOL_DMA_USE_PP_FRAG_COUNT) {
>> + *offset = 0;
>> + return page_pool_alloc_pages(pool, gfp);
>> + }
>> +
>
> This is a recipe for pain. Rather than doing this I would say we should
> stick with our existing behavior and not allow page pool fragments to
> be used when the DMA address is consuming the region. Otherwise we are
> going to make things very confusing.
Are there any other concern other than confusing? we could add a
big comment to make it clear.
The point of adding that is to avoid the driver handling the
PAGE_POOL_DMA_USE_PP_FRAG_COUNT when using page_pool_alloc_frag()
like something like below:
if (!PAGE_POOL_DMA_USE_PP_FRAG_COUNT)
page = page_pool_alloc_frag()
else
page = XXXXX;
Or do you perfer the driver handling it? why?
>
> If we have to have both version I would much rather just have some
> inline calls in the header wrapped in one #ifdef for
> PAGE_POOL_DMA_USE_PP_FRAG_COUNT that basically are a wrapper for
> page_pool pages treated as pp_frag.
Do you have a good name in mind for that wrapper.
In addition to the naming, which API should I use when I am a driver
author wanting to add page pool support?
>
>> size = ALIGN(size, dma_get_cache_alignment());
>> - *offset = pool->frag_offset;
>>
>
> If we are going to be allocating mono-frag pages they should be
> allocated here based on the size check. That way we aren't discrupting
> the performance for the smaller fragments and the code below could
> function undisturbed.
It is to allow possible optimization as below.
>
>> - if (page && *offset + size > max_size) {
>> + if (page) {
>> + *offset = pool->frag_offset;
>> +
>> + if (*offset + size <= max_size) {
>> + pool->frag_users++;
>> + pool->frag_offset = *offset + size;
>> + alloc_stat_inc(pool, fast);
>> + return page;
Note that we still allow frag page here when '(size << 1 > max_size)'.
>> + }
>> +
>> + pool->frag_page = NULL;
>> page = page_pool_drain_frag(pool, page);
>> if (page) {
>> alloc_stat_inc(pool, fast);
>> @@ -714,26 +727,24 @@ struct page *page_pool_alloc_frag(struct page_pool *pool,
>> }
>> }
>>
>> - if (!page) {
>> - page = page_pool_alloc_pages(pool, gfp);
>> - if (unlikely(!page)) {
>> - pool->frag_page = NULL;
>> - return NULL;
>> - }
>> -
>> - pool->frag_page = page;
>> + page = page_pool_alloc_pages(pool, gfp);
>> + if (unlikely(!page))
>> + return NULL;
>>
>> frag_reset:
>> - pool->frag_users = 1;
>> + /* return page as non-frag page if a page is not able to
>> + * hold two frags for the current requested size.
>> + */
>
> This statement ins't exactly true since you make all page pool pages
> into fragmented pages.
Any suggestion to describe it more accurately?
I wrote that thinking frag_count being one as non-frag page.
>
>
>> + if (unlikely(size << 1 > max_size)) {
>
> This should happen much sooner so you aren't mixing these allocations
> with the smaller ones and forcing the fragmented page to be evicted.
As mentioned above, it is to allow a possible optimization
next prev parent reply other threads:[~2023-05-31 12:19 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-29 9:28 [PATCH net-next v2 0/3] " Yunsheng Lin
2023-05-29 9:28 ` [PATCH net-next v2 1/3] page_pool: unify frag page and non-frag page handling Yunsheng Lin
2023-05-30 15:07 ` Alexander H Duyck
2023-05-31 11:55 ` Yunsheng Lin
2023-06-02 16:37 ` Alexander H Duyck
2023-06-03 12:59 ` Yunsheng Lin
2023-06-05 14:58 ` Alexander Duyck
2023-06-06 12:41 ` Yunsheng Lin
2023-06-06 15:33 ` Alexander Duyck
2023-06-07 12:46 ` Yunsheng Lin
2023-06-07 15:05 ` Alexander Duyck
2023-05-29 9:28 ` [PATCH net-next v2 2/3] page_pool: support non-frag page for page_pool_alloc_frag() Yunsheng Lin
2023-05-30 15:07 ` Alexander H Duyck
2023-05-31 12:19 ` Yunsheng Lin [this message]
2023-06-01 12:21 ` Yunsheng Lin
2023-06-01 18:14 ` Alexander Duyck
2023-06-02 12:23 ` Yunsheng Lin
2023-06-02 15:57 ` Alexander Duyck
2023-06-03 4:20 ` Yunsheng Lin
2023-06-05 15:08 ` Alexander Duyck
2023-05-29 9:28 ` [PATCH net-next v2 3/3] page_pool: remove PP_FLAG_PAGE_FRAG flag Yunsheng Lin
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=2e4f0359-151a-5cff-6d31-0ea0f014ef9a@huawei.com \
--to=linyunsheng@huawei.com \
--cc=alexander.duyck@gmail.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=hawk@kernel.org \
--cc=ilias.apalodimas@linaro.org \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lorenzo@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@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
all inboxes | Powered by JetHome®