public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: "Michael S. Tsirkin" <mst@redhat.com>
To: Sasha Levin <sasha.levin@oracle.com>
Cc: Rusty Russell <rusty@rustcorp.com.au>,
	Will Deacon <will.deacon@arm.com>,
	kvm@vger.kernel.org, penberg@kernel.org, marc.zyngier@arm.com
Subject: Re: virtio-net mq vq initialization
Date: Sun, 14 Apr 2013 13:01:56 +0300	[thread overview]
Message-ID: <20130414100156.GB2548@redhat.com> (raw)
In-Reply-To: <5169CCDD.4070205@oracle.com>

On Sat, Apr 13, 2013 at 05:23:41PM -0400, Sasha Levin wrote:
> On 04/12/2013 07:36 AM, Rusty Russell wrote:
> > Sasha Levin <sasha.levin@oracle.com> writes:
> >> On 04/11/2013 12:36 PM, Will Deacon wrote:
> >>> Hello folks,
> >>>
> >>> Here's the latest round of ARM fixes and updates for kvmtool. Most of
> >>> this is confined to the arm/ subdirectory, with the exception of a fix
> >>> to the virtio-mmio vq definitions due to the multi-queue work from
> >>> Sasha. I'm not terribly happy about that code though, since it seriously
> >>> increases the memory footprint of the guest.
> >>>
> >>> Without multi-queue, we can boot Debian Wheezy to a prompt in 38MB. With
> >>> the new changes, that increases to 170MB! Any chance we can try and tackle
> >>> this regression please? I keep getting bitten by the OOM killer :(
> >>
> >> (cc Rusty, MST)
> >>
> >> The spec defines the operation of a virtio-net device with regards to multiple
> >> queues as follows:
> >>
> >> """
> >> Device Initialization
> >>
> >> 	1. The initialization routine should identify the receive and transmission
> >> virtqueues, up to N+1 of each kind. If VIRTIO_NET_F_MQ feature
> >> bit is negotiated, N=max_virtqueue_pairs-1, otherwise identify N=0.
> >>
> >> 	[...]
> >>
> >> 	5. Only receiveq0, transmitq0 and controlq are used by default. To use more
> >> queues driver must negotiate the VIRTIO_NET_F_MQ feature; initialize
> >> up to max_virtqueue_pairs of each of transmit and receive queues; execute_
> >> VIRTIO_NET_CTRL_MQ_VQ_PAIRS_SET command specifying
> >> the number of the transmit and receive queues that is going to be
> >> used and wait until the device consumes the controlq buffer and acks this
> >> command.
> >> """
> >>
> >> And kvmtool follows that to the letter: It will initialize the maximum amount of
> >> queues it can support during initialization and will start using them only when
> >> the device tells it it should use them.
> >>
> >> As Will has stated, this causes a memory issue since all the data structures that hold
> >> all possible queues get initialized regardless of whether we actually need them or not,
> >> which is quite troublesome for systems with small RAM.
> >>
> >>
> >> Rusty, MST, would you be open to a spec and code change that would initialize the
> >> RX/TX vqs on demand instead of on device initialization? Or is there an easier way
> >> to work around this issue?
> > 
> > I'm confused.  kvmtool is using too much memory, or the guest?  If
> > kvmtool, the Device Initialization section above applies to the driver,
> > not the device.  If the guest, well, the language says "UP TO N+1".  You
> > want a small guest, don't use them all.  Or any...
> > 
> > What am I missing?
> 
> It's in the guest - sorry. I was only trying to say that kvmtool doesn't do anything
> odd with regards to initializing virtio-net.
> 
> The thing is that there should be a difference between just allowing a larger number
> of queues and actually using them (i.e. enabling them with ethtool). Right now I see
> the kernel lose 130MB just by having kvmtool offer 8 queue pairs, without actually
> using those queues.
> 
> Yes, we can make it configurable in kvmtool (and I will make it so so the arm folks
> could continue working with tiny guests) but does it make sense that you have to do
> this configuration in *2* places? First in the hypervisor and then inside the guest?
> 
> Memory usage should ideally depend on whether you are actually using multiple queues,
> not on whether you just allow using those queues.
> 
> 
> Thanks,
> Sasha

8 queues eat up 130MB?  Most of the memory is likely for the buffers?  I
think we could easily allocate these lazily as queues are enabled,
without protocol changes. It's harder to clean them as there's no way to
reset a specific queue, but maybe that' good enough for your purposes?

-- 
MST

  reply	other threads:[~2013-04-14 10:02 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-04-11 16:36 [PATCH 0/5] Usual batch of random ARM fixes for kvmtool Will Deacon
2013-04-11 16:36 ` [PATCH 1/5] kvm tools: arm: don't crash when no compatible CPU is found Will Deacon
2013-04-11 16:36 ` [PATCH 2/5] kvm tools: arm: add CPU compatible string to target structure Will Deacon
2013-04-11 16:36 ` [PATCH 3/5] kvm tools: arm: consolidate CPU node generation Will Deacon
2013-04-11 16:36 ` [PATCH 4/5] kvm tools: arm64: add support for AEM and Foundation models Will Deacon
2013-04-11 16:36 ` [PATCH 5/5] kvm tools: bump number of virtio MMIO vqueues Will Deacon
2013-04-11 16:45 ` [PATCH 0/5] Usual batch of random ARM fixes for kvmtool Sasha Levin
2013-04-12  6:52   ` Pekka Enberg
2013-04-12  8:30     ` Marc Zyngier
2013-04-12  8:50       ` Will Deacon
2013-04-11 20:02 ` virtio-net mq vq initialization (was: [PATCH 0/5] Usual batch of random ARM fixes for kvmtool) Sasha Levin
2013-04-12 11:36   ` Rusty Russell
2013-04-12 12:41     ` Will Deacon
2013-04-14 10:03       ` Michael S. Tsirkin
2013-04-13 21:23     ` virtio-net mq vq initialization Sasha Levin
2013-04-14 10:01       ` Michael S. Tsirkin [this message]
2013-04-14 15:16         ` Sasha Levin
2013-04-14 15:53           ` Michael S. Tsirkin
2013-04-14 15:59             ` Sasha Levin
2013-04-14 18:35               ` Michael S. Tsirkin
2013-04-15  2:55                 ` Rusty Russell
2013-04-15  5:58           ` Jason Wang
2013-04-22 18:32             ` Sasha Levin
2013-04-12  7:12 ` [PATCH 0/5] Usual batch of random ARM fixes for kvmtool Pekka Enberg

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=20130414100156.GB2548@redhat.com \
    --to=mst@redhat.com \
    --cc=kvm@vger.kernel.org \
    --cc=marc.zyngier@arm.com \
    --cc=penberg@kernel.org \
    --cc=rusty@rustcorp.com.au \
    --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