Received: from eggs.gnu.org ([208.118.235.92]:32911) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SeL5M-0007sM-PA for qemu-devel@nongnu.org; Tue, 12 Jun 2012 03:00:18 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SeL5K-00059k-OR for qemu-devel@nongnu.org; Tue, 12 Jun 2012 03:00:16 -0400 Received: from nat28.tlf.novell.com ([130.57.49.28]:43504) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SeL5K-0004sn-FJ for qemu-devel@nongnu.org; Tue, 12 Jun 2012 03:00:14 -0400 Message-Id: <4FD70533020000780008952E@nat28.tlf.novell.com> Date: Tue, 12 Jun 2012 08:00:35 +0100 From: "Jan Beulich" References: <4FC770E20200007800087298@nat28.tlf.novell.com> In-Reply-To: Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Subject: Re: [Qemu-devel] [PATCH, v3] qemu/xendisk: set maximum number of grants to be used List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Ian Jackson Cc: Olaf Hering , xen-devel , "qemu-devel@nongnu.org" , Stefano Stabellini >>> On 31.05.12 at 13:27, Stefano Stabellini wrote: > 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. >>=20 >> 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. >>=20 >> Change in v3: introduce MAX_GRANTS(), and add a comment explaining its >> definition. >>=20 >> Signed-off-by: Jan Beulich >=20 > I think it is OK, I'll submit it as a bug fix for QEMU 1.1. >=20 > It should be applied to qemu-xen-traditional too. This is commit 64c27e5b1fdb6d94bdc0bda3b1869d7383a35c65 in git.qemu.org/?p=3Dqemu.git. Jan >> --- a/hw/xen_disk.c >> +++ b/hw/xen_disk.c >> @@ -537,6 +537,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,= =20 > xendev); >> @@ -548,6 +557,11 @@ static void blk_alloc(struct XenDevice * >> 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) >>=20 >>=20 >>=20 >>=20