Patchwork [v2] qemu/xendisk: set maximum number of grants to be used

login
register
mail settings
Submitter Jan Beulich
Date May 31, 2012, 9:58 a.m.
Message ID <4FC75CD902000078000871F6@nat28.tlf.novell.com>
Download mbox | patch
Permalink /patch/162130/
State New
Headers show

Comments

Jan Beulich - May 31, 2012, 9:58 a.m.
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.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
qemu/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.

Signed-off-by: Jan Beulich <jbeulich@suse.com>

--- a/hw/xen_disk.c
+++ b/hw/xen_disk.c
@@ -548,6 +548,11 @@ static void blk_alloc(struct XenDevice *
     if (xen_mode != XEN_EMULATE) {
         batch_maps = 1;
     }
+    if (xc_gnttab_set_max_grants(xendev->gnttabdev,
+            2 * 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)
Stefano Stabellini - May 31, 2012, 10:22 a.m.
On Thu, 31 May 2012, Jan Beulich wrote:
> 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.

Could you please add a brief explanation like this one as a comment in
the code below?


> Signed-off-by: Jan Beulich <jbeulich@suse.com>
> 
> --- a/hw/xen_disk.c
> +++ b/hw/xen_disk.c
> @@ -548,6 +548,11 @@ static void blk_alloc(struct XenDevice *
>      if (xen_mode != XEN_EMULATE) {
>          batch_maps = 1;
>      }
> +    if (xc_gnttab_set_max_grants(xendev->gnttabdev,
> +            2 * 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)

Patch

--- a/hw/xen_disk.c
+++ b/hw/xen_disk.c
@@ -548,6 +548,11 @@  static void blk_alloc(struct XenDevice *
     if (xen_mode != XEN_EMULATE) {
         batch_maps = 1;
     }
+    if (xc_gnttab_set_max_grants(xendev->gnttabdev,
+            2 * 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)