[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 2/9] vhost-vdpa: Set discarding of RAM broken when initializing th
From: |
Michael S. Tsirkin |
Subject: |
[PULL 2/9] vhost-vdpa: Set discarding of RAM broken when initializing the backend |
Date: |
Mon, 1 Nov 2021 19:44:25 -0400 |
From: David Hildenbrand <david@redhat.com>
Similar to VFIO, vDPA will go ahead an map+pin all guest memory. Memory
that used to be discarded will get re-populated and if we
discard+re-access memory after mapping+pinning, the pages mapped into the
vDPA IOMMU will go out of sync with the actual pages mapped into the user
space page tables.
Set discarding of RAM broken such that:
- virtio-mem and vhost-vdpa run mutually exclusive
- virtio-balloon is inhibited and no memory discards will get issued
In the future, we might be able to support coordinated discarding of RAM
as used by virtio-mem and already supported by vfio via the
RamDiscardManager.
Acked-by: Jason Wang <jasowang@redhat.com>
Cc: Jason Wang <jasowang@redhat.com>
Cc: Michael S. Tsirkin <mst@redhat.com>
Cc: Cindy Lu <lulu@redhat.com>
Signed-off-by: David Hildenbrand <david@redhat.com>
Message-Id: <20211027130324.59791-1-david@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Stefano Garzarella <sgarzare@redhat.com>
---
hw/virtio/vhost-vdpa.c | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/hw/virtio/vhost-vdpa.c b/hw/virtio/vhost-vdpa.c
index 12661fd5b1..0d8051426c 100644
--- a/hw/virtio/vhost-vdpa.c
+++ b/hw/virtio/vhost-vdpa.c
@@ -331,6 +331,17 @@ static int vhost_vdpa_init(struct vhost_dev *dev, void
*opaque, Error **errp)
struct vhost_vdpa *v;
assert(dev->vhost_ops->backend_type == VHOST_BACKEND_TYPE_VDPA);
trace_vhost_vdpa_init(dev, opaque);
+ int ret;
+
+ /*
+ * Similar to VFIO, we end up pinning all guest memory and have to
+ * disable discarding of RAM.
+ */
+ ret = ram_block_discard_disable(true);
+ if (ret) {
+ error_report("Cannot set discarding of RAM broken");
+ return ret;
+ }
v = opaque;
v->dev = dev;
@@ -442,6 +453,8 @@ static int vhost_vdpa_cleanup(struct vhost_dev *dev)
memory_listener_unregister(&v->listener);
dev->opaque = NULL;
+ ram_block_discard_disable(false);
+
return 0;
}
--
MST
- [PULL 0/9] pc,pci,virtio: features, fixes, Michael S. Tsirkin, 2021/11/01
- [PULL 1/9] qtest: fix 'expression is always false' build failure in qtest_has_accel(), Michael S. Tsirkin, 2021/11/01
- [PULL 2/9] vhost-vdpa: Set discarding of RAM broken when initializing the backend,
Michael S. Tsirkin <=
- [PULL 3/9] hw/acpi: Add VIOT table, Michael S. Tsirkin, 2021/11/01
- [PULL 4/9] hw/i386/pc: Remove x86_iommu_get_type(), Michael S. Tsirkin, 2021/11/01
- [PULL 6/9] hw/i386/pc: Allow instantiating a virtio-iommu device, Michael S. Tsirkin, 2021/11/01
- [PULL 5/9] hw/i386/pc: Move IOMMU singleton into PCMachineState, Michael S. Tsirkin, 2021/11/01
- [PULL 7/9] pci: Define pci_bus_dev_fn/pci_bus_fn/pci_bus_ret_fn, Michael S. Tsirkin, 2021/11/01
- [PULL 8/9] pci: Export pci_for_each_device_under_bus*(), Michael S. Tsirkin, 2021/11/01
- [PULL 9/9] hw/i386: fix vmmouse registration, Michael S. Tsirkin, 2021/11/01
- Re: [PULL 0/9] pc,pci,virtio: features, fixes, Richard Henderson, 2021/11/02