From: Rusty Russell <rusty@rustcorp.com.au>
To: Sasha Levin <sasha.levin@oracle.com>, mst@redhat.com
Cc: penberg@kernel.org, will.deacon@arm.com, marc.zyngier@arm.com,
kvm@vger.kernel.org, asias@redhat.com, jasowang@redhat.com,
Sasha Levin <sasha.levin@oracle.com>
Subject: Re: [PATCH v2] virtio-net: fill only rx queues which are being used
Date: Mon, 29 Apr 2013 12:00:31 +0930 [thread overview]
Message-ID: <87vc76cblk.fsf@rustcorp.com.au> (raw)
In-Reply-To: <1366733864-32297-1-git-send-email-sasha.levin@oracle.com>
Sasha Levin <sasha.levin@oracle.com> writes:
> Due to MQ support we may allocate a whole bunch of rx queues but
> never use them. With this patch we'll safe the space used by
> the receive buffers until they are actually in use:
Thanks, applied!
Cheers,
Rusty.
>
> sh-4.2# free -h
> total used free shared buffers cached
> Mem: 490M 35M 455M 0B 0B 4.1M
> -/+ buffers/cache: 31M 459M
> Swap: 0B 0B 0B
> sh-4.2# ethtool -L eth0 combined 8
> sh-4.2# free -h
> total used free shared buffers cached
> Mem: 490M 162M 327M 0B 0B 4.1M
> -/+ buffers/cache: 158M 331M
> Swap: 0B 0B 0B
>
> Signed-off-by: Sasha Levin <sasha.levin@oracle.com>
> ---
> drivers/net/virtio_net.c | 15 ++++++++++-----
> 1 file changed, 10 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
> index 6bfc511..196e721 100644
> --- a/drivers/net/virtio_net.c
> +++ b/drivers/net/virtio_net.c
> @@ -581,7 +581,7 @@ static void refill_work(struct work_struct *work)
> bool still_empty;
> int i;
>
> - for (i = 0; i < vi->max_queue_pairs; i++) {
> + for (i = 0; i < vi->curr_queue_pairs; i++) {
> struct receive_queue *rq = &vi->rq[i];
>
> napi_disable(&rq->napi);
> @@ -636,7 +636,7 @@ static int virtnet_open(struct net_device *dev)
> struct virtnet_info *vi = netdev_priv(dev);
> int i;
>
> - for (i = 0; i < vi->max_queue_pairs; i++) {
> + for (i = 0; i < vi->curr_queue_pairs; i++) {
> /* Make sure we have some buffers: if oom use wq. */
> if (!try_fill_recv(&vi->rq[i], GFP_KERNEL))
> schedule_delayed_work(&vi->refill, 0);
> @@ -900,6 +900,7 @@ static int virtnet_set_queues(struct virtnet_info *vi, u16 queue_pairs)
> struct scatterlist sg;
> struct virtio_net_ctrl_mq s;
> struct net_device *dev = vi->dev;
> + int i;
>
> if (!vi->has_cvq || !virtio_has_feature(vi->vdev, VIRTIO_NET_F_MQ))
> return 0;
> @@ -912,8 +913,12 @@ static int virtnet_set_queues(struct virtnet_info *vi, u16 queue_pairs)
> dev_warn(&dev->dev, "Fail to set num of queue pairs to %d\n",
> queue_pairs);
> return -EINVAL;
> - } else
> + } else {
> + for (i = vi->curr_queue_pairs; i < queue_pairs; i++)
> + if (!try_fill_recv(&vi->rq[i], GFP_KERNEL))
> + schedule_delayed_work(&vi->refill, 0);
> vi->curr_queue_pairs = queue_pairs;
> + }
>
> return 0;
> }
> @@ -1568,7 +1573,7 @@ static int virtnet_probe(struct virtio_device *vdev)
> }
>
> /* Last of all, set up some receive buffers. */
> - for (i = 0; i < vi->max_queue_pairs; i++) {
> + for (i = 0; i < vi->curr_queue_pairs; i++) {
> try_fill_recv(&vi->rq[i], GFP_KERNEL);
>
> /* If we didn't even get one input buffer, we're useless. */
> @@ -1692,7 +1697,7 @@ static int virtnet_restore(struct virtio_device *vdev)
>
> netif_device_attach(vi->dev);
>
> - for (i = 0; i < vi->max_queue_pairs; i++)
> + for (i = 0; i < vi->curr_queue_pairs; i++)
> if (!try_fill_recv(&vi->rq[i], GFP_KERNEL))
> schedule_delayed_work(&vi->refill, 0);
>
> --
> 1.8.2.1
prev parent reply other threads:[~2013-04-29 3:18 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-04-23 16:17 [PATCH v2] virtio-net: fill only rx queues which are being used Sasha Levin
2013-04-29 2:30 ` Rusty Russell [this message]
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=87vc76cblk.fsf@rustcorp.com.au \
--to=rusty@rustcorp.com.au \
--cc=asias@redhat.com \
--cc=jasowang@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=marc.zyngier@arm.com \
--cc=mst@redhat.com \
--cc=penberg@kernel.org \
--cc=sasha.levin@oracle.com \
--cc=will.deacon@arm.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