* [PATCH v3 0/3] monitor: Rate-limit MEMORY_DEVICE_SIZE_CHANGE qapi events per device
@ 2021-09-29 16:24 David Hildenbrand
2021-09-29 16:24 ` [PATCH v3 1/3] virtio-mem-pci: Fix memory leak when creating MEMORY_DEVICE_SIZE_CHANGE event David Hildenbrand
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: David Hildenbrand @ 2021-09-29 16:24 UTC (permalink / raw)
To: qemu-devel
Cc: Michael S . Tsirkin, Michal Privoznik, David Hildenbrand,
Markus Armbruster, Dr. David Alan Gilbert, Igor Mammedov,
Eric Blake
Some fixes for virtio-mem-pci, to properly handle MEMORY_DEVICE_SIZE_CHANGE
events, especially not dropping events of some devices when rate-limiting.
v2 -> v3:
- Split up into two patches
- "const char * qom_path" -> "char *qom_path"
- Fix existing memory leak and avoid a new memory leak when creating the
event
v1 -> v2:
- Add the qom-path and use that identifier to rate-limit per device
- Rephrase subject/description
Cc: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
Cc: Markus Armbruster <armbru@redhat.com>
Cc: Michael S. Tsirkin <mst@redhat.com>
Cc: Eric Blake <eblake@redhat.com>
Cc: Igor Mammedov <imammedo@redhat.com>
Cc: Michal Privoznik <mprivozn@redhat.com>
David Hildenbrand (3):
virtio-mem-pci: Fix memory leak when creating
MEMORY_DEVICE_SIZE_CHANGE event
qapi: Include qom-path in MEMORY_DEVICE_SIZE_CHANGE qapi events
monitor: Rate-limit MEMORY_DEVICE_SIZE_CHANGE qapi events per device
hw/virtio/virtio-mem-pci.c | 10 ++++------
monitor/monitor.c | 9 +++++++++
qapi/machine.json | 5 ++++-
3 files changed, 17 insertions(+), 7 deletions(-)
--
2.31.1
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH v3 1/3] virtio-mem-pci: Fix memory leak when creating MEMORY_DEVICE_SIZE_CHANGE event
2021-09-29 16:24 [PATCH v3 0/3] monitor: Rate-limit MEMORY_DEVICE_SIZE_CHANGE qapi events per device David Hildenbrand
@ 2021-09-29 16:24 ` David Hildenbrand
2021-09-29 16:24 ` [PATCH v3 2/3] qapi: Include qom-path in MEMORY_DEVICE_SIZE_CHANGE qapi events David Hildenbrand
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: David Hildenbrand @ 2021-09-29 16:24 UTC (permalink / raw)
To: qemu-devel
Cc: Michael S . Tsirkin, Michal Privoznik, qemu-stable,
David Hildenbrand, Markus Armbruster, Dr. David Alan Gilbert,
Igor Mammedov, Eric Blake
Apparently, we don't have to duplicate the string.
Fixes: 722a3c783ef4 ("virtio-pci: Send qapi events when the virtio-mem size changes")
Cc: qemu-stable@nongnu.org
Signed-off-by: David Hildenbrand <david@redhat.com>
---
hw/virtio/virtio-mem-pci.c | 7 +------
1 file changed, 1 insertion(+), 6 deletions(-)
diff --git a/hw/virtio/virtio-mem-pci.c b/hw/virtio/virtio-mem-pci.c
index fa5395cd88..7e384b7397 100644
--- a/hw/virtio/virtio-mem-pci.c
+++ b/hw/virtio/virtio-mem-pci.c
@@ -88,13 +88,8 @@ static void virtio_mem_pci_size_change_notify(Notifier *notifier, void *data)
size_change_notifier);
DeviceState *dev = DEVICE(pci_mem);
const uint64_t * const size_p = data;
- const char *id = NULL;
- if (dev->id) {
- id = g_strdup(dev->id);
- }
-
- qapi_event_send_memory_device_size_change(!!id, id, *size_p);
+ qapi_event_send_memory_device_size_change(!!dev->id, dev->id, *size_p);
}
static void virtio_mem_pci_class_init(ObjectClass *klass, void *data)
--
2.31.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH v3 2/3] qapi: Include qom-path in MEMORY_DEVICE_SIZE_CHANGE qapi events
2021-09-29 16:24 [PATCH v3 0/3] monitor: Rate-limit MEMORY_DEVICE_SIZE_CHANGE qapi events per device David Hildenbrand
2021-09-29 16:24 ` [PATCH v3 1/3] virtio-mem-pci: Fix memory leak when creating MEMORY_DEVICE_SIZE_CHANGE event David Hildenbrand
@ 2021-09-29 16:24 ` David Hildenbrand
2021-09-29 16:24 ` [PATCH v3 3/3] monitor: Rate-limit MEMORY_DEVICE_SIZE_CHANGE qapi events per device David Hildenbrand
2021-09-30 6:06 ` [PATCH v3 0/3] " Markus Armbruster
3 siblings, 0 replies; 5+ messages in thread
From: David Hildenbrand @ 2021-09-29 16:24 UTC (permalink / raw)
To: qemu-devel
Cc: Michael S . Tsirkin, Michal Privoznik, David Hildenbrand,
Markus Armbruster, Dr. David Alan Gilbert, Igor Mammedov,
Eric Blake
As we might not always have a device id, it is impossible to always
match MEMORY_DEVICE_SIZE_CHANGE events to an actual device. Let's
include the qom-path in the event, which allows for reliable mapping of
events to devices.
Fixes: 722a3c783ef4 ("virtio-pci: Send qapi events when the virtio-mem size changes")
Suggested-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: David Hildenbrand <david@redhat.com>
---
hw/virtio/virtio-mem-pci.c | 5 ++++-
qapi/machine.json | 5 ++++-
2 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/hw/virtio/virtio-mem-pci.c b/hw/virtio/virtio-mem-pci.c
index 7e384b7397..be2383b0c5 100644
--- a/hw/virtio/virtio-mem-pci.c
+++ b/hw/virtio/virtio-mem-pci.c
@@ -87,9 +87,12 @@ static void virtio_mem_pci_size_change_notify(Notifier *notifier, void *data)
VirtIOMEMPCI *pci_mem = container_of(notifier, VirtIOMEMPCI,
size_change_notifier);
DeviceState *dev = DEVICE(pci_mem);
+ char *qom_path = object_get_canonical_path(OBJECT(dev));
const uint64_t * const size_p = data;
- qapi_event_send_memory_device_size_change(!!dev->id, dev->id, *size_p);
+ qapi_event_send_memory_device_size_change(!!dev->id, dev->id, *size_p,
+ qom_path);
+ g_free(qom_path);
}
static void virtio_mem_pci_class_init(ObjectClass *klass, void *data)
diff --git a/qapi/machine.json b/qapi/machine.json
index 32d47f4e35..8258b9ce3a 100644
--- a/qapi/machine.json
+++ b/qapi/machine.json
@@ -1279,8 +1279,11 @@
# action).
#
# @id: device's ID
+#
# @size: the new size of memory that the device provides
#
+# @qom-path: path to the device object in the QOM tree (since 6.2)
+#
# Note: this event is rate-limited.
#
# Since: 5.1
@@ -1293,7 +1296,7 @@
#
##
{ 'event': 'MEMORY_DEVICE_SIZE_CHANGE',
- 'data': { '*id': 'str', 'size': 'size' } }
+ 'data': { '*id': 'str', 'size': 'size', 'qom-path' : 'str'} }
##
--
2.31.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH v3 3/3] monitor: Rate-limit MEMORY_DEVICE_SIZE_CHANGE qapi events per device
2021-09-29 16:24 [PATCH v3 0/3] monitor: Rate-limit MEMORY_DEVICE_SIZE_CHANGE qapi events per device David Hildenbrand
2021-09-29 16:24 ` [PATCH v3 1/3] virtio-mem-pci: Fix memory leak when creating MEMORY_DEVICE_SIZE_CHANGE event David Hildenbrand
2021-09-29 16:24 ` [PATCH v3 2/3] qapi: Include qom-path in MEMORY_DEVICE_SIZE_CHANGE qapi events David Hildenbrand
@ 2021-09-29 16:24 ` David Hildenbrand
2021-09-30 6:06 ` [PATCH v3 0/3] " Markus Armbruster
3 siblings, 0 replies; 5+ messages in thread
From: David Hildenbrand @ 2021-09-29 16:24 UTC (permalink / raw)
To: qemu-devel
Cc: Michael S . Tsirkin, Michal Privoznik, David Hildenbrand,
Markus Armbruster, Dr. David Alan Gilbert, Igor Mammedov,
Eric Blake
We want to rate-limit MEMORY_DEVICE_SIZE_CHANGE events per device,
otherwise we can lose some events for devices. We can now use the
qom-path to reliably map an event to a device and make rate-limiting
device-aware.
This was noticed by starting a VM with two virtio-mem devices that each
have a requested size > 0. The Linux guest will initialize both devices
in parallel, resulting in losing MEMORY_DEVICE_SIZE_CHANGE events for
one of the devices.
Fixes: 722a3c783ef4 ("virtio-pci: Send qapi events when the virtio-mem size changes")
Suggested-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: David Hildenbrand <david@redhat.com>
---
monitor/monitor.c | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/monitor/monitor.c b/monitor/monitor.c
index 46a171bca6..21c7a68758 100644
--- a/monitor/monitor.c
+++ b/monitor/monitor.c
@@ -474,6 +474,10 @@ static unsigned int qapi_event_throttle_hash(const void *key)
hash += g_str_hash(qdict_get_str(evstate->data, "node-name"));
}
+ if (evstate->event == QAPI_EVENT_MEMORY_DEVICE_SIZE_CHANGE) {
+ hash += g_str_hash(qdict_get_str(evstate->data, "qom-path"));
+ }
+
return hash;
}
@@ -496,6 +500,11 @@ static gboolean qapi_event_throttle_equal(const void *a, const void *b)
qdict_get_str(evb->data, "node-name"));
}
+ if (eva->event == QAPI_EVENT_MEMORY_DEVICE_SIZE_CHANGE) {
+ return !strcmp(qdict_get_str(eva->data, "qom-path"),
+ qdict_get_str(evb->data, "qom-path"));
+ }
+
return TRUE;
}
--
2.31.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH v3 0/3] monitor: Rate-limit MEMORY_DEVICE_SIZE_CHANGE qapi events per device
2021-09-29 16:24 [PATCH v3 0/3] monitor: Rate-limit MEMORY_DEVICE_SIZE_CHANGE qapi events per device David Hildenbrand
` (2 preceding siblings ...)
2021-09-29 16:24 ` [PATCH v3 3/3] monitor: Rate-limit MEMORY_DEVICE_SIZE_CHANGE qapi events per device David Hildenbrand
@ 2021-09-30 6:06 ` Markus Armbruster
3 siblings, 0 replies; 5+ messages in thread
From: Markus Armbruster @ 2021-09-30 6:06 UTC (permalink / raw)
To: David Hildenbrand
Cc: Michael S . Tsirkin, Michal Privoznik, qemu-devel,
Dr. David Alan Gilbert, Igor Mammedov, Eric Blake
David Hildenbrand <david@redhat.com> writes:
> Some fixes for virtio-mem-pci, to properly handle MEMORY_DEVICE_SIZE_CHANGE
> events, especially not dropping events of some devices when rate-limiting.
Series
Reviewed-by: Markus Armbruster <armbru@redhat.com>
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2021-09-30 6:35 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-29 16:24 [PATCH v3 0/3] monitor: Rate-limit MEMORY_DEVICE_SIZE_CHANGE qapi events per device David Hildenbrand
2021-09-29 16:24 ` [PATCH v3 1/3] virtio-mem-pci: Fix memory leak when creating MEMORY_DEVICE_SIZE_CHANGE event David Hildenbrand
2021-09-29 16:24 ` [PATCH v3 2/3] qapi: Include qom-path in MEMORY_DEVICE_SIZE_CHANGE qapi events David Hildenbrand
2021-09-29 16:24 ` [PATCH v3 3/3] monitor: Rate-limit MEMORY_DEVICE_SIZE_CHANGE qapi events per device David Hildenbrand
2021-09-30 6:06 ` [PATCH v3 0/3] " Markus Armbruster
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.