From patchwork Thu May 31 11:23:46 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Beulich X-Patchwork-Id: 162140 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 3EC4FB7005 for ; Thu, 31 May 2012 21:24:08 +1000 (EST) Received: from localhost ([::1]:57886 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Sa3U5-0000h7-Iq for incoming@patchwork.ozlabs.org; Thu, 31 May 2012 07:24:05 -0400 Received: from eggs.gnu.org ([208.118.235.92]:58176) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Sa3Ty-0000gu-5J for qemu-devel@nongnu.org; Thu, 31 May 2012 07:23:59 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Sa3Tr-0000En-1b for qemu-devel@nongnu.org; Thu, 31 May 2012 07:23:57 -0400 Received: from nat28.tlf.novell.com ([130.57.49.28]:44727) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Sa3Tq-0000EP-NN for qemu-devel@nongnu.org; Thu, 31 May 2012 07:23:50 -0400 Received: from EMEA1-MTA by nat28.tlf.novell.com with Novell_GroupWise; Thu, 31 May 2012 12:23:47 +0100 Message-Id: <4FC770E20200007800087298@nat28.tlf.novell.com> X-Mailer: Novell GroupWise Internet Agent 12.0.0 Date: Thu, 31 May 2012 12:23:46 +0100 From: "Jan Beulich" To: "xen-devel" , Mime-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6, seldom 2.4 (older, 4) X-Received-From: 130.57.49.28 Cc: Olaf Hering , Stefano Stabellini Subject: [Qemu-devel] [PATCH, v3] qemu/xendisk: set maximum number of grants to be used X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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. Change in v3: introduce MAX_GRANTS(), and add a comment explaining its definition. Signed-off-by: Jan Beulich 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. Change in v3: introduce MAX_GRANTS(), and add a comment explaining its definition. Signed-off-by: Jan Beulich --- a/hw/xen_disk.c +++ b/hw/xen_disk.c @@ -537,6 +537,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); @@ -548,6 +557,11 @@ static void blk_alloc(struct XenDevice * 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) --- a/hw/xen_disk.c +++ b/hw/xen_disk.c @@ -537,6 +537,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); @@ -548,6 +557,11 @@ static void blk_alloc(struct XenDevice * 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)