* [PATCH] kvm: exclude ioeventfd from counting kvm_io_range limit
@ 2013-05-24 22:44 ` Amos Kong
0 siblings, 0 replies; 6+ messages in thread
From: Amos Kong @ 2013-05-24 22:44 UTC (permalink / raw)
To: gleb, kvm; +Cc: qemu-devel, stefanha
We can easily reach the 1000 limit by start VM with a couple
hundred I/O devices (multifunction=on). The hardcode limit
already been adjusted 3 times (6 ~ 200 ~ 300 ~ 1000).
In userspace, we already have maximum file descriptor to
limit ioeventfd count. But kvm_io_bus devices also are used
for pit, pic, ioapic, coalesced_mmio. They couldn't be limited
by maximum file descriptor.
Currently only ioeventfds take too much kvm_io_bus devices,
so just exclude it from counting kvm_io_range limit.
Also fixed one indent issue in kvm_host.h
Signed-off-by: Amos Kong <akong@redhat.com>
---
include/linux/kvm_host.h | 3 ++-
virt/kvm/eventfd.c | 2 ++
virt/kvm/kvm_main.c | 3 ++-
3 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h
index f0eea07..ef261ab 100644
--- a/include/linux/kvm_host.h
+++ b/include/linux/kvm_host.h
@@ -144,7 +144,8 @@ struct kvm_io_range {
#define NR_IOBUS_DEVS 1000
struct kvm_io_bus {
- int dev_count;
+ int dev_count;
+ int ioeventfd_count;
struct kvm_io_range range[];
};
diff --git a/virt/kvm/eventfd.c b/virt/kvm/eventfd.c
index 64ee720..1550637 100644
--- a/virt/kvm/eventfd.c
+++ b/virt/kvm/eventfd.c
@@ -753,6 +753,7 @@ kvm_assign_ioeventfd(struct kvm *kvm, struct kvm_ioeventfd *args)
if (ret < 0)
goto unlock_fail;
+ kvm->buses[bus_idx]->ioeventfd_count++;
list_add_tail(&p->list, &kvm->ioeventfds);
mutex_unlock(&kvm->slots_lock);
@@ -798,6 +799,7 @@ kvm_deassign_ioeventfd(struct kvm *kvm, struct kvm_ioeventfd *args)
continue;
kvm_io_bus_unregister_dev(kvm, bus_idx, &p->dev);
+ kvm->buses[bus_idx]->ioeventfd_count--;
ioeventfd_release(p);
ret = 0;
break;
diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
index 302681c..c6d9baf 100644
--- a/virt/kvm/kvm_main.c
+++ b/virt/kvm/kvm_main.c
@@ -2926,7 +2926,8 @@ int kvm_io_bus_register_dev(struct kvm *kvm, enum kvm_bus bus_idx, gpa_t addr,
struct kvm_io_bus *new_bus, *bus;
bus = kvm->buses[bus_idx];
- if (bus->dev_count > NR_IOBUS_DEVS - 1)
+ /* exclude ioeventfd which is limited by maximum fd */
+ if (bus->dev_count - bus->ioeventfd_count > NR_IOBUS_DEVS - 1)
return -ENOSPC;
new_bus = kzalloc(sizeof(*bus) + ((bus->dev_count + 1) *
--
1.8.1.4
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [Qemu-devel] [PATCH] kvm: exclude ioeventfd from counting kvm_io_range limit
@ 2013-05-24 22:44 ` Amos Kong
0 siblings, 0 replies; 6+ messages in thread
From: Amos Kong @ 2013-05-24 22:44 UTC (permalink / raw)
To: gleb, kvm; +Cc: qemu-devel, stefanha
We can easily reach the 1000 limit by start VM with a couple
hundred I/O devices (multifunction=on). The hardcode limit
already been adjusted 3 times (6 ~ 200 ~ 300 ~ 1000).
In userspace, we already have maximum file descriptor to
limit ioeventfd count. But kvm_io_bus devices also are used
for pit, pic, ioapic, coalesced_mmio. They couldn't be limited
by maximum file descriptor.
Currently only ioeventfds take too much kvm_io_bus devices,
so just exclude it from counting kvm_io_range limit.
Also fixed one indent issue in kvm_host.h
Signed-off-by: Amos Kong <akong@redhat.com>
---
include/linux/kvm_host.h | 3 ++-
virt/kvm/eventfd.c | 2 ++
virt/kvm/kvm_main.c | 3 ++-
3 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h
index f0eea07..ef261ab 100644
--- a/include/linux/kvm_host.h
+++ b/include/linux/kvm_host.h
@@ -144,7 +144,8 @@ struct kvm_io_range {
#define NR_IOBUS_DEVS 1000
struct kvm_io_bus {
- int dev_count;
+ int dev_count;
+ int ioeventfd_count;
struct kvm_io_range range[];
};
diff --git a/virt/kvm/eventfd.c b/virt/kvm/eventfd.c
index 64ee720..1550637 100644
--- a/virt/kvm/eventfd.c
+++ b/virt/kvm/eventfd.c
@@ -753,6 +753,7 @@ kvm_assign_ioeventfd(struct kvm *kvm, struct kvm_ioeventfd *args)
if (ret < 0)
goto unlock_fail;
+ kvm->buses[bus_idx]->ioeventfd_count++;
list_add_tail(&p->list, &kvm->ioeventfds);
mutex_unlock(&kvm->slots_lock);
@@ -798,6 +799,7 @@ kvm_deassign_ioeventfd(struct kvm *kvm, struct kvm_ioeventfd *args)
continue;
kvm_io_bus_unregister_dev(kvm, bus_idx, &p->dev);
+ kvm->buses[bus_idx]->ioeventfd_count--;
ioeventfd_release(p);
ret = 0;
break;
diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
index 302681c..c6d9baf 100644
--- a/virt/kvm/kvm_main.c
+++ b/virt/kvm/kvm_main.c
@@ -2926,7 +2926,8 @@ int kvm_io_bus_register_dev(struct kvm *kvm, enum kvm_bus bus_idx, gpa_t addr,
struct kvm_io_bus *new_bus, *bus;
bus = kvm->buses[bus_idx];
- if (bus->dev_count > NR_IOBUS_DEVS - 1)
+ /* exclude ioeventfd which is limited by maximum fd */
+ if (bus->dev_count - bus->ioeventfd_count > NR_IOBUS_DEVS - 1)
return -ENOSPC;
new_bus = kzalloc(sizeof(*bus) + ((bus->dev_count + 1) *
--
1.8.1.4
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] kvm: exclude ioeventfd from counting kvm_io_range limit
2013-05-24 22:44 ` [Qemu-devel] " Amos Kong
@ 2013-05-27 11:33 ` Stefan Hajnoczi
-1 siblings, 0 replies; 6+ messages in thread
From: Stefan Hajnoczi @ 2013-05-27 11:33 UTC (permalink / raw)
To: Amos Kong; +Cc: gleb, kvm, qemu-devel, stefanha
On Sat, May 25, 2013 at 06:44:15AM +0800, Amos Kong wrote:
> We can easily reach the 1000 limit by start VM with a couple
> hundred I/O devices (multifunction=on). The hardcode limit
> already been adjusted 3 times (6 ~ 200 ~ 300 ~ 1000).
>
> In userspace, we already have maximum file descriptor to
> limit ioeventfd count. But kvm_io_bus devices also are used
> for pit, pic, ioapic, coalesced_mmio. They couldn't be limited
> by maximum file descriptor.
>
> Currently only ioeventfds take too much kvm_io_bus devices,
> so just exclude it from counting kvm_io_range limit.
>
> Also fixed one indent issue in kvm_host.h
>
> Signed-off-by: Amos Kong <akong@redhat.com>
> ---
> include/linux/kvm_host.h | 3 ++-
> virt/kvm/eventfd.c | 2 ++
> virt/kvm/kvm_main.c | 3 ++-
> 3 files changed, 6 insertions(+), 2 deletions(-)
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Qemu-devel] [PATCH] kvm: exclude ioeventfd from counting kvm_io_range limit
@ 2013-05-27 11:33 ` Stefan Hajnoczi
0 siblings, 0 replies; 6+ messages in thread
From: Stefan Hajnoczi @ 2013-05-27 11:33 UTC (permalink / raw)
To: Amos Kong; +Cc: stefanha, kvm, gleb, qemu-devel
On Sat, May 25, 2013 at 06:44:15AM +0800, Amos Kong wrote:
> We can easily reach the 1000 limit by start VM with a couple
> hundred I/O devices (multifunction=on). The hardcode limit
> already been adjusted 3 times (6 ~ 200 ~ 300 ~ 1000).
>
> In userspace, we already have maximum file descriptor to
> limit ioeventfd count. But kvm_io_bus devices also are used
> for pit, pic, ioapic, coalesced_mmio. They couldn't be limited
> by maximum file descriptor.
>
> Currently only ioeventfds take too much kvm_io_bus devices,
> so just exclude it from counting kvm_io_range limit.
>
> Also fixed one indent issue in kvm_host.h
>
> Signed-off-by: Amos Kong <akong@redhat.com>
> ---
> include/linux/kvm_host.h | 3 ++-
> virt/kvm/eventfd.c | 2 ++
> virt/kvm/kvm_main.c | 3 ++-
> 3 files changed, 6 insertions(+), 2 deletions(-)
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] kvm: exclude ioeventfd from counting kvm_io_range limit
2013-05-24 22:44 ` [Qemu-devel] " Amos Kong
@ 2013-06-04 8:49 ` Gleb Natapov
-1 siblings, 0 replies; 6+ messages in thread
From: Gleb Natapov @ 2013-06-04 8:49 UTC (permalink / raw)
To: Amos Kong; +Cc: stefanha, qemu-devel, kvm
On Sat, May 25, 2013 at 06:44:15AM +0800, Amos Kong wrote:
> We can easily reach the 1000 limit by start VM with a couple
> hundred I/O devices (multifunction=on). The hardcode limit
> already been adjusted 3 times (6 ~ 200 ~ 300 ~ 1000).
>
> In userspace, we already have maximum file descriptor to
> limit ioeventfd count. But kvm_io_bus devices also are used
> for pit, pic, ioapic, coalesced_mmio. They couldn't be limited
> by maximum file descriptor.
>
> Currently only ioeventfds take too much kvm_io_bus devices,
> so just exclude it from counting kvm_io_range limit.
>
> Also fixed one indent issue in kvm_host.h
>
> Signed-off-by: Amos Kong <akong@redhat.com>
Applied, thanks.
> ---
> include/linux/kvm_host.h | 3 ++-
> virt/kvm/eventfd.c | 2 ++
> virt/kvm/kvm_main.c | 3 ++-
> 3 files changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h
> index f0eea07..ef261ab 100644
> --- a/include/linux/kvm_host.h
> +++ b/include/linux/kvm_host.h
> @@ -144,7 +144,8 @@ struct kvm_io_range {
> #define NR_IOBUS_DEVS 1000
>
> struct kvm_io_bus {
> - int dev_count;
> + int dev_count;
> + int ioeventfd_count;
> struct kvm_io_range range[];
> };
>
> diff --git a/virt/kvm/eventfd.c b/virt/kvm/eventfd.c
> index 64ee720..1550637 100644
> --- a/virt/kvm/eventfd.c
> +++ b/virt/kvm/eventfd.c
> @@ -753,6 +753,7 @@ kvm_assign_ioeventfd(struct kvm *kvm, struct kvm_ioeventfd *args)
> if (ret < 0)
> goto unlock_fail;
>
> + kvm->buses[bus_idx]->ioeventfd_count++;
> list_add_tail(&p->list, &kvm->ioeventfds);
>
> mutex_unlock(&kvm->slots_lock);
> @@ -798,6 +799,7 @@ kvm_deassign_ioeventfd(struct kvm *kvm, struct kvm_ioeventfd *args)
> continue;
>
> kvm_io_bus_unregister_dev(kvm, bus_idx, &p->dev);
> + kvm->buses[bus_idx]->ioeventfd_count--;
> ioeventfd_release(p);
> ret = 0;
> break;
> diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
> index 302681c..c6d9baf 100644
> --- a/virt/kvm/kvm_main.c
> +++ b/virt/kvm/kvm_main.c
> @@ -2926,7 +2926,8 @@ int kvm_io_bus_register_dev(struct kvm *kvm, enum kvm_bus bus_idx, gpa_t addr,
> struct kvm_io_bus *new_bus, *bus;
>
> bus = kvm->buses[bus_idx];
> - if (bus->dev_count > NR_IOBUS_DEVS - 1)
> + /* exclude ioeventfd which is limited by maximum fd */
> + if (bus->dev_count - bus->ioeventfd_count > NR_IOBUS_DEVS - 1)
> return -ENOSPC;
>
> new_bus = kzalloc(sizeof(*bus) + ((bus->dev_count + 1) *
> --
> 1.8.1.4
--
Gleb.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Qemu-devel] [PATCH] kvm: exclude ioeventfd from counting kvm_io_range limit
@ 2013-06-04 8:49 ` Gleb Natapov
0 siblings, 0 replies; 6+ messages in thread
From: Gleb Natapov @ 2013-06-04 8:49 UTC (permalink / raw)
To: Amos Kong; +Cc: stefanha, qemu-devel, kvm
On Sat, May 25, 2013 at 06:44:15AM +0800, Amos Kong wrote:
> We can easily reach the 1000 limit by start VM with a couple
> hundred I/O devices (multifunction=on). The hardcode limit
> already been adjusted 3 times (6 ~ 200 ~ 300 ~ 1000).
>
> In userspace, we already have maximum file descriptor to
> limit ioeventfd count. But kvm_io_bus devices also are used
> for pit, pic, ioapic, coalesced_mmio. They couldn't be limited
> by maximum file descriptor.
>
> Currently only ioeventfds take too much kvm_io_bus devices,
> so just exclude it from counting kvm_io_range limit.
>
> Also fixed one indent issue in kvm_host.h
>
> Signed-off-by: Amos Kong <akong@redhat.com>
Applied, thanks.
> ---
> include/linux/kvm_host.h | 3 ++-
> virt/kvm/eventfd.c | 2 ++
> virt/kvm/kvm_main.c | 3 ++-
> 3 files changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h
> index f0eea07..ef261ab 100644
> --- a/include/linux/kvm_host.h
> +++ b/include/linux/kvm_host.h
> @@ -144,7 +144,8 @@ struct kvm_io_range {
> #define NR_IOBUS_DEVS 1000
>
> struct kvm_io_bus {
> - int dev_count;
> + int dev_count;
> + int ioeventfd_count;
> struct kvm_io_range range[];
> };
>
> diff --git a/virt/kvm/eventfd.c b/virt/kvm/eventfd.c
> index 64ee720..1550637 100644
> --- a/virt/kvm/eventfd.c
> +++ b/virt/kvm/eventfd.c
> @@ -753,6 +753,7 @@ kvm_assign_ioeventfd(struct kvm *kvm, struct kvm_ioeventfd *args)
> if (ret < 0)
> goto unlock_fail;
>
> + kvm->buses[bus_idx]->ioeventfd_count++;
> list_add_tail(&p->list, &kvm->ioeventfds);
>
> mutex_unlock(&kvm->slots_lock);
> @@ -798,6 +799,7 @@ kvm_deassign_ioeventfd(struct kvm *kvm, struct kvm_ioeventfd *args)
> continue;
>
> kvm_io_bus_unregister_dev(kvm, bus_idx, &p->dev);
> + kvm->buses[bus_idx]->ioeventfd_count--;
> ioeventfd_release(p);
> ret = 0;
> break;
> diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
> index 302681c..c6d9baf 100644
> --- a/virt/kvm/kvm_main.c
> +++ b/virt/kvm/kvm_main.c
> @@ -2926,7 +2926,8 @@ int kvm_io_bus_register_dev(struct kvm *kvm, enum kvm_bus bus_idx, gpa_t addr,
> struct kvm_io_bus *new_bus, *bus;
>
> bus = kvm->buses[bus_idx];
> - if (bus->dev_count > NR_IOBUS_DEVS - 1)
> + /* exclude ioeventfd which is limited by maximum fd */
> + if (bus->dev_count - bus->ioeventfd_count > NR_IOBUS_DEVS - 1)
> return -ENOSPC;
>
> new_bus = kzalloc(sizeof(*bus) + ((bus->dev_count + 1) *
> --
> 1.8.1.4
--
Gleb.
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2013-06-04 8:50 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-05-24 22:44 [PATCH] kvm: exclude ioeventfd from counting kvm_io_range limit Amos Kong
2013-05-24 22:44 ` [Qemu-devel] " Amos Kong
2013-05-27 11:33 ` Stefan Hajnoczi
2013-05-27 11:33 ` [Qemu-devel] " Stefan Hajnoczi
2013-06-04 8:49 ` Gleb Natapov
2013-06-04 8:49 ` [Qemu-devel] " Gleb Natapov
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.