Skip to contentSkip to conversation

vhost: fix performance on LE hosts

PATCH Applied Michael S. Tsirkin 3 participants 6 messages Oct 27, 2015 – Oct 28, 2015

Subsystems (5)
lore
Share & tools
lore

Michael S. Tsirkin

author maintainer
#0 lore raw

PATCH 1/1 vhost: fix performance on LE hosts

commit 2751c9882b947292fcfb084c4f604e01724af804 ("vhost: cross-endian support for legacy devices") introduced a minor regression: even with cross-endian disabled, and even on LE host, vhost_is_little_endian is checking is_le flag so there's always a branch.

To fix, simply check virtio_legacy_is_little_endian first.

---
 drivers/vhost/vhost.h | 7 +++++++
 1 file changed, 7 insertions(+)
drivers/vhost/vhost.h +7 -0
index 4772862..d3f7674 100644
@@ -183,10 +183,17 @@ static inline bool vhost_has_feature(struct vhost_virtqueue *vq, int bit)
 	return vq->acked_features & (1ULL << bit);
 }
 
+#ifdef CONFIG_VHOST_CROSS_ENDIAN_LEGACY
 static inline bool vhost_is_little_endian(struct vhost_virtqueue *vq)
 {
 	return vq->is_le;
 }
+#else
+static inline bool vhost_is_little_endian(struct vhost_virtqueue *vq)
+{
+	return virtio_legacy_is_little_endian() || vq->is_le;
+}
+#endif
 
 /* Memory accessors */
 static inline u16 vhost16_to_cpu(struct vhost_virtqueue *vq, __virtio16 val)
Signature · 1 line
MST
Reviewed-by on v1 1/1
#1 lore raw
Quoted 9 lines · On Tue, 27 Oct 2015 11:37:39 +0200 "Michael S. Tsirkin" <[email protected]> wrote:

commit 2751c9882b947292fcfb084c4f604e01724af804 ("vhost: cross-endian support for legacy devices") introduced a minor regression: even with cross-endian disabled, and even on LE host, vhost_is_little_endian is checking is_le flag so there's always a branch.

To fix, simply check virtio_legacy_is_little_endian first.

Oops my bad for this oversight...

Quoted 26 lines
---
 drivers/vhost/vhost.h | 7 +++++++
 1 file changed, 7 insertions(+)
drivers/vhost/vhost.h +7 -0
index 4772862..d3f7674 100644
@@ -183,10 +183,17 @@ static inline bool vhost_has_feature(struct vhost_virtqueue *vq, int bit)
 	return vq->acked_features & (1ULL << bit);
 }
 
+#ifdef CONFIG_VHOST_CROSS_ENDIAN_LEGACY
 static inline bool vhost_is_little_endian(struct vhost_virtqueue *vq)
 {
 	return vq->is_le;
 }
+#else
+static inline bool vhost_is_little_endian(struct vhost_virtqueue *vq)
+{
+	return virtio_legacy_is_little_endian() || vq->is_le;
+}
+#endif
 
 /* Memory accessors */
 static inline u16 vhost16_to_cpu(struct vhost_virtqueue *vq, __virtio16 val)
maintainer
#2 lore raw
In reply to Michael S. Tsirkin

From: "Michael S. Tsirkin" <[email protected]>
Date: Tue, 27 Oct 2015 11:37:39 +0200

Quoted 9 lines

commit 2751c9882b947292fcfb084c4f604e01724af804 ("vhost: cross-endian support for legacy devices") introduced a minor regression: even with cross-endian disabled, and even on LE host, vhost_is_little_endian is checking is_le flag so there's always a branch.

To fix, simply check virtio_legacy_is_little_endian first.

Michael, do you want me to take this via the 'net' tree?

author maintainer
#3 lore raw
Quoted 8 lines · David Miller

From: "Michael S. Tsirkin" <[email protected]>
Date: Tue, 27 Oct 2015 11:37:39 +0200

Quoted 5 lines

commit 2751c9882b947292fcfb084c4f604e01724af804 ("vhost: cross-endian support for legacy devices") introduced a minor regression: even with cross-endian disabled, and even on LE host, vhost_is_little_endian is checking is_le flag so there's always a branch.

Quoted 6 lines
Quoted 4 lines

To fix, simply check virtio_legacy_is_little_endian first.

Michael, do you want me to take this via the 'net' tree?

Sure - especially since it looks like I have nothing else for this merge window (working on fixing shutdown races, but it's slow going). Thanks a lot!

Signature · 1 line
MST
maintainer
#4 lore raw
In reply to Michael S. Tsirkin

From: "Michael S. Tsirkin" <[email protected]>
Date: Tue, 27 Oct 2015 11:37:39 +0200

Quoted 9 lines

commit 2751c9882b947292fcfb084c4f604e01724af804 ("vhost: cross-endian support for legacy devices") introduced a minor regression: even with cross-endian disabled, and even on LE host, vhost_is_little_endian is checking is_le flag so there's always a branch.

To fix, simply check virtio_legacy_is_little_endian first.

Michael, do you want me to take this via the 'net' tree?

maintainer Applied
#5 lore raw
In reply to Michael S. Tsirkin

From: "Michael S. Tsirkin" <[email protected]>
Date: Tue, 27 Oct 2015 11:37:39 +0200

Quoted 9 lines

commit 2751c9882b947292fcfb084c4f604e01724af804 ("vhost: cross-endian support for legacy devices") introduced a minor regression: even with cross-endian disabled, and even on LE host, vhost_is_little_endian is checking is_le flag so there's always a branch.

To fix, simply check virtio_legacy_is_little_endian first.

Applied.