Re: [PATCH v4 3/3] vhost/vsock: keep IOTLB across feature updates
From: Stefano Garzarella <sgarzare@redhat.com>
Date: 2026-08-14 08:02:37
Also in:
kvm, lkml, virtualization
On Fri, Aug 14, 2026 at 03:29:03PM +0800, Jia Jia wrote:
quoted hunk ↗ jump to hunk
VHOST_SET_FEATURES is also used to update logging while a device is running. When ACCESS_PLATFORM stays enabled, allocating a new empty IOTLB on every call drops valid translations and forces avoidable misses. Initialize the device IOTLB only when one does not already exist. Fixes: e13a6915a03f ("vhost/vsock: add IOTLB API support") Signed-off-by: Jia Jia <redacted> --- drivers/vhost/vsock.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)diff --git a/drivers/vhost/vsock.c b/drivers/vhost/vsock.c index b69c260eaeff..9142fa1143b2 100644 --- a/drivers/vhost/vsock.c +++ b/drivers/vhost/vsock.c@@ -869,6 +869,7 @@ static int vhost_vsock_set_features(struct vhost_vsock *vsock, u64 features)vsock->dev.iotlb) vhost_clear_device_iotlb(&vsock->dev);
Ah, okay, now I see why you did it in the other patch, but if we move dev.iotlb checks in the functions we can still do that.
- if ((features & (1ULL << VIRTIO_F_ACCESS_PLATFORM))) {
+ if ((features & (1ULL << VIRTIO_F_ACCESS_PLATFORM)) &&
+ !vsock->dev.iotlb) {
if (vhost_init_device_iotlb(&vsock->dev))IIUC vhost_init_device_iotlb() handles the case where dev.iotlb is already initialized and override it. Here we are preventing that. Will we do the same in vhost-net? If yes, all the callers will call vhost_init_device_iotlb() with `dev.iotlb` NULL, so should we remove that behaviour and add the check we are adding here inside the vhost_init_device_iotlb()? Or there is an use case where vhost_init_device_iotlb() is called with an already initialized dev.iotlb ? Thanks, Stefano
goto err; -- 2.34.1