From: "Jan Beulich" Subject: [PATCH] qemu-traditional/xendisk: set maximum number of grants to be used Date: Mon, 25 Jun 2012 11:44:18 +0100 Message-ID: <4FE85D22020000780008BA8F@nat28.tlf.novell.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=__Part9CB23612.1__=" Return-path: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Ian Jackson Cc: xen-devel , Stefano Stabellini List-Id: xen-devel@lists.xenproject.org This is a MIME message. If you are reading this text, you may want to consider changing to a mail reader or gateway that understands how to properly handle MIME multipart messages. --=__Part9CB23612.1__= Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Content-Disposition: inline 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 Signed-off-by: Jan Beulich Signed-off-by: Stefano Stabellini --- a/hw/xen_disk.c +++ b/hw/xen_disk.c @@ -570,6 +570,15 @@ static void blk_bh(void *opaque) blk_handle_requests(blkdev); } =20 +/* + * 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 =3D container_of(xendev, struct XenBlkDev, = xendev); @@ -580,6 +589,11 @@ static void blk_alloc(struct XenDevice * blkdev->bh =3D qemu_bh_new(blk_bh, blkdev); if (xen_mode !=3D XEN_EMULATE) batch_maps =3D 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)); + } } =20 static int blk_init(struct XenDevice *xendev) --=__Part9CB23612.1__= Content-Type: text/plain; name="qemu-xendisk-set-max-grants.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="qemu-xendisk-set-max-grants.patch" qemu-traditional/xendisk: set maximum number of grants to be used=0A=0ALega= cy (non-pvops) gntdev drivers may require this to be done when the=0Anumber= of grants intended to be used simultaneously exceeds a certain=0Adriver = specific default limit.=0A=0AChange in v2: Double the number requested, as = we need to account for=0Athe allocations needing to happen in contiguous = chunks. The worst case=0Anumber would be max_req * max_seg + (max_req - 1) = * (max_seg - 1) + 1,=0Abut in order to keep things simple just use 2 * = max_req * max_seg.=0A=0Aupstream-commit: 64c27e5b1fdb6d94bdc0bda3b1869d7383= a35c65=0A=0ASigned-off-by: Jan Beulich =0ASigned-off-by:= Stefano Stabellini =0A=0A--- a/hw/xen_di= sk.c=0A+++ b/hw/xen_disk.c=0A@@ -570,6 +570,15 @@ static void blk_bh(void = *opaque)=0A blk_handle_requests(blkdev);=0A }=0A =0A+/*=0A+ * We need = to account for the grant allocations requiring contiguous=0A+ * chunks; = the worst case number would be=0A+ * max_req * max_seg + (max_req - 1) = * (max_seg - 1) + 1,=0A+ * but in order to keep things simple just use=0A+ = * 2 * max_req * max_seg.=0A+ */=0A+#define MAX_GRANTS(max_req, = max_seg) (2 * (max_req) * (max_seg))=0A+=0A static void blk_alloc(struct = XenDevice *xendev)=0A {=0A struct XenBlkDev *blkdev =3D container_of(xe= ndev, struct XenBlkDev, xendev);=0A@@ -580,6 +589,11 @@ static void = blk_alloc(struct XenDevice *=0A blkdev->bh =3D qemu_bh_new(blk_bh, = blkdev);=0A if (xen_mode !=3D XEN_EMULATE)=0A batch_maps =3D = 1;=0A+ if (xc_gnttab_set_max_grants(xendev->gnttabdev,=0A+ = MAX_GRANTS(max_requests, BLKIF_MAX_SEGMENTS_PER_REQUEST)) < 0) {=0A+ = xen_be_printf(xendev, 0, "xc_gnttab_set_max_grants failed: %s\n",=0A+ = strerror(errno));=0A+ }=0A }=0A =0A static int = blk_init(struct XenDevice *xendev)=0A --=__Part9CB23612.1__= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xen.org http://lists.xen.org/xen-devel --=__Part9CB23612.1__=--