From: Yunsheng Lin <linyunsheng@huawei.com>
To: Ilias Apalodimas <ilias.apalodimas@linaro.org>
Cc: Furong Xu <0x1207@gmail.com>, <netdev@vger.kernel.org>,
<linux-kernel@vger.kernel.org>,
Jesper Dangaard Brouer <hawk@kernel.org>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
<xfr@outlook.com>
Subject: Re: [PATCH net-next v1] page_pool: check for dma_sync_size earlier
Date: Tue, 15 Oct 2024 19:06:03 +0800 [thread overview]
Message-ID: <625cdab0-7348-41a1-b07f-6e5fe7962eec@huawei.com> (raw)
In-Reply-To: <CAC_iWjKWjRbhfHz4CJbq-SXEd=rDJP+Go0bfLQ4pMxFNNuPXNQ@mail.gmail.com>
On 2024/10/15 15:43, Ilias Apalodimas wrote:
> Hi Yunsheng,
>
> On Mon, 14 Oct 2024 at 15:39, Yunsheng Lin <linyunsheng@huawei.com> wrote:
>>
>> On 2024/10/14 14:35, Furong Xu wrote:
>>> Hi Yunsheng,
>>>
>>> On Sat, 12 Oct 2024 14:14:41 +0800, Yunsheng Lin <linyunsheng@huawei.com> wrote:
>>>
>>>> I would prefer to add a new api to do that, as it makes the semantic
>>>> more obvious and may enable removing some checking in the future.
>>>>
>>>> And we may need to disable this 'feature' for frag relate API for now,
>>>> as currently there may be multi callings to page_pool_put_netmem() for
>>>> the same page, and dma_sync is only done for the last one, which means
>>>> it might cause some problem for those usecases when using frag API.
>>>
>>> I am not an expert on page_pool.
>>> So would you mind sending a new patch to add a non-dma-sync version of
>>> page_pool_put_page() and CC it to me?
>>
>> As I have at least two patchsets pending for the net-next, which seems
>> it might take a while, so it might take a while for me to send another
>> new patch.
>>
>> Perhaps just add something like page_pool_put_page_nosync() as
>> page_pool_put_full_page() does for the case of dma_sync_size being
>> -1? and leave removing of extra checking as later refactoring and
>> optimization.
>>
>> As for the frag related API like page_pool_alloc_frag() and
>> page_pool_alloc(), we don't really have a corresponding free side
>> API for them, instead we reuse page_pool_put_page() for the free
>> side, and don't really do any dma sync unless it is the last frag
>> user of the same page, see the page_pool_is_last_ref() checking in
>> page_pool_put_netmem().
>>
>> So it might require more refactoring to support the usecase of
>> this patch for frag API, for example we might need to pull the
>> dma_sync operation out of __page_pool_put_page(), and put it in
>> page_pool_put_netmem() so that dma_sync is also done for the
>> non-last frag user too.
>> Or not support it for frag API for now as stmmac driver does not
>> seem to be using frag API, and put a warning to catch the case of
>> misusing of the 'feature' for frag API in the 'if' checking in
>> page_pool_put_netmem() before returning? something like below:
>>
>> --- a/include/net/page_pool/helpers.h
>> +++ b/include/net/page_pool/helpers.h
>> @@ -317,8 +317,10 @@ static inline void page_pool_put_netmem(struct page_pool *pool,
>> * allow registering MEM_TYPE_PAGE_POOL, but shield linker.
>> */
>> #ifdef CONFIG_PAGE_POOL
>> - if (!page_pool_is_last_ref(netmem))
>> + if (!page_pool_is_last_ref(netmem)) {
>> + /* Big comment why frag API is not support yet */
>> + DEBUG_NET_WARN_ON_ONCE(!dma_sync_size);
Note, the above checking is not 100% reliable, as which frag user
is the last one depending on runtime excution.
>
> Ok, since we do have a page_pool_put_full_page(), adding a variant for
> the nosync seems reasonable.
> But can't the check above be part of that function instead of the core code?
I was thinking about something like below mirroring page_pool_put_full_page()
for simplicity:
static inline void page_pool_put_page_nosync(struct page_pool *pool,
struct page *page, bool allow_direct)
{
page_pool_put_netmem(pool, page_to_netmem(page), 0, allow_direct);
}
And do the dma_sync_size checking as this patch does in
page_pool_dma_sync_for_device().
next prev parent reply other threads:[~2024-10-15 11:06 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-10 11:40 Furong Xu
2024-10-10 11:53 ` Yunsheng Lin
2024-10-11 2:14 ` Furong Xu
2024-10-11 5:06 ` Ilias Apalodimas
2024-10-11 6:31 ` Furong Xu
2024-10-11 8:55 ` Yunsheng Lin
2024-10-11 9:26 ` Furong Xu
2024-10-11 15:49 ` Jakub Kicinski
2024-10-11 12:13 ` Ilias Apalodimas
2024-10-12 6:14 ` Yunsheng Lin
2024-10-14 6:35 ` Furong Xu
2024-10-14 12:38 ` Yunsheng Lin
2024-10-15 7:43 ` Ilias Apalodimas
2024-10-15 11:06 ` Yunsheng Lin [this message]
2024-10-15 13:25 ` Ilias Apalodimas
2024-10-16 2:32 ` Furong Xu
2024-10-16 9:09 ` 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=625cdab0-7348-41a1-b07f-6e5fe7962eec@huawei.com \
--to=linyunsheng@huawei.com \
--cc=0x1207@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=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=xfr@outlook.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®