Skip to contentSkip to conversation

xen: use native disk xenbus protocol if possible

PATCH Superseded Juergen Gross 2 participants 4 messages Jun 17, 2016 – Jun 29, 2016

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 xen: use native disk xenbus protocol if possible

The qdisk implementation is using the native xenbus protocol only in case of no protocol specified at all. As using the explicit 32- or 64-bit protocol is slower than the native one due to copying requests not by memcpy but element for element, this is not optimal.

Correct this by using the native protocol in case word sizes of frontend and backend match.

---
 hw/block/xen_disk.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)
hw/block/xen_disk.c +8 -8
index 2862b59..0961fcb 100644
@@ -976,14 +976,14 @@ static int blk_connect(struct XenDevice *xendev)
         blkdev->feature_persistent = !!pers;
     }
 
-    blkdev->protocol = BLKIF_PROTOCOL_NATIVE;
-    if (blkdev->xendev.protocol) {
-        if (strcmp(blkdev->xendev.protocol, XEN_IO_PROTO_ABI_X86_32) == 0) {
-            blkdev->protocol = BLKIF_PROTOCOL_X86_32;
-        }
-        if (strcmp(blkdev->xendev.protocol, XEN_IO_PROTO_ABI_X86_64) == 0) {
-            blkdev->protocol = BLKIF_PROTOCOL_X86_64;
-        }
+    if (!blkdev->xendev.protocol) {
+        blkdev->protocol = BLKIF_PROTOCOL_NATIVE;
+    } else if (strcmp(blkdev->xendev.protocol, XEN_IO_PROTO_ABI_NATIVE) == 0) {
+        blkdev->protocol = BLKIF_PROTOCOL_NATIVE;
+    } else if (strcmp(blkdev->xendev.protocol, XEN_IO_PROTO_ABI_X86_32) == 0) {
+        blkdev->protocol = BLKIF_PROTOCOL_X86_32;
+    } else if (strcmp(blkdev->xendev.protocol, XEN_IO_PROTO_ABI_X86_64) == 0) {
+        blkdev->protocol = BLKIF_PROTOCOL_X86_64;
     }
 
     blkdev->sring = xengnttab_map_grant_ref(blkdev->xendev.gnttabdev,
Signature · 1 line
2.6.6
#1 lore raw
Quoted 7 lines · Juergen Gross

The qdisk implementation is using the native xenbus protocol only in case of no protocol specified at all. As using the explicit 32- or 64-bit protocol is slower than the native one due to copying requests not by memcpy but element for element, this is not optimal.

Correct this by using the native protocol in case word sizes of frontend and backend match.

Ping?

Quoted 34 lines
---
 hw/block/xen_disk.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)
hw/block/xen_disk.c +8 -8
index 2862b59..0961fcb 100644
@@ -976,14 +976,14 @@ static int blk_connect(struct XenDevice *xendev)
         blkdev->feature_persistent = !!pers;
     }
 
-    blkdev->protocol = BLKIF_PROTOCOL_NATIVE;
-    if (blkdev->xendev.protocol) {
-        if (strcmp(blkdev->xendev.protocol, XEN_IO_PROTO_ABI_X86_32) == 0) {
-            blkdev->protocol = BLKIF_PROTOCOL_X86_32;
-        }
-        if (strcmp(blkdev->xendev.protocol, XEN_IO_PROTO_ABI_X86_64) == 0) {
-            blkdev->protocol = BLKIF_PROTOCOL_X86_64;
-        }
+    if (!blkdev->xendev.protocol) {
+        blkdev->protocol = BLKIF_PROTOCOL_NATIVE;
+    } else if (strcmp(blkdev->xendev.protocol, XEN_IO_PROTO_ABI_NATIVE) == 0) {
+        blkdev->protocol = BLKIF_PROTOCOL_NATIVE;
+    } else if (strcmp(blkdev->xendev.protocol, XEN_IO_PROTO_ABI_X86_32) == 0) {
+        blkdev->protocol = BLKIF_PROTOCOL_X86_32;
+    } else if (strcmp(blkdev->xendev.protocol, XEN_IO_PROTO_ABI_X86_64) == 0) {
+        blkdev->protocol = BLKIF_PROTOCOL_X86_64;
     }
 
     blkdev->sring = xengnttab_map_grant_ref(blkdev->xendev.gnttabdev,
#2 lore raw
In reply to Juergen Gross
Quoted 27 lines · Juergen Gross

The qdisk implementation is using the native xenbus protocol only in case of no protocol specified at all. As using the explicit 32- or 64-bit protocol is slower than the native one due to copying requests not by memcpy but element for element, this is not optimal.

Correct this by using the native protocol in case word sizes of frontend and backend match.

---
 hw/block/xen_disk.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)
hw/block/xen_disk.c +0 -6
index 2862b59..0961fcb 100644
@@ -976,14 +976,14 @@ static int blk_connect(struct XenDevice *xendev)
         blkdev->feature_persistent = !!pers;
     }
 
-    blkdev->protocol = BLKIF_PROTOCOL_NATIVE;
-    if (blkdev->xendev.protocol) {
-        if (strcmp(blkdev->xendev.protocol, XEN_IO_PROTO_ABI_X86_32) == 0) {
-            blkdev->protocol = BLKIF_PROTOCOL_X86_32;
-        }
-        if (strcmp(blkdev->xendev.protocol, XEN_IO_PROTO_ABI_X86_64) == 0) {

hw/block/xen_disk.c static int blk_connect(struct XenDevice *xendev) · line 986

Quoted 10 lines
hw/block/xen_disk.c +8 -2
-            blkdev->protocol = BLKIF_PROTOCOL_X86_64;
-        }
+    if (!blkdev->xendev.protocol) {
+        blkdev->protocol = BLKIF_PROTOCOL_NATIVE;
+    } else if (strcmp(blkdev->xendev.protocol, XEN_IO_PROTO_ABI_NATIVE) == 0) {
+        blkdev->protocol = BLKIF_PROTOCOL_NATIVE;
+    } else if (strcmp(blkdev->xendev.protocol, XEN_IO_PROTO_ABI_X86_32) == 0) {
+        blkdev->protocol = BLKIF_PROTOCOL_X86_32;
+    } else if (strcmp(blkdev->xendev.protocol, XEN_IO_PROTO_ABI_X86_64) == 0) {
+        blkdev->protocol = BLKIF_PROTOCOL_X86_64;

There is one difference with the previous code, in case the protocol is specified, but it not x86_32 or x86_64, then no blkdev->protocol is selected (then no ring is initialized). Could you re-add this case?

Signature · 1 line
Anthony PERARD
#3 lore raw
Quoted 34 lines · Anthony PERARD
Quoted 33 lines · Juergen Gross

The qdisk implementation is using the native xenbus protocol only in case of no protocol specified at all. As using the explicit 32- or 64-bit protocol is slower than the native one due to copying requests not by memcpy but element for element, this is not optimal.

Correct this by using the native protocol in case word sizes of frontend and backend match.

---
 hw/block/xen_disk.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)
hw/block/xen_disk.c +4 -8
index 2862b59..0961fcb 100644
@@ -976,14 +976,14 @@ static int blk_connect(struct XenDevice *xendev)
         blkdev->feature_persistent = !!pers;
     }
 
-    blkdev->protocol = BLKIF_PROTOCOL_NATIVE;
-    if (blkdev->xendev.protocol) {
-        if (strcmp(blkdev->xendev.protocol, XEN_IO_PROTO_ABI_X86_32) == 0) {
-            blkdev->protocol = BLKIF_PROTOCOL_X86_32;
-        }
-        if (strcmp(blkdev->xendev.protocol, XEN_IO_PROTO_ABI_X86_64) == 0) {
-            blkdev->protocol = BLKIF_PROTOCOL_X86_64;
-        }
+    if (!blkdev->xendev.protocol) {
+        blkdev->protocol = BLKIF_PROTOCOL_NATIVE;
+    } else if (strcmp(blkdev->xendev.protocol, XEN_IO_PROTO_ABI_NATIVE) == 0) {
+        blkdev->protocol = BLKIF_PROTOCOL_NATIVE;
Quoted 8 lines

hw/block/xen_disk.c static int blk_connect(struct XenDevice *xendev) · line 986

Quoted 4 lines
hw/block/xen_disk.c +4 -0
+    } else if (strcmp(blkdev->xendev.protocol, XEN_IO_PROTO_ABI_X86_32) == 0) {
+        blkdev->protocol = BLKIF_PROTOCOL_X86_32;
+    } else if (strcmp(blkdev->xendev.protocol, XEN_IO_PROTO_ABI_X86_64) == 0) {
+        blkdev->protocol = BLKIF_PROTOCOL_X86_64;

There is one difference with the previous code, in case the protocol is specified, but it not x86_32 or x86_64, then no blkdev->protocol is selected (then no ring is initialized). Could you re-add this case?

Aah, of course!

Thanks,

Juergen

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel