virtio_net: use page_private() accessors for the big-packets page chain
Subsystems (4)
PATCH 1/1 virtio_net: use page_private() accessors for the big-packets page chain
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).
--- drivers/net/virtio_net.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-)
drivers/net/virtio_net.c +10 -8
@@ -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 )
Signature · 1 line
2.56.1.839.g22a8290db9-goog
[email protected]
AI reviewSashiko has reviewed this patch and found no issues.
Quoted 11 lines
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()andset_page_private()instead, like the rest of the kernel, so that the driver no longer depends on where struct page keeps the field.
Quoted 5 lines
No functional change.
This patch was written with the help of an AI coding assistant (Gemini).
Signed-off-by Nilay Vaish <[email protected]>
Sashiko has reviewed this patch and found no issues.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1