All of lore.kernel.org
 help / color / mirror / Atom feed
From: David Hildenbrand <david@redhat.com>
To: qemu-devel@nongnu.org
Cc: "David Hildenbrand" <david@redhat.com>,
	"Paolo Bonzini" <pbonzini@redhat.com>,
	"Igor Mammedov" <imammedo@redhat.com>,
	"Xiao Guangrong" <xiaoguangrong.eric@gmail.com>,
	"Michael S. Tsirkin" <mst@redhat.com>,
	"Peter Xu" <peterx@redhat.com>,
	"Philippe Mathieu-Daudé" <philmd@linaro.org>,
	"Eduardo Habkost" <eduardo@habkost.net>,
	"Marcel Apfelbaum" <marcel.apfelbaum@gmail.com>,
	"Yanan Wang" <wangyanan55@huawei.com>,
	"Michal Privoznik" <mprivozn@redhat.com>,
	"Daniel P . Berrangé" <berrange@redhat.com>,
	"Gavin Shan" <gshan@redhat.com>,
	"Alex Williamson" <alex.williamson@redhat.com>,
	"Stefan Hajnoczi" <stefanha@redhat.com>,
	"Maciej S . Szmigiero" <mail@maciej.szmigiero.name>,
	kvm@vger.kernel.org
Subject: [PATCH v3 02/16] vhost: Remove vhost_backend_can_merge() callback
Date: Fri,  8 Sep 2023 16:21:22 +0200	[thread overview]
Message-ID: <20230908142136.403541-3-david@redhat.com> (raw)
In-Reply-To: <20230908142136.403541-1-david@redhat.com>

Checking whether the memory regions are equal is sufficient: if they are
equal, then most certainly the contained fd is equal.

The whole vhost-user memslot handling is suboptimal and overly
complicated. We shouldn't have to lookup a RAM memory regions we got
notified about in vhost_user_get_mr_data() using a host pointer. But that
requires a bigger rework -- especially an alternative vhost_set_mem_table()
backend call that simply consumes MemoryRegionSections.

For now, let's just drop vhost_backend_can_merge().

Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
Reviewed-by: Igor Mammedov <imammedo@redhat.com>
Acked-by: Igor Mammedov <imammedo@redhat.com>
Reviewed-by: Peter Xu <peterx@redhat.com>
Signed-off-by: David Hildenbrand <david@redhat.com>
---
 hw/virtio/vhost-user.c            | 14 --------------
 hw/virtio/vhost-vdpa.c            |  1 -
 hw/virtio/vhost.c                 |  6 +-----
 include/hw/virtio/vhost-backend.h |  4 ----
 4 files changed, 1 insertion(+), 24 deletions(-)

diff --git a/hw/virtio/vhost-user.c b/hw/virtio/vhost-user.c
index 1e7553352a..e6de930872 100644
--- a/hw/virtio/vhost-user.c
+++ b/hw/virtio/vhost-user.c
@@ -2205,19 +2205,6 @@ static int vhost_user_migration_done(struct vhost_dev *dev, char* mac_addr)
     return -ENOTSUP;
 }
 
-static bool vhost_user_can_merge(struct vhost_dev *dev,
-                                 uint64_t start1, uint64_t size1,
-                                 uint64_t start2, uint64_t size2)
-{
-    ram_addr_t offset;
-    int mfd, rfd;
-
-    (void)vhost_user_get_mr_data(start1, &offset, &mfd);
-    (void)vhost_user_get_mr_data(start2, &offset, &rfd);
-
-    return mfd == rfd;
-}
-
 static int vhost_user_net_set_mtu(struct vhost_dev *dev, uint16_t mtu)
 {
     VhostUserMsg msg;
@@ -2764,7 +2751,6 @@ const VhostOps user_ops = {
         .vhost_set_vring_enable = vhost_user_set_vring_enable,
         .vhost_requires_shm_log = vhost_user_requires_shm_log,
         .vhost_migration_done = vhost_user_migration_done,
-        .vhost_backend_can_merge = vhost_user_can_merge,
         .vhost_net_set_mtu = vhost_user_net_set_mtu,
         .vhost_set_iotlb_callback = vhost_user_set_iotlb_callback,
         .vhost_send_device_iotlb_msg = vhost_user_send_device_iotlb_msg,
diff --git a/hw/virtio/vhost-vdpa.c b/hw/virtio/vhost-vdpa.c
index 42f2a4bae9..8f07bee041 100644
--- a/hw/virtio/vhost-vdpa.c
+++ b/hw/virtio/vhost-vdpa.c
@@ -1508,7 +1508,6 @@ const VhostOps vdpa_ops = {
         .vhost_set_config = vhost_vdpa_set_config,
         .vhost_requires_shm_log = NULL,
         .vhost_migration_done = NULL,
-        .vhost_backend_can_merge = NULL,
         .vhost_net_set_mtu = NULL,
         .vhost_set_iotlb_callback = NULL,
         .vhost_send_device_iotlb_msg = NULL,
diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c
index c1e6148833..c16ad14535 100644
--- a/hw/virtio/vhost.c
+++ b/hw/virtio/vhost.c
@@ -728,11 +728,7 @@ static void vhost_region_add_section(struct vhost_dev *dev,
             size_t offset = mrs_gpa - prev_gpa_start;
 
             if (prev_host_start + offset == mrs_host &&
-                section->mr == prev_sec->mr &&
-                (!dev->vhost_ops->vhost_backend_can_merge ||
-                 dev->vhost_ops->vhost_backend_can_merge(dev,
-                    mrs_host, mrs_size,
-                    prev_host_start, prev_size))) {
+                section->mr == prev_sec->mr) {
                 uint64_t max_end = MAX(prev_host_end, mrs_host + mrs_size);
                 need_add = false;
                 prev_sec->offset_within_address_space =
diff --git a/include/hw/virtio/vhost-backend.h b/include/hw/virtio/vhost-backend.h
index df2821ddae..12d578824b 100644
--- a/include/hw/virtio/vhost-backend.h
+++ b/include/hw/virtio/vhost-backend.h
@@ -86,9 +86,6 @@ typedef int (*vhost_set_vring_enable_op)(struct vhost_dev *dev,
 typedef bool (*vhost_requires_shm_log_op)(struct vhost_dev *dev);
 typedef int (*vhost_migration_done_op)(struct vhost_dev *dev,
                                        char *mac_addr);
-typedef bool (*vhost_backend_can_merge_op)(struct vhost_dev *dev,
-                                           uint64_t start1, uint64_t size1,
-                                           uint64_t start2, uint64_t size2);
 typedef int (*vhost_vsock_set_guest_cid_op)(struct vhost_dev *dev,
                                             uint64_t guest_cid);
 typedef int (*vhost_vsock_set_running_op)(struct vhost_dev *dev, int start);
@@ -163,7 +160,6 @@ typedef struct VhostOps {
     vhost_set_vring_enable_op vhost_set_vring_enable;
     vhost_requires_shm_log_op vhost_requires_shm_log;
     vhost_migration_done_op vhost_migration_done;
-    vhost_backend_can_merge_op vhost_backend_can_merge;
     vhost_vsock_set_guest_cid_op vhost_vsock_set_guest_cid;
     vhost_vsock_set_running_op vhost_vsock_set_running;
     vhost_set_iotlb_callback_op vhost_set_iotlb_callback;
-- 
2.41.0


  parent reply	other threads:[~2023-09-08 14:22 UTC|newest]

Thread overview: 39+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-08 14:21 [PATCH v3 00/16] virtio-mem: Expose device memory through multiple memslots David Hildenbrand
2023-09-08 14:21 ` [PATCH v3 01/16] vhost: Rework memslot filtering and fix "used_memslot" tracking David Hildenbrand
2023-09-08 14:21 ` David Hildenbrand [this message]
2023-09-08 14:21 ` [PATCH v3 03/16] softmmu/physmem: Fixup qemu_ram_block_from_host() documentation David Hildenbrand
2023-09-08 14:21 ` [PATCH v3 04/16] kvm: Return number of free memslots David Hildenbrand
2023-09-16 16:05   ` Maciej S. Szmigiero
2023-09-08 14:21 ` [PATCH v3 05/16] vhost: " David Hildenbrand
2023-09-16 16:07   ` Maciej S. Szmigiero
2023-09-08 14:21 ` [PATCH v3 06/16] memory-device: Support memory devices with multiple memslots David Hildenbrand
2023-09-16 16:27   ` Maciej S. Szmigiero
2023-09-08 14:21 ` [PATCH v3 07/16] stubs: Rename qmp_memory_device.c to memory_device.c David Hildenbrand
2023-09-16 16:28   ` Maciej S. Szmigiero
2023-09-08 14:21 ` [PATCH v3 08/16] memory-device: Track required and actually used memslots in DeviceMemoryState David Hildenbrand
2023-09-16 16:36   ` Maciej S. Szmigiero
2023-09-08 14:21 ` [PATCH v3 09/16] memory-device,vhost: Support memory devices that dynamically consume memslots David Hildenbrand
2023-09-08 14:21   ` [PATCH v3 09/16] memory-device, vhost: " David Hildenbrand
2023-09-16 17:52   ` Maciej S. Szmigiero
2023-09-16 17:52     ` [PATCH v3 09/16] memory-device,vhost: " Maciej S. Szmigiero
2023-09-08 14:21 ` [PATCH v3 10/16] kvm: Add stub for kvm_get_max_memslots() David Hildenbrand
2023-09-16 17:13   ` Maciej S. Szmigiero
2023-09-08 14:21 ` [PATCH v3 11/16] vhost: Add vhost_get_max_memslots() David Hildenbrand
2023-09-16 17:16   ` Maciej S. Szmigiero
2023-09-08 14:21 ` [PATCH v3 12/16] memory-device,vhost: Support automatic decision on the number of memslots David Hildenbrand
2023-09-08 14:21   ` [PATCH v3 12/16] memory-device, vhost: " David Hildenbrand
2023-09-17 10:46   ` [PATCH v3 12/16] memory-device,vhost: " Maciej S. Szmigiero
2023-09-17 10:46     ` [PATCH v3 12/16] memory-device, vhost: " Maciej S. Szmigiero
2023-09-18 12:33     ` David Hildenbrand
2023-09-18 12:33       ` [PATCH v3 12/16] memory-device,vhost: " David Hildenbrand
2023-09-08 14:21 ` [PATCH v3 13/16] memory: Clarify mapping requirements for RamDiscardManager David Hildenbrand
2023-09-16 17:31   ` Maciej S. Szmigiero
2023-09-08 14:21 ` [PATCH v3 14/16] virtio-mem: Expose device memory via multiple memslots if enabled David Hildenbrand
2023-09-17 11:47   ` Maciej S. Szmigiero
2023-09-19  8:08     ` David Hildenbrand
2023-09-08 14:21 ` [PATCH v3 15/16] memory,vhost: Allow for marking memory device memory regions unmergeable David Hildenbrand
2023-09-08 14:21   ` [PATCH v3 15/16] memory, vhost: " David Hildenbrand
2023-09-08 14:21 ` [PATCH v3 16/16] virtio-mem: Mark memslot alias " David Hildenbrand
2023-09-11  7:45 ` [PATCH v3 00/16] virtio-mem: Expose device memory through multiple memslots David Hildenbrand
2023-09-19  8:20   ` David Hildenbrand
2023-09-19  9:34     ` David Hildenbrand

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=20230908142136.403541-3-david@redhat.com \
    --to=david@redhat.com \
    --cc=alex.williamson@redhat.com \
    --cc=berrange@redhat.com \
    --cc=eduardo@habkost.net \
    --cc=gshan@redhat.com \
    --cc=imammedo@redhat.com \
    --cc=kvm@vger.kernel.org \
    --cc=mail@maciej.szmigiero.name \
    --cc=marcel.apfelbaum@gmail.com \
    --cc=mprivozn@redhat.com \
    --cc=mst@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=peterx@redhat.com \
    --cc=philmd@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@redhat.com \
    --cc=wangyanan55@huawei.com \
    --cc=xiaoguangrong.eric@gmail.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 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.