From: Nilay Vaish <nilayvaish@google.com>
To: "Michael S . Tsirkin" <mst@redhat.com>,
Jason Wang <jasowangio@gmail.com>
Cc: "Eugenio Pérez" <eperezma@redhat.com>,
"Xuan Zhuo" <xuanzhuo@linux.alibaba.com>,
"Andrew Lunn" <andrew+netdev@lunn.ch>,
"David S . Miller" <davem@davemloft.net>,
"Eric Dumazet" <edumazet@kernel.org>,
"Jakub Kicinski" <kuba@kernel.org>,
"Paolo Abeni" <pabeni@redhat.com>,
netdev@vger.kernel.org, virtualization@lists.linux.dev,
"Nilay Vaish" <nilayvaish@google.com>
Subject: [PATCH net-next] virtio_net: use page_private() accessors for the big-packets page chain
Date: Mon, 23 Nov 2026 11:22:20 -0800 [thread overview]
Message-ID: <20261123192220.4013325-1-nilayvaish@google.com> (raw)
Big packets mode chains its receive pages through page->private, reading
and writing the field directly.
struct page is being shrunk as part of the memdesc work, and its private
field is one of those that will move. Direct users have to go through
the accessors before that can happen.
Use page_private() and set_page_private() instead, like the rest of the
kernel, so that the driver no longer depends on where struct page keeps
the field.
No functional change.
This patch was written with the help of an AI coding assistant (Gemini).
Signed-off-by: Nilay Vaish <nilayvaish@google.com>
---
drivers/net/virtio_net.c | 18 ++++++++++--------
1 file changed, 10 insertions(+), 8 deletions(-)
diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
index 0988a946ef35..5eef2c315963 100644
--- a/drivers/net/virtio_net.c
+++ b/drivers/net/virtio_net.c
@@ -680,8 +680,10 @@ static void give_pages(struct receive_queue *rq, struct page *page)
struct page *end;
/* Find end of list, sew whole thing into vi->rq.pages. */
- for (end = page; end->private; end = (struct page *)end->private);
- end->private = (unsigned long)rq->pages;
+ for (end = page; page_private(end);
+ end = (struct page *)page_private(end))
+ ;
+ set_page_private(end, (unsigned long)rq->pages);
rq->pages = page;
}
@@ -690,9 +692,9 @@ static struct page *get_a_page(struct receive_queue *rq, gfp_t gfp_mask)
struct page *p = rq->pages;
if (p) {
- rq->pages = (struct page *)p->private;
+ rq->pages = (struct page *)page_private(p);
/* clear private here, it is used to chain pages */
- p->private = 0;
+ set_page_private(p, 0);
} else
p = alloc_page(gfp_mask);
return p;
@@ -881,7 +883,7 @@ static struct sk_buff *page_to_skb(struct virtnet_info *vi,
* Currently, big packets mode doesn't use page pools.
*/
if (!rq->page_pool) {
- page = (struct page *)page->private;
+ page = (struct page *)page_private(page);
if (page)
give_pages(rq, page);
}
@@ -929,7 +931,7 @@ static struct sk_buff *page_to_skb(struct virtnet_info *vi,
skb_add_rx_frag(skb, skb_shinfo(skb)->nr_frags, page, offset,
frag_size, truesize);
len -= frag_size;
- page = (struct page *)page->private;
+ page = (struct page *)page_private(page);
offset = 0;
}
@@ -2705,7 +2707,7 @@ static int add_recvbuf_big(struct virtnet_info *vi, struct receive_queue *rq,
sg_set_buf(&rq->sg[i], page_address(first), PAGE_SIZE);
/* chain new page in list head to match sg */
- first->private = (unsigned long)list;
+ set_page_private(first, (unsigned long)list);
list = first;
}
@@ -2725,7 +2727,7 @@ static int add_recvbuf_big(struct virtnet_info *vi, struct receive_queue *rq,
sg_set_buf(&rq->sg[1], p + offset, PAGE_SIZE - offset);
/* chain first in list head */
- first->private = (unsigned long)list;
+ set_page_private(first, (unsigned long)list);
err = virtqueue_add_inbuf(rq->vq, rq->sg, vi->big_packets_num_skbfrags + 2,
first, gfp);
if (err < 0)
--
2.56.1.839.g22a8290db9-goog
reply other threads:[~2026-11-23 19:22 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20261123192220.4013325-1-nilayvaish@google.com \
--to=nilayvaish@google.com \
--cc=andrew+netdev@lunn.ch \
--cc=davem@davemloft.net \
--cc=edumazet@kernel.org \
--cc=eperezma@redhat.com \
--cc=jasowangio@gmail.com \
--cc=kuba@kernel.org \
--cc=mst@redhat.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.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