Skip to content

Commit 4be2193

Browse files
minhbq-99Paolo Abeni
authored andcommitted
virtio-net: remove redundant truesize check with PAGE_SIZE
The truesize is guaranteed not to exceed PAGE_SIZE in get_mergeable_buf_len(). It is saved in mergeable context, which is not changeable by the host side, so the check in receive path is quite redundant. Acked-by: Jason Wang <jasowang@redhat.com> Signed-off-by: Bui Quang Minh <minhquangbui99@gmail.com> Link: https://patch.msgid.link/20250630144212.48471-3-minhquangbui99@gmail.com Signed-off-by: Paolo Abeni <pabeni@redhat.com>
1 parent 315dbdd commit 4be2193

1 file changed

Lines changed: 3 additions & 4 deletions

File tree

drivers/net/virtio_net.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2157,9 +2157,9 @@ static int virtnet_build_xdp_buff_mrg(struct net_device *dev,
21572157
{
21582158
struct virtio_net_hdr_mrg_rxbuf *hdr = buf;
21592159
unsigned int headroom, tailroom, room;
2160-
unsigned int truesize, cur_frag_size;
21612160
struct skb_shared_info *shinfo;
21622161
unsigned int xdp_frags_truesz = 0;
2162+
unsigned int truesize;
21632163
struct page *page;
21642164
skb_frag_t *frag;
21652165
int offset;
@@ -2207,9 +2207,8 @@ static int virtnet_build_xdp_buff_mrg(struct net_device *dev,
22072207
tailroom = headroom ? sizeof(struct skb_shared_info) : 0;
22082208
room = SKB_DATA_ALIGN(headroom + tailroom);
22092209

2210-
cur_frag_size = truesize;
2211-
xdp_frags_truesz += cur_frag_size;
2212-
if (unlikely(len > truesize - room || cur_frag_size > PAGE_SIZE)) {
2210+
xdp_frags_truesz += truesize;
2211+
if (unlikely(len > truesize - room)) {
22132212
put_page(page);
22142213
pr_debug("%s: rx error: len %u exceeds truesize %lu\n",
22152214
dev->name, len, (unsigned long)(truesize - room));

0 commit comments

Comments
 (0)