[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 03/21] qdev: Do not use slow [*] expansion for GPIO c
From: |
Andreas Färber |
Subject: |
[Qemu-devel] [PULL 03/21] qdev: Do not use slow [*] expansion for GPIO creation |
Date: |
Sat, 19 Sep 2015 16:43:12 +0200 |
From: Pavel Fedin <address@hidden>
Expansion of [*] suffix is very slow because index expansion is done using
trial and error strategy, starting every time from zero and retrying with
the next index until insertion succeeds. With large number of already added
properties this process takes huge amount of time (O(n^2) complexity).
Some architectures (like ARM) use very large amount of IRQ pins in interrupt
controller models. This flaw makes machine startup extremely slow
(~20 seconds for ARM64 with 32 CPUs). This patch decreases this time down to
~10 seconds.
Also in qdev_init_gpio_out_named() memset() is now called only once for the
whole array instead of per-cell cleaning
Signed-off-by: Pavel Fedin <address@hidden>
Reviewed-by: Daniel P. Berrange <address@hidden>
Signed-off-by: Andreas Färber <address@hidden>
---
hw/core/qdev.c | 21 +++++++++++++++------
1 file changed, 15 insertions(+), 6 deletions(-)
diff --git a/hw/core/qdev.c b/hw/core/qdev.c
index a24493a..4ab04aa 100644
--- a/hw/core/qdev.c
+++ b/hw/core/qdev.c
@@ -417,17 +417,21 @@ void qdev_init_gpio_in_named(DeviceState *dev,
qemu_irq_handler handler,
{
int i;
NamedGPIOList *gpio_list = qdev_get_named_gpio_list(dev, name);
- char *propname = g_strdup_printf("%s[*]", name ? name : "unnamed-gpio-in");
assert(gpio_list->num_out == 0 || !name);
gpio_list->in = qemu_extend_irqs(gpio_list->in, gpio_list->num_in, handler,
dev, n);
+ if (!name) {
+ name = "unnamed-gpio-in";
+ }
for (i = gpio_list->num_in; i < gpio_list->num_in + n; i++) {
+ gchar *propname = g_strdup_printf("%s[%u]", name, i);
+
object_property_add_child(OBJECT(dev), propname,
OBJECT(gpio_list->in[i]), &error_abort);
+ g_free(propname);
}
- g_free(propname);
gpio_list->num_in += n;
}
@@ -442,20 +446,25 @@ void qdev_init_gpio_out_named(DeviceState *dev, qemu_irq
*pins,
{
int i;
NamedGPIOList *gpio_list = qdev_get_named_gpio_list(dev, name);
- char *propname = g_strdup_printf("%s[*]", name ? name :
"unnamed-gpio-out");
assert(gpio_list->num_in == 0 || !name);
- gpio_list->num_out += n;
+ if (!name) {
+ name = "unnamed-gpio-out";
+ }
+ memset(pins, 0, sizeof(*pins) * n);
for (i = 0; i < n; ++i) {
- memset(&pins[i], 0, sizeof(*pins));
+ gchar *propname = g_strdup_printf("%s[%u]", name,
+ gpio_list->num_out + i);
+
object_property_add_link(OBJECT(dev), propname, TYPE_IRQ,
(Object **)&pins[i],
object_property_allow_set_link,
OBJ_PROP_LINK_UNREF_ON_RELEASE,
&error_abort);
+ g_free(propname);
}
- g_free(propname);
+ gpio_list->num_out += n;
}
void qdev_init_gpio_out(DeviceState *dev, qemu_irq *pins, int n)
--
2.1.4
- [Qemu-devel] [PULL 00/21] QOM devices patch queue 2015-09-19, Andreas Färber, 2015/09/19
- [Qemu-devel] [PULL 04/21] machine: MACHINE_TYPE_NAME macro, Andreas Färber, 2015/09/19
- [Qemu-devel] [PULL 03/21] qdev: Do not use slow [*] expansion for GPIO creation,
Andreas Färber <=
- [Qemu-devel] [PULL 02/21] qom: Fix invalid error check in property_get_str(), Andreas Färber, 2015/09/19
- [Qemu-devel] [PULL 01/21] qom: Do not reuse errp after a possible error, Andreas Färber, 2015/09/19
- [Qemu-devel] [PULL 05/21] vexpress: Don't set name on abstract class, Andreas Färber, 2015/09/19
- [Qemu-devel] [PULL 06/21] vexpress: Rename machine classes to use MACHINE_TYPE_NAME, Andreas Färber, 2015/09/19
- [Qemu-devel] [PULL 07/21] arm: Rename virt machine class to use MACHINE_TYPE_NAME, Andreas Färber, 2015/09/19
- [Qemu-devel] [PULL 09/21] s390-virtio: Rename machine class name to use MACHINE_TYPE_NAME, Andreas Färber, 2015/09/19
- [Qemu-devel] [PULL 12/21] machine: Ensure all TYPE_MACHINE subclasses have the right suffix, Andreas Färber, 2015/09/19
- [Qemu-devel] [PULL 10/21] s390: Rename s390-ccw-virtio-2.4 class name to use MACHINE_TYPE_NAME, Andreas Färber, 2015/09/19
- [Qemu-devel] [PULL 08/21] pseries: Rename machine class names to use MACHINE_TYPE_NAME, Andreas Färber, 2015/09/19
- [Qemu-devel] [PULL 11/21] mac99: Use MACHINE_TYPE_NAME to encode class name, Andreas Färber, 2015/09/19