kvm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Amos Kong <akong@redhat.com>
To: Jan Kiszka <jan.kiszka@siemens.com>
Cc: kvm@vger.kernel.org, jasowang@redhat.com, mtosatti@redhat.com,
	alex williamson <alex.williamson@redhat.com>,
	avi@redhat.com, levinsasha928@gmail.com
Subject: Re: [PATCH v3] KVM: Resize kvm_io_range array dynamically
Date: Thu, 01 Mar 2012 13:19:24 +0800	[thread overview]
Message-ID: <4F4F06DC.6030400@redhat.com> (raw)
In-Reply-To: <2b6f7414-7cae-4349-9f5d-eb6c3febf612@zmail13.collab.prod.int.phx2.redhat.com>

On 01/03/12 00:34, Amos Kong wrote:
> ----- Original Message -----
>> On 2012-02-29 16:22, Amos Kong wrote:
>>> ----- Original Message -----
>>>> On 2012-02-29 14:30, Amos Kong wrote:
>>>>> kvm_io_bus devices are used for ioevent, pit, pic, ioapic,
>>>>> coalesced_mmio.
>>>>>
>>>>> Currently Qemu only emulates one PCI bus, it contains 32 slots,
>>>>> one slot contains 8 functions, maximum of supported PCI devices:
>>>>>   1 * 32 * 8 = 256. The maximum of coalesced mmio zone is 100,
>>>>> each zone has an iobus devices. 300 io_bus devices is not enough.
>>>>>
>>>>> This patch makes the kvm_io_range array can be resized
>>>>> dynamically.
>>>>
>>>> Is there any limit, or can userspace allocate arbitrary amounts of
>>>> kernel memory this way?
>>>
>>> Hi Jan,
>>>
>>> There is a fixed array in linux-2.6/include/linux/kvm_host.h,
>>> we can only register 300 devices.
>>>
>>> struct kvm_io_range {
>>>          gpa_t addr;
>>>          int len;
>>>          struct kvm_io_device *dev;
>>> };
>>>
>>> struct kvm_io_bus {
>>>          int                   dev_count;
>>> #define NR_IOBUS_DEVS 300
>>>          struct kvm_io_range range[NR_IOBUS_DEVS];
>>> };
>>>                                    ^^^^^^^^^^^^^^
>>
>> Right. But doesn't your patch remove precisely this limit? So what
>> limits userspace now? To register 300 million devices...?
>
> Hi Jan,
>
> It seems we need to reserve the limitation in kvm_host.h
>
> #define NR_IOBUS_DEVS 600
>
> /* Currently Qemu only emulates one PCI bus, it contains 32 slots,
> one slot contains 8 functions. Only 29 slots can be used to
> add multiple function devices. Maximum of supported PCI devices:
> 29 * 8 = 232. Each virtio-blk device needs 1 iobus device,
> each virtio-net(vhost) device requires 2 such devices to service
> notifications (ioevent) from rx/tx queues.
> The maximum of coalesced mmio zone is 100, each zone has an iobus
> devices. ioevent, pit, ioapic take less iobus devices.
>
> So we can set max limitation to 600. */

One virtio-net(vhost=on) takes two iobus devices,
and it needs three IRQs for MSI/MIS-X.
I started a guest with 232 virtio-net(vhost=on),
guest IRQ 24 to 191 were used for virtio-config/input/output,
and only 56 virtio-nics' MSIX were enabled.
56 virtio-net(vhost=on) registered 56 * 2 = 112 iobus devices.

It's safe to set the limit to 300, right ?


> ----- check limit when register dev ----
>
> virt/kvm/kvm_main.c:
>
> /* Caller must hold slots_lock. */
> int kvm_io_bus_register_dev(struct kvm *kvm, enum kvm_bus bus_idx, gpa_t addr,
>                              int len, struct kvm_io_device *dev)
> {
>          struct kvm_io_bus *new_bus, *bus;
>
>          bus = kvm->buses[bus_idx];
>          if (bus->dev_count>  NR_IOBUS_DEVS - 1)   // can only register 600 devices
>                  return -ENOSPC;
>
> Amos.

-- 
			Amos.

  reply	other threads:[~2012-03-01  5:19 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-02-29  5:24 [PATCH] KVM: Resize kvm_io_bus_range array dynamically Amos Kong
2012-02-29  5:50 ` [PATCH v2] KVM: Resize kvm_io_range " Amos Kong
2012-02-29 13:30 ` [PATCH v3] " Amos Kong
2012-02-29 14:19   ` Jan Kiszka
2012-02-29 15:22     ` Amos Kong
2012-02-29 15:29       ` Jan Kiszka
2012-02-29 16:34         ` Amos Kong
2012-03-01  5:19           ` Amos Kong [this message]
2012-03-01  7:01 ` [PATCH v4] " Amos Kong
2012-03-01 10:14   ` Sasha Levin
2012-03-01 15:33     ` Alex Williamson
2012-03-07 10:57   ` Avi Kivity
2012-03-07 12:51     ` Amos Kong
2012-03-07 14:12       ` Avi Kivity
2012-03-07 13:16   ` [PATCH v5 1/2] KVM: resize " Amos Kong
2012-03-07 13:16   ` [PATCH v5 2/2] KVM: set upper bounds for iobus dev to limit userspace Amos Kong
2012-03-07 13:20   ` [RESEND PATCH v5 0/2] fix ENOSPC issue of iobus dev Amos Kong
2012-03-07 13:20     ` [RESEND PATCH v5 1/2] KVM: resize kvm_io_range array dynamically Amos Kong
2012-03-07 13:20     ` [RESEND PATCH v5 2/2] KVM: set upper bounds for iobus dev to limit userspace Amos Kong
2012-03-08  2:03   ` [PATCH v6 0/2] fix ENOSPC issue of iobus dev Amos Kong
2012-03-08  2:03     ` [PATCH v6 1/2] KVM: resize kvm_io_range array dynamically Amos Kong
2012-03-08 23:20       ` Marcelo Tosatti
2012-03-09  4:05         ` Amos Kong
2012-03-08  2:04     ` [PATCH v6 2/2] KVM: set upper bounds for iobus dev to limit userspace Amos Kong
2012-03-09  4:17   ` [PATCH v7 0/2] fix ENOSPC issue of iobus dev Amos Kong
2012-03-09  4:17     ` [PATCH v7 1/2] KVM: resize kvm_io_range array dynamically Amos Kong
2012-03-09  4:17     ` [PATCH v7 2/2] KVM: set upper bounds for iobus dev to limit userspace Amos Kong
2012-03-09 21:07     ` [PATCH v7 0/2] fix ENOSPC issue of iobus dev Marcelo Tosatti

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=4F4F06DC.6030400@redhat.com \
    --to=akong@redhat.com \
    --cc=alex.williamson@redhat.com \
    --cc=avi@redhat.com \
    --cc=jan.kiszka@siemens.com \
    --cc=jasowang@redhat.com \
    --cc=kvm@vger.kernel.org \
    --cc=levinsasha928@gmail.com \
    --cc=mtosatti@redhat.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;
as well as URLs for NNTP newsgroup(s).