From mboxrd@z Thu Jan 1 00:00:00 1970 From: Rusty Russell Subject: Re: [PATCH] virtio-net: fill only rx queues which are being used Date: Tue, 23 Apr 2013 13:43:04 +0930 Message-ID: <87obd5ga0f.fsf@rustcorp.com.au> References: <1366677336-2278-1-git-send-email-sasha.levin@oracle.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: penberg@kernel.org, will.deacon@arm.com, marc.zyngier@arm.com, kvm@vger.kernel.org, asias@redhat.com, jasowang@redhat.com, Sasha Levin To: Sasha Levin , mst@redhat.com Return-path: Received: from ozlabs.org ([203.10.76.45]:55329 "EHLO ozlabs.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751506Ab3DWEWG (ORCPT ); Tue, 23 Apr 2013 00:22:06 -0400 In-Reply-To: <1366677336-2278-1-git-send-email-sasha.levin@oracle.com> Sender: kvm-owner@vger.kernel.org List-ID: Sasha Levin 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: Idea is good, implementation needs a tiny tweak: > @@ -912,8 +913,13 @@ 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 { > + if (queue_pairs > vi->curr_queue_pairs) > + for (i = 0; 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; > } You don't want to refill existing queues, so you don't need the "if". 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); We don't free up buffers when we're reducing queues, but I consider that a corner case. Thanks, Rusty.