From: Yunsheng Lin <yunshenglin0825@gmail.com>
To: Jesper Dangaard Brouer <hawk@kernel.org>,
Yunsheng Lin <linyunsheng@huawei.com>,
davem@davemloft.net, kuba@kernel.org, pabeni@redhat.com
Cc: zhangkun09@huawei.com, liuyonglong@huawei.com,
fanghaiqing@huawei.com, Robin Murphy <robin.murphy@arm.com>,
Alexander Duyck <alexander.duyck@gmail.com>,
IOMMU <iommu@lists.linux.dev>,
Andrew Morton <akpm@linux-foundation.org>,
Eric Dumazet <edumazet@google.com>,
Simon Horman <horms@kernel.org>,
Ilias Apalodimas <ilias.apalodimas@linaro.org>,
linux-mm@kvack.org, linux-kernel@vger.kernel.org,
netdev@vger.kernel.org, kernel-team <kernel-team@cloudflare.com>
Subject: Re: [PATCH net-next v7 3/8] page_pool: fix IOMMU crash when driver has already unbound
Date: Sat, 18 Jan 2025 21:36:52 +0800 [thread overview]
Message-ID: <3795e5e1-8a6a-4ee3-9778-1828ac5b2748@gmail.com> (raw)
In-Reply-To: <eb2381d2-34a4-4915-b0b5-b07cc81646d3@kernel.org>
On 1/18/2025 12:56 AM, Jesper Dangaard Brouer wrote:
...
>> I am not really sure about that, as using the PAGE_SIZE block to hold the
>> item seems like a implementation detail, which might change in the
>> future,
>> renaming other function to something like that doesn't seem right to
>> me IMHO.
>>
>> Also the next patch will add page_pool_item_blk_add() to support
>> unlimited
>> inflight pages, it seems a better name is needed for that too, perheps
>> rename
>> page_pool_item_blk_add() to page_pool_dynamic_item_add()?
>>
>
> Hmmm... not sure about this.
> I think I prefer page_pool_item_blk_add() over
> page_pool_dynamic_item_add().
>
>> For __page_pool_item_init(), perhaps just inline it back to
>> page_pool_item_init()
>> as __page_pool_item_init() is only used by page_pool_item_init(), and
>> both of them
>> are not really large function.
>
> I like that you had a helper function. So, don't merge
> __page_pool_item_init() into page_pool_item_init() just to avoid naming
> it differently.
Any particular reason for the above suggestion?
After reusing the page_pool_item_uninit() to fix the similar
use-after-freed problem,it seems reasonable to not expose the
item_blcok as much as possible as item_blcok is really an
implementation detail that should be hidden as much as possible
IMHO.
If it is able to reused for supporting the unlimited item case,
then I am agreed that it might be better to refactor it out,
but it is not really reusable.
static int page_pool_item_init(struct page_pool *pool)
{
#define PAGE_POOL_MIN_INFLIGHT_ITEMS 512
struct page_pool_item_block *block;
int item_cnt;
INIT_LIST_HEAD(&pool->item_blocks);
init_llist_head(&pool->hold_items);
init_llist_head(&pool->release_items);
item_cnt = pool->p.pool_size * 2 + PP_ALLOC_CACHE_SIZE +
PAGE_POOL_MIN_INFLIGHT_ITEMS;
for (; item_cnt > 0; item_cnt -= ITEMS_PER_PAGE) {
struct page *page;
unsigned int i;
page = alloc_pages_node(pool->p.nid, GFP_KERNEL, 0);
if (!page) {
page_pool_item_uninit(pool);
return -ENOMEM;
}
block = page_address(page);
block->pp = pool;
list_add(&block->list, &pool->item_blocks);
for (i = 0; i < ITEMS_PER_PAGE; i++) {
page_pool_item_init_state(&block->items[i]);
__llist_add(&block->items[i].lentry,
&pool->hold_items);
}
}
return 0;
}
>
> Let me be more explicit what I'm asking for:
>
> IMHO you should rename:
> - __page_pool_item_init() to __page_pool_item_block_init()
> and rename:
> - page_pool_item_init() to page_pool_item_block_init()
>
> I hope this make it more clear what I'm saying.
> > --Jesper
>
next prev parent reply other threads:[~2025-01-18 13:37 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-10 13:06 [PATCH net-next v7 0/8] fix two bugs related to page_pool Yunsheng Lin
2025-01-10 13:06 ` [PATCH net-next v7 1/8] page_pool: introduce page_pool_get_pp() API Yunsheng Lin
2025-01-10 13:06 ` [PATCH net-next v7 2/8] page_pool: fix timing for checking and disabling napi_local Yunsheng Lin
2025-01-10 15:40 ` Toke Høiland-Jørgensen
2025-01-11 5:24 ` Yunsheng Lin
2025-01-14 13:03 ` Yunsheng Lin
2025-01-20 11:24 ` Toke Høiland-Jørgensen
2025-01-22 11:02 ` Yunsheng Lin
2025-01-24 17:13 ` Toke Høiland-Jørgensen
2025-01-25 14:21 ` Yunsheng Lin
2025-01-27 13:47 ` Toke Høiland-Jørgensen
2025-02-04 13:51 ` Yunsheng Lin
2025-01-10 13:06 ` [PATCH net-next v7 3/8] page_pool: fix IOMMU crash when driver has already unbound Yunsheng Lin
2025-01-15 16:29 ` Jesper Dangaard Brouer
2025-01-16 12:52 ` Yunsheng Lin
2025-01-16 16:09 ` Jesper Dangaard Brouer
2025-01-17 11:56 ` Yunsheng Lin
2025-01-17 16:56 ` Jesper Dangaard Brouer
2025-01-18 13:36 ` Yunsheng Lin [this message]
2025-01-10 13:06 ` [PATCH net-next v7 4/8] page_pool: support unlimited number of inflight pages Yunsheng Lin
2025-01-10 13:06 ` [PATCH net-next v7 5/8] page_pool: skip dma sync operation for " Yunsheng Lin
2025-01-10 13:07 ` [PATCH net-next v7 6/8] page_pool: use list instead of ptr_ring for ring cache Yunsheng Lin
2025-01-10 13:07 ` [PATCH net-next v7 7/8] page_pool: batch refilling pages to reduce atomic operation Yunsheng Lin
2025-01-10 13:07 ` [PATCH net-next v7 8/8] page_pool: use list instead of array for alloc cache Yunsheng Lin
2025-01-14 14:31 ` [PATCH net-next v7 0/8] fix two bugs related to page_pool Jesper Dangaard Brouer
2025-01-15 11:33 ` Yunsheng Lin
2025-01-15 17:40 ` Jesper Dangaard Brouer
2025-01-16 12:52 ` Yunsheng Lin
2025-01-16 18:02 ` Jesper Dangaard Brouer
2025-01-17 11:35 ` Yunsheng Lin
2025-01-18 8:04 ` Jesper Dangaard Brouer
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=3795e5e1-8a6a-4ee3-9778-1828ac5b2748@gmail.com \
--to=yunshenglin0825@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=alexander.duyck@gmail.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=fanghaiqing@huawei.com \
--cc=hawk@kernel.org \
--cc=horms@kernel.org \
--cc=ilias.apalodimas@linaro.org \
--cc=iommu@lists.linux.dev \
--cc=kernel-team@cloudflare.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.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=robin.murphy@arm.com \
--cc=zhangkun09@huawei.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
Powered by JetHome