* [PATCH net-next v2] virtio_net: Reuse buffer free function
@ 2023-01-16 20:27 Parav Pandit
2023-01-16 22:13 ` Michael S. Tsirkin
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Parav Pandit @ 2023-01-16 20:27 UTC (permalink / raw)
To: mst, jasowang, netdev, davem, kuba
Cc: edumazet, pabeni, virtualization, Parav Pandit, Alexander Duyck,
Xuan Zhuo
virtnet_rq_free_unused_buf() helper function to free the buffer
already exists. Avoid code duplication by reusing existing function.
Reviewed-by: Alexander Duyck <alexanderduyck@fb.com>
Reviewed-by: Xuan Zhuo <xuanzhuo@linux.alibaba.com>
Signed-off-by: Parav Pandit <parav@nvidia.com>
---
drivers/net/virtio_net.c | 8 +-------
1 file changed, 1 insertion(+), 7 deletions(-)
diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
index 7723b2a49d8e..31d037df514f 100644
--- a/drivers/net/virtio_net.c
+++ b/drivers/net/virtio_net.c
@@ -1251,13 +1251,7 @@ static void receive_buf(struct virtnet_info *vi, struct receive_queue *rq,
if (unlikely(len < vi->hdr_len + ETH_HLEN)) {
pr_debug("%s: short packet %i\n", dev->name, len);
dev->stats.rx_length_errors++;
- if (vi->mergeable_rx_bufs) {
- put_page(virt_to_head_page(buf));
- } else if (vi->big_packets) {
- give_pages(rq, buf);
- } else {
- put_page(virt_to_head_page(buf));
- }
+ virtnet_rq_free_unused_buf(rq->vq, buf);
return;
}
--
2.26.2
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH net-next v2] virtio_net: Reuse buffer free function
2023-01-16 20:27 [PATCH net-next v2] virtio_net: Reuse buffer free function Parav Pandit
@ 2023-01-16 22:13 ` Michael S. Tsirkin
2023-01-16 23:37 ` Parav Pandit
2023-01-17 3:06 ` Jason Wang
2023-01-18 14:00 ` patchwork-bot+netdevbpf
2 siblings, 1 reply; 5+ messages in thread
From: Michael S. Tsirkin @ 2023-01-16 22:13 UTC (permalink / raw)
To: Parav Pandit
Cc: jasowang, netdev, davem, kuba, edumazet, pabeni, virtualization,
Alexander Duyck, Xuan Zhuo
On Mon, Jan 16, 2023 at 10:27:08PM +0200, Parav Pandit wrote:
> virtnet_rq_free_unused_buf() helper function to free the buffer
> already exists. Avoid code duplication by reusing existing function.
>
> Reviewed-by: Alexander Duyck <alexanderduyck@fb.com>
> Reviewed-by: Xuan Zhuo <xuanzhuo@linux.alibaba.com>
> Signed-off-by: Parav Pandit <parav@nvidia.com>
> ---
> drivers/net/virtio_net.c | 8 +-------
> 1 file changed, 1 insertion(+), 7 deletions(-)
>
> diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
> index 7723b2a49d8e..31d037df514f 100644
> --- a/drivers/net/virtio_net.c
> +++ b/drivers/net/virtio_net.c
> @@ -1251,13 +1251,7 @@ static void receive_buf(struct virtnet_info *vi, struct receive_queue *rq,
> if (unlikely(len < vi->hdr_len + ETH_HLEN)) {
> pr_debug("%s: short packet %i\n", dev->name, len);
> dev->stats.rx_length_errors++;
> - if (vi->mergeable_rx_bufs) {
> - put_page(virt_to_head_page(buf));
> - } else if (vi->big_packets) {
> - give_pages(rq, buf);
> - } else {
> - put_page(virt_to_head_page(buf));
> - }
> + virtnet_rq_free_unused_buf(rq->vq, buf);
> return;
> }
Sure.
Acked-by: Michael S. Tsirkin <mst@redhat.com>
while we are at it how about a patch moving
virtnet_rq_free_unused_buf and virtnet_sq_free_unused_buf so
we don't need forward declarations?
E.g. a good place for virtnet_sq_free_unused_buf is likely
after ptr_to_xdp group of functions.
For virtnet_rq_free_unused_buf - after give_pages/get_a_page.
>
> --
> 2.26.2
^ permalink raw reply [flat|nested] 5+ messages in thread
* RE: [PATCH net-next v2] virtio_net: Reuse buffer free function
2023-01-16 22:13 ` Michael S. Tsirkin
@ 2023-01-16 23:37 ` Parav Pandit
0 siblings, 0 replies; 5+ messages in thread
From: Parav Pandit @ 2023-01-16 23:37 UTC (permalink / raw)
To: Michael S. Tsirkin
Cc: jasowang, netdev, davem, kuba, edumazet, pabeni, virtualization,
Alexander Duyck, Xuan Zhuo
> From: Michael S. Tsirkin <mst@redhat.com>
> Sent: Monday, January 16, 2023 5:13 PM
>
> On Mon, Jan 16, 2023 at 10:27:08PM +0200, Parav Pandit wrote:
> > virtnet_rq_free_unused_buf() helper function to free the buffer
> > already exists. Avoid code duplication by reusing existing function.
> >
> > Reviewed-by: Alexander Duyck <alexanderduyck@fb.com>
> > Reviewed-by: Xuan Zhuo <xuanzhuo@linux.alibaba.com>
> > Signed-off-by: Parav Pandit <parav@nvidia.com>
> > ---
> > drivers/net/virtio_net.c | 8 +-------
> > 1 file changed, 1 insertion(+), 7 deletions(-)
> >
> > diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c index
> > 7723b2a49d8e..31d037df514f 100644
> > --- a/drivers/net/virtio_net.c
> > +++ b/drivers/net/virtio_net.c
> > @@ -1251,13 +1251,7 @@ static void receive_buf(struct virtnet_info *vi,
> struct receive_queue *rq,
> > if (unlikely(len < vi->hdr_len + ETH_HLEN)) {
> > pr_debug("%s: short packet %i\n", dev->name, len);
> > dev->stats.rx_length_errors++;
> > - if (vi->mergeable_rx_bufs) {
> > - put_page(virt_to_head_page(buf));
> > - } else if (vi->big_packets) {
> > - give_pages(rq, buf);
> > - } else {
> > - put_page(virt_to_head_page(buf));
> > - }
> > + virtnet_rq_free_unused_buf(rq->vq, buf);
> > return;
> > }
>
> Sure.
>
> Acked-by: Michael S. Tsirkin <mst@redhat.com>
>
> while we are at it how about a patch moving virtnet_rq_free_unused_buf and
> virtnet_sq_free_unused_buf so we don't need forward declarations?
>
Yes. its in my list. Will do after this patch.
I am also going to add the comment for the history about not doing ZLEN around this area.
> E.g. a good place for virtnet_sq_free_unused_buf is likely after ptr_to_xdp
> group of functions.
>
> For virtnet_rq_free_unused_buf - after give_pages/get_a_page.
>
> >
> > --
> > 2.26.2
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH net-next v2] virtio_net: Reuse buffer free function
2023-01-16 20:27 [PATCH net-next v2] virtio_net: Reuse buffer free function Parav Pandit
2023-01-16 22:13 ` Michael S. Tsirkin
@ 2023-01-17 3:06 ` Jason Wang
2023-01-18 14:00 ` patchwork-bot+netdevbpf
2 siblings, 0 replies; 5+ messages in thread
From: Jason Wang @ 2023-01-17 3:06 UTC (permalink / raw)
To: Parav Pandit
Cc: mst, netdev, davem, kuba, edumazet, pabeni, virtualization,
Alexander Duyck, Xuan Zhuo
On Tue, Jan 17, 2023 at 4:27 AM Parav Pandit <parav@nvidia.com> wrote:
>
> virtnet_rq_free_unused_buf() helper function to free the buffer
> already exists. Avoid code duplication by reusing existing function.
>
> Reviewed-by: Alexander Duyck <alexanderduyck@fb.com>
> Reviewed-by: Xuan Zhuo <xuanzhuo@linux.alibaba.com>
> Signed-off-by: Parav Pandit <parav@nvidia.com>
Acked-by: Jason Wang <jasowang@redhat.com>
Thanks
> ---
> drivers/net/virtio_net.c | 8 +-------
> 1 file changed, 1 insertion(+), 7 deletions(-)
>
> diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
> index 7723b2a49d8e..31d037df514f 100644
> --- a/drivers/net/virtio_net.c
> +++ b/drivers/net/virtio_net.c
> @@ -1251,13 +1251,7 @@ static void receive_buf(struct virtnet_info *vi, struct receive_queue *rq,
> if (unlikely(len < vi->hdr_len + ETH_HLEN)) {
> pr_debug("%s: short packet %i\n", dev->name, len);
> dev->stats.rx_length_errors++;
> - if (vi->mergeable_rx_bufs) {
> - put_page(virt_to_head_page(buf));
> - } else if (vi->big_packets) {
> - give_pages(rq, buf);
> - } else {
> - put_page(virt_to_head_page(buf));
> - }
> + virtnet_rq_free_unused_buf(rq->vq, buf);
> return;
> }
>
> --
> 2.26.2
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH net-next v2] virtio_net: Reuse buffer free function
2023-01-16 20:27 [PATCH net-next v2] virtio_net: Reuse buffer free function Parav Pandit
2023-01-16 22:13 ` Michael S. Tsirkin
2023-01-17 3:06 ` Jason Wang
@ 2023-01-18 14:00 ` patchwork-bot+netdevbpf
2 siblings, 0 replies; 5+ messages in thread
From: patchwork-bot+netdevbpf @ 2023-01-18 14:00 UTC (permalink / raw)
To: Parav Pandit
Cc: mst, jasowang, netdev, davem, kuba, edumazet, pabeni,
virtualization, alexanderduyck, xuanzhuo
Hello:
This patch was applied to netdev/net-next.git (master)
by David S. Miller <davem@davemloft.net>:
On Mon, 16 Jan 2023 22:27:08 +0200 you wrote:
> virtnet_rq_free_unused_buf() helper function to free the buffer
> already exists. Avoid code duplication by reusing existing function.
>
> Reviewed-by: Alexander Duyck <alexanderduyck@fb.com>
> Reviewed-by: Xuan Zhuo <xuanzhuo@linux.alibaba.com>
> Signed-off-by: Parav Pandit <parav@nvidia.com>
>
> [...]
Here is the summary with links:
- [net-next,v2] virtio_net: Reuse buffer free function
https://git.kernel.org/netdev/net-next/c/eb1d929f1551
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2023-01-18 14:19 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-16 20:27 [PATCH net-next v2] virtio_net: Reuse buffer free function Parav Pandit
2023-01-16 22:13 ` Michael S. Tsirkin
2023-01-16 23:37 ` Parav Pandit
2023-01-17 3:06 ` Jason Wang
2023-01-18 14:00 ` patchwork-bot+netdevbpf
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).