RE: [PATCH V3,net-next, 3/4] net: mana: Enable RX path to handle various MTU sizes

Haiyang Zhang
2023-04-15T14:25:37Z

> -----Original Message-----
> From: Jakub Kicinski <kuba@kernel.org>
> Sent: Friday, April 14, 2023 10:06 PM
> To: Haiyang Zhang <haiyangz@microsoft.com>
> Cc: linux-hyperv@vger.kernel.org; netdev@vger.kernel.org; Dexuan Cui
> <decui@microsoft.com>; KY Srinivasan <kys@microsoft.com>; Paul Rosswurm
> <paulros@microsoft.com>; olaf@aepfle.de; vkuznets@redhat.com;
> davem@davemloft.net; wei.liu@kernel.org; edumazet@google.com;
> pabeni@redhat.com; leon@kernel.org; Long Li <longli@microsoft.com>;
> ssengar@linux.microsoft.com; linux-rdma@vger.kernel.org;
> daniel@iogearbox.net; john.fastabend@gmail.com; bpf@vger.kernel.org;
> ast@kernel.org; Ajay Sharma <sharmaajay@microsoft.com>;
> hawk@kernel.org; linux-kernel@vger.kernel.org
> Subject: Re: [PATCH V3,net-next, 3/4] net: mana: Enable RX path to handle
> various MTU sizes
>
> On Wed, 12 Apr 2023 14:16:02 -0700 Haiyang Zhang wrote:
> > + } else if (rxq->alloc_size > PAGE_SIZE) {
> > + if (is_napi)
> > + va = napi_alloc_frag(rxq->alloc_size);
>
> Allocating frag larger than a page is not safe.

I saw other drivers doing this - use napi_alloc_frag for size bigger than a page.
And it returns compound page. Why it's not safe? Should we use other allocator
when need compound pages?

> Frag allocator falls back to allocating single pages, doesn't it?

Actually I checked it. Compound page is still returned for size smaller than PAGE_SIZE,
so I used single page allocation for that.

Thanks,
- Haiyang