From: Bui Quang Minh <minhquangbui99@gmail.com>
To: Jakub Kicinski <kuba@kernel.org>
Cc: "Paolo Abeni" <pabeni@redhat.com>,
netdev@vger.kernel.org, "Michael S. Tsirkin" <mst@redhat.com>,
"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>,
"Alexei Starovoitov" <ast@kernel.org>,
"Daniel Borkmann" <daniel@iogearbox.net>,
"Jesper Dangaard Brouer" <hawk@kernel.org>,
"John Fastabend" <john.fastabend@gmail.com>,
virtualization@lists.linux.dev, linux-kernel@vger.kernel.org,
bpf@vger.kernel.org, stable@vger.kernel.org
Subject: Re: [PATCH net] virtio-net: drop the multi-buffer XDP packet in zerocopy
Date: Fri, 13 Jun 2025 22:58:38 +0700 [thread overview]
Message-ID: <9dd17a20-b5b8-4385-9a61-d9647da337a9@gmail.com> (raw)
In-Reply-To: <20250610133750.7c43e634@kernel.org>
On 6/11/25 03:37, Jakub Kicinski wrote:
> On Tue, 10 Jun 2025 22:18:32 +0700 Bui Quang Minh wrote:
>>>> Furthermore, we are in the zerocopy so we cannot linearize by
>>>> allocating a large enough buffer to cover the whole frame then copy the
>>>> frame data to it. That's not zerocopy anymore. Also, XDP socket zerocopy
>>>> receive has assumption that the packet it receives must from the umem
>>>> pool. AFAIK, the generic XDP path is for copy mode only.
>>> Generic XDP == do_xdp_generic(), here I think you mean the normal XDP
>>> patch in the virtio driver? If so then no, XDP is very much not
>>> expected to copy each frame before processing.
>> Yes, I mean generic XDP = do_xdp_generic(). I mean that we can linearize
>> the frame if needed (like in netif_skb_check_for_xdp()) in copy mode for
>> XDP socket but not in zerocopy mode.
> Okay, I meant the copies in the driver - virtio calls
> xdp_linearize_page() in a few places, for normal XDP.
>
>>> This is only slightly related to you patch but while we talk about
>>> multi-buf - in the netdev CI the test which sends ping while XDP
>>> multi-buf program is attached is really flaky :(
>>> https://netdev.bots.linux.dev/contest.html?executor=vmksft-drv-hw&test=ping-py.ping-test-xdp-native-mb&ld-cases=1
>> metal-drv-hw means the NETIF is the real NIC, right?
> The "metal" in the name refers to the AWS instance type that hosts
> the runner. The test runs in a VM over virtio, more details:
> https://github.com/linux-netdev/nipa/wiki/Running-driver-tests-on-virtio
I've figured out the problem. When the test fails, in mergeable_xdp_get_buf
xdp_room = SKB_DATA_ALIGN(XDP_PACKET_HEADROOM +
sizeof(struct skb_shared_info));
if (*len + xdp_room > PAGE_SIZE)
return NULL;
*len + xdp_room > PAGE_SIZE and NULL is returned, so the packet is
dropped. This case happens when add_recvbuf_mergeable is called when XDP
program is not loaded, so it does not reserve space for
XDP_PACKET_HEADROOM and struct skb_shared_info. But when the vhost uses
that buffer and send back to virtio-net, XDP program is loaded. The code
has the assumption that XDP frag cannot exceed PAGE_SIZE which I think
is not correct anymore. Due to that assumption, when the frame data +
XDP_PACKET_HEADROOM + sizeof(struct skb_shared_info) > PAGE_SIZE, the
code does not build xdp_buff but drops the frame. xdp_linearize_page has
the same assumption. As I don't think the assumption is correct anymore,
the fix might be allocating a big enough buffer to build xdp_buff.
Thanks,
Quang Minh.
next prev parent reply other threads:[~2025-06-13 15:58 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-03 15:06 [PATCH net] virtio-net: drop the multi-buffer XDP packet in zerocopy Bui Quang Minh
2025-06-04 0:37 ` Jason Wang
2025-06-04 14:17 ` Bui Quang Minh
2025-06-05 0:46 ` Jason Wang
2025-06-04 16:55 ` Zvi Effron
2025-06-05 14:25 ` Bui Quang Minh
2025-06-05 11:03 ` Paolo Abeni
2025-06-05 14:33 ` Bui Quang Minh
2025-06-05 14:48 ` Jakub Kicinski
2025-06-06 15:48 ` Bui Quang Minh
2025-06-09 16:58 ` Jakub Kicinski
2025-06-10 15:18 ` Bui Quang Minh
2025-06-10 20:37 ` Jakub Kicinski
2025-06-13 15:58 ` Bui Quang Minh [this message]
2025-06-13 1:51 ` Xuan Zhuo
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=9dd17a20-b5b8-4385-9a61-d9647da337a9@gmail.com \
--to=minhquangbui99@gmail.com \
--cc=andrew+netdev@lunn.ch \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=eperezma@redhat.com \
--cc=hawk@kernel.org \
--cc=jasowang@redhat.com \
--cc=john.fastabend@gmail.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=stable@vger.kernel.org \
--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