vhost: accept VIRTIO_F_ORDER_PLATFORM as a valid SVQ feature
PATCH 1/1 vhost: accept VIRTIO_F_ORDER_PLATFORM as a valid SVQ feature
VIRTIO_F_ORDER_PLATFORM indicates that memory accesses by the driver and the device are ordered in a way described by the platform. Since vDPA devices may be backed by a hardware devices, let's allow VIRTIO_F_ORDER_PLATFORM.
--- hw/virtio/vhost-shadow-virtqueue.c | 1 + 1 file changed, 1 insertion(+)
hw/virtio/vhost-shadow-virtqueue.c +1 -0
@@ -34,6 +34,7 @@ bool vhost_svq_valid_features(uint64_t features, Error **errp)switch (b) {case VIRTIO_F_ANY_LAYOUT :case VIRTIO_RING_F_EVENT_IDX : +case VIRTIO_F_ORDER_PLATFORM :continue ;case VIRTIO_F_ACCESS_PLATFORM :
Signature · 1 line
2.31.1
Quoted 16 lines · Eugenio Pérez
VIRTIO_F_ORDER_PLATFORMindicates that memory accesses by the driver and the device are ordered in a way described by the platform. Since vDPA devices may be backed by a hardware devices, let's allowVIRTIO_F_ORDER_PLATFORM.Signed-off-by Eugenio Pérez <[email protected]>--- hw/virtio/vhost-shadow-virtqueue.c | 1 + 1 file changed, 1 insertion(+)hw/virtio/vhost-shadow-virtqueue.c +0
-0
hw/virtio/vhost-shadow-virtqueue.c bool vhost_svq_valid_features(uint64_t features, Error **errp) · line 37
Quoted 4 lines
hw/virtio/vhost-shadow-virtqueue.c +1
-0@@ -34,6 +34,7 @@ bool vhost_svq_valid_features(uint64_t features, Error **errp)switch (b) {case VIRTIO_F_ANY_LAYOUT :case VIRTIO_RING_F_EVENT_IDX : +case VIRTIO_F_ORDER_PLATFORM :
Do we need to add this bit to vdpa_feature_bits[] as well?
Thanks
Quoted 6 lines
hw/virtio/vhost-shadow-virtqueue.c +0
-1continue ;case VIRTIO_F_ACCESS_PLATFORM : --2.31.1
Quoted 13 lines · Jason Wang
Quoted 11 lines · Eugenio Pérez
VIRTIO_F_ORDER_PLATFORMindicates that memory accesses by the driver and the device are ordered in a way described by the platform. Since vDPA devices may be backed by a hardware devices, let's allowVIRTIO_F_ORDER_PLATFORM.Signed-off-by Eugenio Pérez <[email protected]>--- hw/virtio/vhost-shadow-virtqueue.c | 1 + 1 file changed, 1 insertion(+)
Quoted 12 lines
hw/virtio/vhost-shadow-virtqueue.c bool vhost_svq_valid_features(uint64_t features, Error **errp) · line 37
Quoted 9 lines
hw/virtio/vhost-shadow-virtqueue.c +1
-0@@ -34,6 +34,7 @@ bool vhost_svq_valid_features(uint64_t features, Error **errp)switch (b) {case VIRTIO_F_ANY_LAYOUT :case VIRTIO_RING_F_EVENT_IDX : +case VIRTIO_F_ORDER_PLATFORM :Do we need to add this bit to vdpa_feature_bits[] as well?
If we want to pass it to the guest, yes we should. I'll send another patch for it.
But I think that should be done on top / in parallel actually.
Open question: Should all vdpa hardware devices offer it? Or this is only needed on specific archs?
Thanks!
Quoted 30 lines · Eugenio Perez Martin
Quoted 13 lines · Jason Wang
Quoted 11 lines · Eugenio Pérez
VIRTIO_F_ORDER_PLATFORMindicates that memory accesses by the driver and the device are ordered in a way described by the platform. Since vDPA devices may be backed by a hardware devices, let's allowVIRTIO_F_ORDER_PLATFORM.Signed-off-by Eugenio Pérez <[email protected]>--- hw/virtio/vhost-shadow-virtqueue.c | 1 + 1 file changed, 1 insertion(+)Quoted 12 lines
hw/virtio/vhost-shadow-virtqueue.c bool vhost_svq_valid_features(uint64_t features, Error **errp) · line 37
Quoted 9 lines
hw/virtio/vhost-shadow-virtqueue.c +1
-0@@ -34,6 +34,7 @@ bool vhost_svq_valid_features(uint64_t features, Error **errp)switch (b) {case VIRTIO_F_ANY_LAYOUT :case VIRTIO_RING_F_EVENT_IDX : +case VIRTIO_F_ORDER_PLATFORM :Do we need to add this bit to vdpa_feature_bits[] as well?
If we want to pass it to the guest, yes we should. I'll send another patch for it.
Quoted 6 lines
But I think that should be done on top / in parallel actually.
Open question: Should all vdpa hardware devices offer it? Or this is only needed on specific archs?
Thanks!
I don't get what this is doing at all frankly. vdpa has to
pass VIRTIO_F_ORDER_PLATFORM to guest at all times - unless
- it's a x86 host where it kind of works anyway
- it's vduse which frankly is so slow we can do VIRTIO_F_ORDER_PLATFORM anyway. In short VIRTIO_F_ORDER_PLATFORM has nothing to do with the device and everything with qemu itself.
Yea we can allow VIRTIO_F_ORDER_PLATFORM from kernel but given we never did at this point it will need a protocol feature bit. I don't think it's worth it ..
Signature · 1 line
MST
Quoted 37 lines · Michael S. Tsirkin
Quoted 35 lines · Eugenio Perez Martin
Quoted 13 lines · Jason Wang
Quoted 11 lines · Eugenio Pérez
VIRTIO_F_ORDER_PLATFORMindicates that memory accesses by the driver and the device are ordered in a way described by the platform. Since vDPA devices may be backed by a hardware devices, let's allowVIRTIO_F_ORDER_PLATFORM.Signed-off-by Eugenio Pérez <[email protected]>--- hw/virtio/vhost-shadow-virtqueue.c | 1 + 1 file changed, 1 insertion(+)Quoted 12 lines
hw/virtio/vhost-shadow-virtqueue.c bool vhost_svq_valid_features(uint64_t features, Error **errp) · line 37
Quoted 9 lines
hw/virtio/vhost-shadow-virtqueue.c +1
-0@@ -34,6 +34,7 @@ bool vhost_svq_valid_features(uint64_t features, Error **errp)switch (b) {case VIRTIO_F_ANY_LAYOUT :case VIRTIO_RING_F_EVENT_IDX : +case VIRTIO_F_ORDER_PLATFORM :Do we need to add this bit to vdpa_feature_bits[] as well?
If we want to pass it to the guest, yes we should. I'll send another patch for it.
But I think that should be done on top / in parallel actually.
Open question: Should all vdpa hardware devices offer it? Or this is only needed on specific archs?
Quoted 6 lines
Quoted 1 line
Thanks!
I don't get what this is doing at all frankly. vdpa has to
passVIRTIO_F_ORDER_PLATFORMto guest at all times - unless
- it's a x86 host where it kind of works anyway
- it's vduse which frankly is so slow we can doVIRTIO_F_ORDER_PLATFORManyway.
That was my understanding, adding vdpasim to the list of exceptions (please correct me if I'm wrong).
Quoted 3 lines
In short
VIRTIO_F_ORDER_PLATFORMhas nothing to do with the device and everything with qemu itself.
I have little experience outside of x86 so I may be wrong here. My understanding is that this feature allows the guest to optimize barriers around memory ops:
* If VIRTIO_F_ORDER_PLATFORM is not negotiated, the driver can use softer memory barriers that protects ordering between different processors.
* If VIRTIO_F_ORDER_PLATFORM is negotiated, stronger ordering is needed that also protects transport (PCI) accesses
This is backed up by comments in the standard:
This implies that the driver needs to use memory barriers suitable for devices described by the platform; e.g. for the PCI transport in the case of hardware PCI devices.
And in virtio drivers:
For virtio_pci on SMP, we don't need to order with respect to MMIO accesses through relaxed memory I/O windows, so virt_mb() et al are sufficient.
For using virtio to talk to real devices (eg. other heterogeneous CPUs) we do need real barriers.
So the sentence "VIRTIO_F_ORDER_PLATFORM has nothing to do with the device and everything with qemu itself." is actually the reverse, and has everything to do with devices?
Quoted 4 lines
Yea we can allow
VIRTIO_F_ORDER_PLATFORMfrom kernel but given we never did at this point it will need a protocol feature bit. I don't think it's worth it ..
With "from kernel" do you mean in vhost-kernel or in virtio ring driver? The virtio ring driver already supports them.
I'm ok with leaving this for the future but that means hw devices in non-x86 platforms may not work correctly, isn't it?
Thanks!
Quoted 73 lines · Eugenio Perez Martin
Quoted 37 lines · Michael S. Tsirkin
Quoted 35 lines · Eugenio Perez Martin
Quoted 13 lines · Jason Wang
Quoted 11 lines · Eugenio Pérez
VIRTIO_F_ORDER_PLATFORMindicates that memory accesses by the driver and the device are ordered in a way described by the platform. Since vDPA devices may be backed by a hardware devices, let's allowVIRTIO_F_ORDER_PLATFORM.Signed-off-by Eugenio Pérez <[email protected]>--- hw/virtio/vhost-shadow-virtqueue.c | 1 + 1 file changed, 1 insertion(+)Quoted 12 lines
hw/virtio/vhost-shadow-virtqueue.c bool vhost_svq_valid_features(uint64_t features, Error **errp) · line 37
Quoted 9 lines
hw/virtio/vhost-shadow-virtqueue.c +1
-0@@ -34,6 +34,7 @@ bool vhost_svq_valid_features(uint64_t features, Error **errp)switch (b) {case VIRTIO_F_ANY_LAYOUT :case VIRTIO_RING_F_EVENT_IDX : +case VIRTIO_F_ORDER_PLATFORM :Do we need to add this bit to vdpa_feature_bits[] as well?
If we want to pass it to the guest, yes we should. I'll send another patch for it.
But I think that should be done on top / in parallel actually.
Open question: Should all vdpa hardware devices offer it? Or this is only needed on specific archs?
Quoted 6 lines
Quoted 1 line
Thanks!
I don't get what this is doing at all frankly. vdpa has to
passVIRTIO_F_ORDER_PLATFORMto guest at all times - unless
- it's a x86 host where it kind of works anyway
- it's vduse which frankly is so slow we can doVIRTIO_F_ORDER_PLATFORManyway.That was my understanding, adding vdpasim to the list of exceptions (please correct me if I'm wrong).
Quoted 3 lines
In short
VIRTIO_F_ORDER_PLATFORMhas nothing to do with the device and everything with qemu itself.I have little experience outside of x86 so I may be wrong here. My understanding is that this feature allows the guest to optimize barriers around memory ops:
* IfVIRTIO_F_ORDER_PLATFORMis not negotiated, the driver can use softer memory barriers that protects ordering between different processors.
* IfVIRTIO_F_ORDER_PLATFORMis negotiated, stronger ordering is needed that also protects transport (PCI) accessesThis is backed up by comments in the standard:
This implies that the driver needs to use memory barriers suitable for devices described by the platform; e.g. for the PCI transport in the case of hardware PCI devices.And in virtio drivers:
Forvirtio_pcion SMP, we don't need to order with respect to MMIO accesses through relaxed memory I/O windows, sovirt_mb()et al are sufficient.
For using virtio to talk to real devices (eg. other heterogeneous CPUs) we do need real barriers.
Quoted 3 lines
So the sentence "
VIRTIO_F_ORDER_PLATFORMhas nothing to do with the device and everything with qemu itself." is actually the reverse, and has everything to do with devices?
Point is this is not device's decision.
Quoted 7 lines
Quoted 4 lines
Yea we can allow
VIRTIO_F_ORDER_PLATFORMfrom kernel but given we never did at this point it will need a protocol feature bit. I don't think it's worth it ..With "from kernel" do you mean in vhost-kernel or in virtio ring driver? The virtio ring driver already supports them.
vhost-kernel
Quoted 4 lines
I'm ok with leaving this for the future but that means hw devices in non-x86 platforms may not work correctly, isn't it?
Thanks!
You need to pass this to guest. My point is that there is no reason to get it from the kernel driver. QEMU can figure out whether the flag is needed itself.
Signature · 1 line
MST
Quoted 92 lines · Michael S. Tsirkin
Quoted 73 lines · Eugenio Perez Martin
Quoted 37 lines · Michael S. Tsirkin
Quoted 35 lines · Eugenio Perez Martin
Quoted 13 lines · Jason Wang
Quoted 11 lines · Eugenio Pérez
VIRTIO_F_ORDER_PLATFORMindicates that memory accesses by the driver and the device are ordered in a way described by the platform. Since vDPA devices may be backed by a hardware devices, let's allowVIRTIO_F_ORDER_PLATFORM.Signed-off-by Eugenio Pérez <[email protected]>--- hw/virtio/vhost-shadow-virtqueue.c | 1 + 1 file changed, 1 insertion(+)Quoted 12 lines
hw/virtio/vhost-shadow-virtqueue.c bool vhost_svq_valid_features(uint64_t features, Error **errp) · line 37
Quoted 9 lines
hw/virtio/vhost-shadow-virtqueue.c +1
-0@@ -34,6 +34,7 @@ bool vhost_svq_valid_features(uint64_t features, Error **errp)switch (b) {case VIRTIO_F_ANY_LAYOUT :case VIRTIO_RING_F_EVENT_IDX : +case VIRTIO_F_ORDER_PLATFORM :Do we need to add this bit to vdpa_feature_bits[] as well?
If we want to pass it to the guest, yes we should. I'll send another patch for it.
But I think that should be done on top / in parallel actually.
Open question: Should all vdpa hardware devices offer it? Or this is only needed on specific archs?
Quoted 6 lines
Quoted 1 line
Thanks!
I don't get what this is doing at all frankly. vdpa has to
passVIRTIO_F_ORDER_PLATFORMto guest at all times - unless
- it's a x86 host where it kind of works anyway
- it's vduse which frankly is so slow we can doVIRTIO_F_ORDER_PLATFORManyway.That was my understanding, adding vdpasim to the list of exceptions (please correct me if I'm wrong).
Quoted 3 lines
In short
VIRTIO_F_ORDER_PLATFORMhas nothing to do with the device and everything with qemu itself.I have little experience outside of x86 so I may be wrong here. My understanding is that this feature allows the guest to optimize barriers around memory ops:
* IfVIRTIO_F_ORDER_PLATFORMis not negotiated, the driver can use softer memory barriers that protects ordering between different processors.
* IfVIRTIO_F_ORDER_PLATFORMis negotiated, stronger ordering is needed that also protects transport (PCI) accessesThis is backed up by comments in the standard:
This implies that the driver needs to use memory barriers suitable for devices described by the platform; e.g. for the PCI transport in the case of hardware PCI devices.And in virtio drivers:
Forvirtio_pcion SMP, we don't need to order with respect to MMIO accesses through relaxed memory I/O windows, sovirt_mb()et al are sufficient.
For using virtio to talk to real devices (eg. other heterogeneous CPUs) we do need real barriers.Quoted 3 lines
So the sentence "
VIRTIO_F_ORDER_PLATFORMhas nothing to do with the device and everything with qemu itself." is actually the reverse, and has everything to do with devices?Point is this is not device's decision.
Quoted 7 lines
Quoted 4 lines
Yea we can allow
VIRTIO_F_ORDER_PLATFORMfrom kernel but given we never did at this point it will need a protocol feature bit. I don't think it's worth it ..With "from kernel" do you mean in vhost-kernel or in virtio ring driver? The virtio ring driver already supports them.
vhost-kernel
Quoted 9 lines
Quoted 4 lines
I'm ok with leaving this for the future but that means hw devices in non-x86 platforms may not work correctly, isn't it?
Thanks!
You need to pass this to guest. My point is that there is no reason to get it from the kernel driver. QEMU can figure out whether the flag is needed itself.
Ok, I can see now how the HW device does not have all the knowledge to offer this flag or not. But I'm not sure how qemu can know either.
If qemu opens /dev/vhost-vdpa-N, how can it know it? It has no way to tell if the device is sw or hw as far as I know. Am I missing something?
Thanks!
Quoted 5 lines · Eugenio Perez Martin
Quoted 4 lines
You need to pass this to guest. My point is that there is no reason to get it from the kernel driver. QEMU can figure out whether the flag is needed itself.
Quoted 8 lines
Ok, I can see now how the HW device does not have all the knowledge to offer this flag or not. But I'm not sure how qemu can know either.
If qemu opens
/dev/vhost-vdpa-N, how can it know it? It has no way to tell if the device is sw or hw as far as I know. Am I missing something?Thanks!
This is what I said earlier. You can safely assume vdpa needs this flag. Only exception is vduse and we don't care about performance there.
Signature · 1 line
MST
Quoted 10 lines · Michael S. Tsirkin
Quoted 8 lines · Eugenio Perez Martin
Quoted 4 lines
You need to pass this to guest. My point is that there is no reason to get it from the kernel driver. QEMU can figure out whether the flag is needed itself.
Ok, I can see now how the HW device does not have all the knowledge to offer this flag or not. But I'm not sure how qemu can know either.
Quoted 9 lines
Quoted 5 lines
If qemu opens
/dev/vhost-vdpa-N, how can it know it? It has no way to tell if the device is sw or hw as far as I know. Am I missing something?Thanks!
This is what I said earlier. You can safely assume vdpa needs this flag. Only exception is vduse and we don't care about performance there.
Ok now I get your point, thanks for explaining.
But I'm missing why it is wrong to start using it properly from the kernel. I didn't test vDPA in non x86 / PCI, but if it does not work because of the lack of this feature flag the right fix would be to offer it, not to start assuming it in qemu, isn't it?
I can see how "assume VIRTIO_F_ORDER_PLATFORM from qemu" may need code comments and extra explanations, but to start offering it properly from the device is expected somehow.
Thanks!
Quoted 30 lines · Eugenio Perez Martin
Quoted 10 lines · Michael S. Tsirkin
Quoted 8 lines · Eugenio Perez Martin
Quoted 4 lines
You need to pass this to guest. My point is that there is no reason to get it from the kernel driver. QEMU can figure out whether the flag is needed itself.
Ok, I can see now how the HW device does not have all the knowledge to offer this flag or not. But I'm not sure how qemu can know either.
Quoted 9 lines
Quoted 5 lines
If qemu opens
/dev/vhost-vdpa-N, how can it know it? It has no way to tell if the device is sw or hw as far as I know. Am I missing something?Thanks!
This is what I said earlier. You can safely assume vdpa needs this flag. Only exception is vduse and we don't care about performance there.
Ok now I get your point, thanks for explaining.
But I'm missing why it is wrong to start using it properly from the kernel.
I didn't test vDPA in non x86 / PCI, but if it does not work because of the lack of this feature flag the right fix would be to offer it, not to start assuming it in qemu, isn't it?
Quoted 5 lines
I can see how "assume
VIRTIO_F_ORDER_PLATFORMfrom qemu" may need code comments and extra explanations, but to start offering it properly from the device is expected somehow.Thanks!
Does kernel always expose it?
Signature · 1 line
MST
Quoted 32 lines · Michael S. Tsirkin
Quoted 30 lines · Eugenio Perez Martin
Quoted 10 lines · Michael S. Tsirkin
Quoted 8 lines · Eugenio Perez Martin
Quoted 4 lines
You need to pass this to guest. My point is that there is no reason to get it from the kernel driver. QEMU can figure out whether the flag is needed itself.
Ok, I can see now how the HW device does not have all the knowledge to offer this flag or not. But I'm not sure how qemu can know either.
Quoted 9 lines
Quoted 5 lines
If qemu opens
/dev/vhost-vdpa-N, how can it know it? It has no way to tell if the device is sw or hw as far as I know. Am I missing something?Thanks!
This is what I said earlier. You can safely assume vdpa needs this flag. Only exception is vduse and we don't care about performance there.
Ok now I get your point, thanks for explaining.
But I'm missing why it is wrong to start using it properly from the kernel.
I didn't test vDPA in non x86 / PCI, but if it does not work because of the lack of this feature flag the right fix would be to offer it, not to start assuming it in qemu, isn't it?
Quoted 8 lines
Quoted 5 lines
I can see how "assume
VIRTIO_F_ORDER_PLATFORMfrom qemu" may need code comments and extra explanations, but to start offering it properly from the device is expected somehow.Thanks!
Does kernel always expose it?
As far as I know the only vdpa device exposing it is alibaba/eni_vdpa
Quoted 37 lines · Eugenio Perez Martin
Quoted 36 lines · Michael S. Tsirkin
Quoted 34 lines · Eugenio Perez Martin
Quoted 10 lines · Michael S. Tsirkin
Quoted 8 lines · Eugenio Perez Martin
Quoted 4 lines
You need to pass this to guest. My point is that there is no reason to get it from the kernel driver. QEMU can figure out whether the flag is needed itself.
Ok, I can see now how the HW device does not have all the knowledge to offer this flag or not. But I'm not sure how qemu can know either.
Quoted 9 lines
Quoted 5 lines
If qemu opens
/dev/vhost-vdpa-N, how can it know it? It has no way to tell if the device is sw or hw as far as I know. Am I missing something?Thanks!
This is what I said earlier. You can safely assume vdpa needs this flag. Only exception is vduse and we don't care about performance there.
Ok now I get your point, thanks for explaining.
But I'm missing why it is wrong to start using it properly from the kernel.
I didn't test vDPA in non x86 / PCI, but if it does not work because of the lack of this feature flag the right fix would be to offer it, not to start assuming it in qemu, isn't it?
I can see how "assume
VIRTIO_F_ORDER_PLATFORMfrom qemu" may need code comments and extra explanations, but to start offering it properly from the device is expected somehow.
Quoted 6 lines
Quoted 4 lines
Quoted 1 line
Thanks!
Does kernel always expose it?
As far as I know the only vdpa device exposing it is alibaba/eni_vdpa
That is my point then. qemu should set it and ignore what kernel says.
Signature · 1 line
MST