virtio-pci: correctly set virtio pci queue mem multiplier
PATCH 1/1 virtio-pci: correctly set virtio pci queue mem multiplier
Currently, virtio_pci_queue_mem_mult function returns 4K when VIRTIO_PCI_FLAG_PAGE_PER_VQ is set. But this is not correct when host has page size as 64K.
This patch fixes the same.
--- hw/virtio/virtio-pci.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
hw/virtio/virtio-pci.c +1 -3
@@ -316,12 +316,10 @@ static bool virtio_pci_ioeventfd_enabled(DeviceState *d)return (proxy->flags &VIRTIO_PCI_FLAG_USE_IOEVENTFD ) !=0 ; } -#define QEMU_VIRTIO_PCI_QUEUE_MEM_MULT 0x1000 -static inline int virtio_pci_queue_mem_mult (struct VirtIOPCIProxy *proxy) {return (proxy->flags &VIRTIO_PCI_FLAG_PAGE_PER_VQ ) ? -QEMU_VIRTIO_PCI_QUEUE_MEM_MULT :4 ; +qemu_real_host_page_size () :4 ; } static int virtio_pci_ioeventfd_assign(DeviceState *d, EventNotifier *notifier,
Signature · 1 line
2.25.1
Quoted 6 lines · Srujana Challa
Currently,
virtio_pci_queue_mem_multfunction returns 4K whenVIRTIO_PCI_FLAG_PAGE_PER_VQis set. But this is not correct when host has page size as 64K.
This patch fixes the same.Signed-off-by Srujana Challa <[email protected]>
You can't tweak guest visible values like this without compat machinery. It's also going to consume a ton more phys memory - can this break any configs?
Why is this a problem? Just with vdpa?
Quoted 24 lines
--- hw/virtio/virtio-pci.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)hw/virtio/virtio-pci.c +1
-3@@ -316,12 +316,10 @@ static bool virtio_pci_ioeventfd_enabled(DeviceState *d)return (proxy->flags &VIRTIO_PCI_FLAG_USE_IOEVENTFD ) !=0 ; } -#define QEMU_VIRTIO_PCI_QUEUE_MEM_MULT 0x1000 -static inline int virtio_pci_queue_mem_mult (struct VirtIOPCIProxy *proxy) {return (proxy->flags &VIRTIO_PCI_FLAG_PAGE_PER_VQ ) ? -QEMU_VIRTIO_PCI_QUEUE_MEM_MULT :4 ; +qemu_real_host_page_size () :4 ; } static int virtio_pci_ioeventfd_assign(DeviceState *d, EventNotifier *notifier,Signature · 1 line
2.25.1
Quoted 12 lines
Subject: [EXT] Re: [PATCH] virtio-pci: correctly set virtio pci queue mem multiplier
External Email
----------------------------------------------------------------------
Quoted 5 lines · Srujana Challa
Currently,
virtio_pci_queue_mem_multfunction returns 4K whenVIRTIO_PCI_FLAG_PAGE_PER_VQis set. But this is not correct when host has page size as 64K.
This patch fixes the same.
Quoted 5 lines
Quoted 1 line
Signed-off-by Srujana Challa <[email protected]>You can't tweak guest visible values like this without compat machinery. It's also going to consume a ton more phys memory - can this break any configs? Why is this a problem? Just with vdpa?
We are observing the issue with vdpa when host has page size of 64K. We haven't verified any other backends. I think, any backend that uses below API would fail if host has page size other than 4K right?
And also as per VIRTIO_PCI_FLAG_PAGE_PER_VQ, it should be equal to page_size right?
static int virtio_pci_set_host_notifier_mr(DeviceState *d, int n,
MemoryRegion *mr, bool assign)
{
VirtIOPCIProxy *proxy = to_virtio_pci_proxy(d);
int offset;
if (n >= VIRTIO_QUEUE_MAX || !virtio_pci_modern(proxy) ||
virtio_pci_queue_mem_mult(proxy) != memory_region_size(mr)) {
return -1;
}Quoted 26 lines
hw/virtio/virtio-pci.c static bool
Quoted 10 lines
--- hw/virtio/virtio-pci.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)hw/virtio/virtio-pci.c index renamed from hw/virtio/virtio-pci.c +0
-0
e433879542..028df99991100644hw/virtio/virtio-pci.c +0
-0@@ -316,12 +316,10 @@ static bool
virtio_pci_ioeventfd_enabled(DeviceState *d)Quoted 15 lines
hw/virtio/virtio-pci.c +1
-4return (proxy->flags &VIRTIO_PCI_FLAG_USE_IOEVENTFD ) !=0 ; } -#define QEMU_VIRTIO_PCI_QUEUE_MEM_MULT 0x1000 -static inline int virtio_pci_queue_mem_mult (struct VirtIOPCIProxy *proxy) {return (proxy->flags &VIRTIO_PCI_FLAG_PAGE_PER_VQ ) ? -QEMU_VIRTIO_PCI_QUEUE_MEM_MULT :4 ; +qemu_real_host_page_size () :4 ; } static int virtio_pci_ioeventfd_assign(DeviceState *d, EventNotifier *notifier, --2.25.1
Quoted 26 lines · Srujana Challa
Quoted 12 lines
Subject: [EXT] Re: [PATCH] virtio-pci: correctly set virtio pci queue mem multiplier
External Email
----------------------------------------------------------------------
Quoted 5 lines · Srujana Challa
Currently,
virtio_pci_queue_mem_multfunction returns 4K whenVIRTIO_PCI_FLAG_PAGE_PER_VQis set. But this is not correct when host has page size as 64K.
This patch fixes the same.Quoted 5 lines
Quoted 1 line
Signed-off-by Srujana Challa <[email protected]>You can't tweak guest visible values like this without compat machinery. It's also going to consume a ton more phys memory - can this break any configs? Why is this a problem? Just with vdpa?
We are observing the issue with vdpa when host has page size of 64K. We haven't verified any other backends. I think, any backend that uses below API would fail if host has page size other than 4K right?
And also as perVIRTIO_PCI_FLAG_PAGE_PER_VQ, it should be equal topage_sizeright?static int virtio_pci_set_host_notifier_mr(DeviceState *d, int n,
MemoryRegion *mr, bool assign)
Quoted 8 lines
{
VirtIOPCIProxy *proxy = to_virtio_pci_proxy(d);
int offset;
if (n >= VIRTIO_QUEUE_MAX || !virtio_pci_modern(proxy) ||
virtio_pci_queue_mem_mult(proxy) != memory_region_size(mr)) {
return -1;
}Yes but not everyone uses that right? Plain virtio in software with no tricks doesn't care?
Quoted 26 lines
Quoted 26 lines
hw/virtio/virtio-pci.c static bool
Quoted 10 lines
--- hw/virtio/virtio-pci.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)hw/virtio/virtio-pci.c index renamed from hw/virtio/virtio-pci.c +0
-0
e433879542..028df99991100644hw/virtio/virtio-pci.c +0
-0@@ -316,12 +316,10 @@ static bool
virtio_pci_ioeventfd_enabled(DeviceState *d)Quoted 15 lines
hw/virtio/virtio-pci.c +1
-4return (proxy->flags &VIRTIO_PCI_FLAG_USE_IOEVENTFD ) !=0 ; } -#define QEMU_VIRTIO_PCI_QUEUE_MEM_MULT 0x1000 -static inline int virtio_pci_queue_mem_mult (struct VirtIOPCIProxy *proxy) {return (proxy->flags &VIRTIO_PCI_FLAG_PAGE_PER_VQ ) ? -QEMU_VIRTIO_PCI_QUEUE_MEM_MULT :4 ; +qemu_real_host_page_size () :4 ; } static int virtio_pci_ioeventfd_assign(DeviceState *d, EventNotifier *notifier, --2.25.1
Quoted 35 lines
Subject: Re: [EXT] Re: [PATCH] virtio-pci: correctly set virtio pci queue mem multiplier
Quoted 12 lines · Srujana Challa
Quoted 12 lines
Subject: [EXT] Re: [PATCH] virtio-pci: correctly set virtio pci queue mem multiplier
External Email
--------------------------------------------------------------------
Quoted 5 lines · Srujana Challa
Currently,
virtio_pci_queue_mem_multfunction returns 4K whenVIRTIO_PCI_FLAG_PAGE_PER_VQis set. But this is not correct when host has page size as 64K.
This patch fixes the same.Quoted 4 lines
Quoted 4 lines
Quoted 1 line
Signed-off-by Srujana Challa <[email protected]>You can't tweak guest visible values like this without compat machinery. It's also going to consume a ton more phys memory - can this
break any configs?
Quoted 14 lines
Quoted 1 line
Why is this a problem? Just with vdpa?
We are observing the issue with vdpa when host has page size of 64K. We haven't verified any other backends. I think, any backend that uses below API would fail if host has page size other than 4K right? And also as per
VIRTIO_PCI_FLAG_PAGE_PER_VQ, it should be equal topage_sizeright?static int virtio_pci_set_host_notifier_mr(DeviceState *d, int n,
MemoryRegion *mr, boolassign) { VirtIOPCIProxy *proxy = to_virtio_pci_proxy(d); int offset;
Quoted 7 lines
Quoted 4 lines
if (n >= VIRTIO_QUEUE_MAX || !virtio_pci_modern(proxy) || virtio_pci_queue_mem_mult(proxy) != memory_region_size(mr)) { return -1; }Yes but not everyone uses that right? Plain virtio in software with no tricks doesn't care?
Yes, any other better ways to address this issue.?
Quoted 29 lines
Quoted 29 lines
Quoted 29 lines
hw/virtio/virtio-pci.c static bool
Quoted 12 lines
--- hw/virtio/virtio-pci.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)hw/virtio/virtio-pci.c index renamed from hw/virtio/virtio-pci.c +0
-0
e433879542..028df99991100644hw/virtio/virtio-pci.c +0
-0@@ -316,12 +316,10 @@ static bool
virtio_pci_ioeventfd_enabled(DeviceState *d)Quoted 16 lines
hw/virtio/virtio-pci.c +1
-3return (proxy->flags &VIRTIO_PCI_FLAG_USE_IOEVENTFD ) !=0 ; } -#define QEMU_VIRTIO_PCI_QUEUE_MEM_MULT 0x1000 -static inline int virtio_pci_queue_mem_mult (struct VirtIOPCIProxy *proxy) {return (proxy->flags &VIRTIO_PCI_FLAG_PAGE_PER_VQ ) ? -QEMU_VIRTIO_PCI_QUEUE_MEM_MULT :4 ; +qemu_real_host_page_size () :4 ; } static int virtio_pci_ioeventfd_assign(DeviceState *d,EventNotifier *notifier,
--
2.25.1
Quoted 35 lines · Srujana Challa
Quoted 35 lines
Subject: Re: [EXT] Re: [PATCH] virtio-pci: correctly set virtio pci queue mem multiplier
Quoted 12 lines · Srujana Challa
Quoted 12 lines
Subject: [EXT] Re: [PATCH] virtio-pci: correctly set virtio pci queue mem multiplier
External Email
--------------------------------------------------------------------
Quoted 5 lines · Srujana Challa
Currently,
virtio_pci_queue_mem_multfunction returns 4K whenVIRTIO_PCI_FLAG_PAGE_PER_VQis set. But this is not correct when host has page size as 64K.
This patch fixes the same.Quoted 4 lines
Quoted 4 lines
Quoted 1 line
Signed-off-by Srujana Challa <[email protected]>You can't tweak guest visible values like this without compat machinery. It's also going to consume a ton more phys memory - can this
break any configs?
Quoted 14 lines
Quoted 1 line
Why is this a problem? Just with vdpa?
We are observing the issue with vdpa when host has page size of 64K. We haven't verified any other backends. I think, any backend that uses below API would fail if host has page size other than 4K right? And also as per
VIRTIO_PCI_FLAG_PAGE_PER_VQ, it should be equal topage_sizeright?static int virtio_pci_set_host_notifier_mr(DeviceState *d, int n,
MemoryRegion *mr, boolassign) { VirtIOPCIProxy *proxy = to_virtio_pci_proxy(d); int offset;
Quoted 8 lines
Quoted 7 lines
Quoted 4 lines
if (n >= VIRTIO_QUEUE_MAX || !virtio_pci_modern(proxy) || virtio_pci_queue_mem_mult(proxy) != memory_region_size(mr)) { return -1; }Yes but not everyone uses that right? Plain virtio in software with no tricks doesn't care?
Yes, any other better ways to address this issue.?
Add a property that vdpa can set?
Quoted 29 lines
Quoted 29 lines
Quoted 29 lines
Quoted 29 lines
hw/virtio/virtio-pci.c static bool
Quoted 12 lines
--- hw/virtio/virtio-pci.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)hw/virtio/virtio-pci.c index renamed from hw/virtio/virtio-pci.c +0
-0
e433879542..028df99991100644hw/virtio/virtio-pci.c +0
-0@@ -316,12 +316,10 @@ static bool
virtio_pci_ioeventfd_enabled(DeviceState *d)Quoted 16 lines
hw/virtio/virtio-pci.c +1
-3return (proxy->flags &VIRTIO_PCI_FLAG_USE_IOEVENTFD ) !=0 ; } -#define QEMU_VIRTIO_PCI_QUEUE_MEM_MULT 0x1000 -static inline int virtio_pci_queue_mem_mult (struct VirtIOPCIProxy *proxy) {return (proxy->flags &VIRTIO_PCI_FLAG_PAGE_PER_VQ ) ? -QEMU_VIRTIO_PCI_QUEUE_MEM_MULT :4 ; +qemu_real_host_page_size () :4 ; } static int virtio_pci_ioeventfd_assign(DeviceState *d,EventNotifier *notifier,
--
2.25.1
Quoted 54 lines
-----Original Message-----
From: Michael S. Tsirkin <[email protected]>
Sent: Tuesday, February 13, 2024 9:23 PM
To: Srujana Challa <[email protected]>
Cc: [email protected]; Vamsi Krishna Attunuru <[email protected]>; Jerin Jacob <[email protected]>
Subject: Re: [EXT] Re: [PATCH] virtio-pci: correctly set virtio pci queue mem multiplierQuoted 42 lines · Srujana Challa
Quoted 42 lines
Subject: Re: [EXT] Re: [PATCH] virtio-pci: correctly set virtio pci queue mem multiplier
Quoted 13 lines · Srujana Challa
Quoted 13 lines
Subject: [EXT] Re: [PATCH] virtio-pci: correctly set virtio pci queue mem multiplier
External Email
----------------------------------------------------------------
----Quoted 5 lines · Srujana Challa
Currently,
virtio_pci_queue_mem_multfunction returns 4K whenVIRTIO_PCI_FLAG_PAGE_PER_VQis set. But this is not correct when host has page size as 64K.
This patch fixes the same.Quoted 5 lines
Quoted 5 lines
Quoted 1 line
Signed-off-by Srujana Challa <[email protected]>You can't tweak guest visible values like this without compat machinery. It's also going to consume a ton more phys memory - can this
break any configs?
Quoted 18 lines
Quoted 1 line
Why is this a problem? Just with vdpa?
We are observing the issue with vdpa when host has page size of 64K. We haven't verified any other backends. I think, any backend that uses below API would fail if host has page size other than 4K right? And also as per
VIRTIO_PCI_FLAG_PAGE_PER_VQ, it should be equal topage_sizeright?static int virtio_pci_set_host_notifier_mr(DeviceState *d, int n,
MemoryRegion *mr, boolassign) { VirtIOPCIProxy *proxy = to_virtio_pci_proxy(d); int offset; if (n >= VIRTIO_QUEUE_MAX || !virtio_pci_modern(proxy) || virtio_pci_queue_mem_mult(proxy) != memory_region_size(mr)) { return -1; }
Quoted 5 lines
Quoted 3 lines
Quoted 2 lines
Yes but not everyone uses that right? Plain virtio in software with no tricks doesn't care?
Yes, any other better ways to address this issue.?
Add a property that vdpa can set?
I think, as per VIRTIO_PCI_FLAG_PAGE_PER_VQ flag, it should be equal to host Page_size. May be for software use, we can introduce one more flag, that could be irrespective of host page_size?
Quoted 33 lines
Quoted 33 lines
Quoted 33 lines
Quoted 33 lines
Quoted 33 lines
hw/virtio/virtio-pci.c static bool
Quoted 15 lines
--- hw/virtio/virtio-pci.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)hw/virtio/virtio-pci.c +0
-0index
e433879542..028df99991100644hw/virtio/virtio-pci.c +0
-0@@ -316,12 +316,10 @@ static bool
virtio_pci_ioeventfd_enabled(DeviceState *d)Quoted 17 lines
hw/virtio/virtio-pci.c +0
-2return (proxy->flags &VIRTIO_PCI_FLAG_USE_IOEVENTFD ) !=0 ; } -#define QEMU_VIRTIO_PCI_QUEUE_MEM_MULT 0x1000 - static inline int virtio_pci_queue_mem_mult(structVirtIOPCIProxy
*proxy) { return (proxy->flags & VIRTIO_PCI_FLAG_PAGE_PER_VQ) ?hw/virtio/virtio-pci.c +1
-1- QEMU_VIRTIO_PCI_QUEUE_MEM_MULT :4 ; + qemu_real_host_page_size() : 4; } static int virtio_pci_ioeventfd_assign(DeviceState *d,EventNotifier *notifier,
--
2.25.1