Hi Alex,

On 21/3/22 16:30, Alex Bennée wrote:
At a couple of hundred bytes per notifier allocating one for every
potential queue is very wasteful as most devices only have a few
queues. Instead of having this handled statically dynamically assign
them and track in a GPtrArray.

[AJB: it's hard to trigger the vhost notifiers code, I assume as it
requires a KVM guest with appropriate backend]

Signed-off-by: Alex Bennée <alex.ben...@linaro.org>
---
  include/hw/virtio/vhost-user.h | 42 ++++++++++++++++-
  hw/virtio/vhost-user.c         | 83 +++++++++++++++++++++++++++-------
  hw/virtio/trace-events         |  1 +
  3 files changed, 108 insertions(+), 18 deletions(-)


  void vhost_user_cleanup(VhostUserState *user)
  {
-    int i;
-    VhostUserHostNotifier *n;
-
      if (!user->chr) {
          return;
      }
      memory_region_transaction_begin();
-    for (i = 0; i < VIRTIO_QUEUE_MAX; i++) {
-        n = &user->notifier[i];
-        vhost_user_host_notifier_remove(user, NULL, i);
-        object_unparent(OBJECT(&n->mr));
-    }
+    user->notifiers = (GPtrArray *) g_ptr_array_free(user->notifiers, true);

Since you replaced an iteration by a single function call, the MR transaction guards can be removed now, right?

      memory_region_transaction_commit();
      user->chr = NULL;
  }

Reply via email to