From: Vishwanath Seshagiri <vishs@meta.com>
To: "Michael S. Tsirkin" <mst@redhat.com>
Cc: "Jason Wang" <jasowang@redhat.com>,
"Xuan Zhuo" <xuanzhuo@linux.alibaba.com>,
"Eugenio Pérez" <eperezma@redhat.com>,
"Andrew Lunn" <andrew+netdev@lunn.ch>,
"David S . Miller" <davem@davemloft.net>,
"Eric Dumazet" <edumazet@google.com>,
"Jakub Kicinski" <kuba@kernel.org>,
"Paolo Abeni" <pabeni@redhat.com>, "David Wei" <dw@davidwei.uk>,
"Matteo Croce" <technoboy85@gmail.com>,
"Ilias Apalodimas" <ilias.apalodimas@linaro.org>,
netdev@vger.kernel.org, virtualization@lists.linux.dev,
linux-kernel@vger.kernel.org, kernel-team@meta.com
Subject: Re: [PATCH net-next v9] virtio_net: add page_pool support for buffer allocation
Date: Mon, 2 Mar 2026 16:15:55 +0530 [thread overview]
Message-ID: <3efbd98e-95df-4c18-88d7-78b7f7cb1648@meta.com> (raw)
In-Reply-To: <20260302050013-mutt-send-email-mst@kernel.org>
On 3/2/26 3:57 PM, Michael S. Tsirkin wrote:
>> @@ -2666,32 +2603,25 @@ static void receive_buf(struct virtnet_info *vi, struct receive_queue *rq,
>> static int add_recvbuf_small(struct virtnet_info *vi, struct receive_queue *rq,
>> gfp_t gfp)
>> {
>> - char *buf;
>> unsigned int xdp_headroom = virtnet_get_headroom(vi);
>> void *ctx = (void *)(unsigned long)xdp_headroom;
>> - int len = vi->hdr_len + VIRTNET_RX_PAD + GOOD_PACKET_LEN + xdp_headroom;
>> + unsigned int len = vi->hdr_len + VIRTNET_RX_PAD + GOOD_PACKET_LEN + xdp_headroom;
>> + char *buf;
>> int err;
>>
>> len = SKB_DATA_ALIGN(len) +
>> SKB_DATA_ALIGN(sizeof(struct skb_shared_info));
>>
>> - if (unlikely(!skb_page_frag_refill(len, &rq->alloc_frag, gfp)))
>> - return -ENOMEM;
>> -
>> - buf = virtnet_rq_alloc(rq, len, gfp);
>> + buf = page_pool_alloc_va(rq->page_pool, &len, gfp);
>
> So this can increase len (for end of page accounting).
>
>> if (unlikely(!buf))
>> return -ENOMEM;
>>
>> buf += VIRTNET_RX_PAD + xdp_headroom;
>>
>> - virtnet_rq_init_one_sg(rq, buf, vi->hdr_len + GOOD_PACKET_LEN);
>> -
>> - err = virtqueue_add_inbuf_premapped(rq->vq, rq->sg, 1, buf, ctx, gfp);
>> - if (err < 0) {
>> - virtnet_rq_unmap(rq, buf, 0);
>> - put_page(virt_to_head_page(buf));
>> - }
>> + err = virtnet_rq_submit(rq, buf, vi->hdr_len + GOOD_PACKET_LEN, ctx, gfp);
>>
>> + if (err < 0)
>> + page_pool_put_page(rq->page_pool, virt_to_head_page(buf), -1, false);
>> return err;
>
>
> But len is ignored in the rest of the function.
> Will this not under-account truesize?
>
>
> If it's intentional maybe add a comment explaining why?
It isn't intentional. I will add a separate alloc_len variable for the
page_pool_alloc_va() in v10.
>
>> }
>>
prev parent reply other threads:[~2026-03-02 10:46 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-02 4:10 [PATCH net-next v9] virtio_net: add page_pool support for buffer allocation Vishwanath Seshagiri
2026-03-02 10:27 ` Michael S. Tsirkin
2026-03-02 10:45 ` Vishwanath Seshagiri [this message]
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=3efbd98e-95df-4c18-88d7-78b7f7cb1648@meta.com \
--to=vishs@meta.com \
--cc=andrew+netdev@lunn.ch \
--cc=davem@davemloft.net \
--cc=dw@davidwei.uk \
--cc=edumazet@google.com \
--cc=eperezma@redhat.com \
--cc=ilias.apalodimas@linaro.org \
--cc=jasowang@redhat.com \
--cc=kernel-team@meta.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mst@redhat.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=technoboy85@gmail.com \
--cc=virtualization@lists.linux.dev \
--cc=xuanzhuo@linux.alibaba.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