Re: [PATCH RFC net-next v4 6/9] iavf: switch to Page Pool

From: Yunsheng Lin
Date: Tue Jul 11 2023 - 07:47:59 EST


On 2023/7/10 21:34, Alexander Lobakin wrote:
> From: Yunsheng Lin <yunshenglin0825@xxxxxxxxx>
> Date: Sun, 9 Jul 2023 13:16:39 +0800
>
>> On 2023/7/7 0:38, Alexander Lobakin wrote:
>>
>> ...
>>
>>>>
>>>>> /**
>>>>> @@ -766,13 +742,19 @@ void iavf_free_rx_resources(struct iavf_ring *rx_ring)
>>>>> **/
>>>>> int iavf_setup_rx_descriptors(struct iavf_ring *rx_ring)
>>>>> {
>>>>> - struct device *dev = rx_ring->dev;
>>>>> - int bi_size;
>>>>> + struct page_pool *pool;
>>>>> +
>>>>> + pool = libie_rx_page_pool_create(&rx_ring->q_vector->napi,
>>>>> + rx_ring->count);
>>>>
>>>> If a page is able to be spilt between more than one desc, perhaps the
>>>> prt_ring size does not need to be as big as rx_ring->count.
>>>
>>> But we doesn't know in advance, right? Esp. given that it's hidden in
>>> the lib. But anyway, you can only assume that in regular cases if you
>>> always allocate frags of the same size, PP will split pages when 2+
>>> frags can fit there or return the whole page otherwise, but who knows
>>> what might happen.
>>
>> It seems intel driver is able to know the size of memory it needs when
>> creating the ring/queue/napi/pp, maybe the driver only tell the libie
>> how many descs does it use for queue, and libie can adjust it accordingly?
>
> But libie can't say for sure how PP will split pages for it, right?
>
>>
>>> BTW, with recent recycling optimization, most of recycling is done
>>> directly through cache, not ptr_ring. So I'd even say it's safe to start
>>> creating smaller ptr_rings in the drivers.
>>
>> The problem is that we may use more memory than before for certain case
>> if we don't limit the size of ptr_ring, unless we can ensure all of
>> recycling is done directly through cache, not ptr_ring.
> Also not sure I'm following =\

Before adding page pool support, the max memory used in the driver is as
below:
rx_ring->count * PAGE_SIZE;

After adding page pool support, the max memory used in the driver is as
below:

ptr_ring->size * PAGE_SIZE +
PP_ALLOC_CACHE_SIZE * PAGE_SIZE +
rx_ring->count * PAGE_SIZE / pp.init_arg

>
> [...]
>
> Thanks,
> Olek
>
> .
>