Skip to contentSkip to conversation

qemu-traditional/xendisk: set maximum number of grants to be used

PATCH In review Jan Beulich 2 participants 2 messages Jun 25, 2012 – Jun 29, 2012

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 qemu-traditional/xendisk: set maximum number of grants to be used

Legacy (non-pvops) gntdev drivers may require this to be done when the number of grants intended to be used simultaneously exceeds a certain driver specific default limit.

Change in v2: Double the number requested, as we need to account for the allocations needing to happen in contiguous chunks. The worst case number would be max_req * max_seg + (max_req - 1) * (max_seg - 1) + 1, but in order to keep things simple just use 2 * max_req * max_seg.

upstream-commit: 64c27e5b1fdb6d94bdc0bda3b1869d7383a35c65

hw/xen_disk.c +14 -0
@@ -570,6 +570,15 @@ static void blk_bh(void *opaque)
     blk_handle_requests(blkdev);
 }
 
+/*
+ * We need to account for the grant allocations requiring contiguous
+ * chunks; the worst case number would be
+ *     max_req * max_seg + (max_req - 1) * (max_seg - 1) + 1,
+ * but in order to keep things simple just use
+ *     2 * max_req * max_seg.
+ */
+#define MAX_GRANTS(max_req, max_seg) (2 * (max_req) * (max_seg))
+
 static void blk_alloc(struct XenDevice *xendev)
 {
     struct XenBlkDev *blkdev = container_of(xendev, struct XenBlkDev, xendev);
@@ -580,6 +589,11 @@ static void blk_alloc(struct XenDevice *
     blkdev->bh = qemu_bh_new(blk_bh, blkdev);
     if (xen_mode != XEN_EMULATE)
         batch_maps = 1;
+    if (xc_gnttab_set_max_grants(xendev->gnttabdev,
+            MAX_GRANTS(max_requests, BLKIF_MAX_SEGMENTS_PER_REQUEST)) < 0) {
+        xen_be_printf(xendev, 0, "xc_gnttab_set_max_grants failed: %s\n",
+                      strerror(errno));
+    }
 }
 
 static int blk_init(struct XenDevice *xendev)

qemu-traditional/xendisk: set maximum number of grants to be used

Legacy (non-pvops) gntdev drivers may require this to be done when the number of grants intended to be used simultaneously exceeds a certain driver specific default limit.

Change in v2: Double the number requested, as we need to account for the allocations needing to happen in contiguous chunks. The worst case number would be max_req * max_seg + (max_req - 1) * (max_seg - 1) + 1, but in order to keep things simple just use 2 * max_req * max_seg.

upstream-commit: 64c27e5b1fdb6d94bdc0bda3b1869d7383a35c65

hw/xen_disk.c +14 -0
@@ -570,6 +570,15 @@ static void blk_bh(void *opaque)
     blk_handle_requests(blkdev);
 }
 
+/*
+ * We need to account for the grant allocations requiring contiguous
+ * chunks; the worst case number would be
+ *     max_req * max_seg + (max_req - 1) * (max_seg - 1) + 1,
+ * but in order to keep things simple just use
+ *     2 * max_req * max_seg.
+ */
+#define MAX_GRANTS(max_req, max_seg) (2 * (max_req) * (max_seg))
+
 static void blk_alloc(struct XenDevice *xendev)
 {
     struct XenBlkDev *blkdev = container_of(xendev, struct XenBlkDev, xendev);
@@ -580,6 +589,11 @@ static void blk_alloc(struct XenDevice *
     blkdev->bh = qemu_bh_new(blk_bh, blkdev);
     if (xen_mode != XEN_EMULATE)
         batch_maps = 1;
+    if (xc_gnttab_set_max_grants(xendev->gnttabdev,
+            MAX_GRANTS(max_requests, BLKIF_MAX_SEGMENTS_PER_REQUEST)) < 0) {
+        xen_be_printf(xendev, 0, "xc_gnttab_set_max_grants failed: %s\n",
+                      strerror(errno));
+    }
 }
 
 static int blk_init(struct XenDevice *xendev)

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

#1 lore raw

Jan Beulich writes ("[Xen-devel] [PATCH] qemu-traditional/xendisk: set maximum number of grants to be used"):

Quoted 3 lines

Legacy (non-pvops) gntdev drivers may require this to be done when the number of grants intended to be used simultaneously exceeds a certain driver specific default limit.

Committed to qemu-xen-traditional, thanks.

Ian.