From nobody Tue Feb 10 01:59:38 2026 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org ARC-Seal: i=1; a=rsa-sha256; t=1563432840; cv=none; d=zoho.com; s=zohoarc; b=cMOId1GNB6n6quywe1jS7T7bTCjoGRNbYeqhT/JEBaJ3oK5JfHem6TWjXGXEYonMAvAF1vMG7BDduIpwrNFqTVbmiDCY2V2QlGGgGf65uS6rH4x9kUdMRFrquhI6+6cmfmBGm4zyw0a4F8b/q+xtl+x6oMtnZiS7JECB2Uh/9us= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1563432840; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=zgu7Bd/u72f6gY4i+1Zxydum69HJf8TYcU9r9cCFZWk=; b=ZU8mcOlMqsolw7LH1ncb7VMpQNgrXJTYpF//vyahcN/QQsvmkxhGgFb9b49Vq17HPFghz4hNnHPveI3uKxrJK3F5rjDcHsKoBrkdpabzkAzrQxTvOEEH3WnoCxMV12N2L8jCuRdrEv8zlIevt05Y5A7tnMRN7a9GWw6qn1nWEUY= ARC-Authentication-Results: i=1; mx.zoho.com; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1563432840403792.1987269412526; Wed, 17 Jul 2019 23:54:00 -0700 (PDT) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1ho0HG-0003iG-RP; Thu, 18 Jul 2019 06:52:30 +0000 Received: from us1-rack-dfw2.inumbo.com ([104.130.134.6]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1ho0HF-0003i7-Ai for xen-devel@lists.xenproject.org; Thu, 18 Jul 2019 06:52:29 +0000 Received: from mx1.suse.de (unknown [195.135.220.15]) by us1-rack-dfw2.inumbo.com (Halon) with ESMTPS id 9ac8f834-a928-11e9-8980-bc764e045a96; Thu, 18 Jul 2019 06:52:27 +0000 (UTC) Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id E1D4BAE47; Thu, 18 Jul 2019 06:52:26 +0000 (UTC) X-Inumbo-ID: 9ac8f834-a928-11e9-8980-bc764e045a96 X-Virus-Scanned: by amavisd-new at test-mx.suse.de From: Juergen Gross To: xen-devel@lists.xenproject.org, linux-kernel@vger.kernel.org Date: Thu, 18 Jul 2019 08:52:22 +0200 Message-Id: <20190718065222.31310-3-jgross@suse.com> X-Mailer: git-send-email 2.16.4 In-Reply-To: <20190718065222.31310-1-jgross@suse.com> References: <20190718065222.31310-1-jgross@suse.com> Subject: [Xen-devel] [PATCH 2/2] xen/gntdev: switch from kcalloc() to kvcalloc() X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Juergen Gross , Boris Ostrovsky , Stefano Stabellini MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" With sufficient many pages to map gntdev can reach order 9 allocation sizes. As there is no need to have physically contiguous buffers switch to kvcalloc() in order to avoid failing allocations. Signed-off-by: Juergen Gross --- drivers/xen/gntdev.c | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/drivers/xen/gntdev.c b/drivers/xen/gntdev.c index 23e21a9aedf7..961aa778312b 100644 --- a/drivers/xen/gntdev.c +++ b/drivers/xen/gntdev.c @@ -115,14 +115,14 @@ static void gntdev_free_map(struct gntdev_grant_map *= map) gnttab_free_pages(map->count, map->pages); =20 #ifdef CONFIG_XEN_GRANT_DMA_ALLOC - kfree(map->frames); + kvfree(map->frames); #endif - kfree(map->pages); - kfree(map->grants); - kfree(map->map_ops); - kfree(map->unmap_ops); - kfree(map->kmap_ops); - kfree(map->kunmap_ops); + kvfree(map->pages); + kvfree(map->grants); + kvfree(map->map_ops); + kvfree(map->unmap_ops); + kvfree(map->kmap_ops); + kvfree(map->kunmap_ops); kfree(map); } =20 @@ -136,12 +136,12 @@ struct gntdev_grant_map *gntdev_alloc_map(struct gntd= ev_priv *priv, int count, if (NULL =3D=3D add) return NULL; =20 - add->grants =3D kcalloc(count, sizeof(add->grants[0]), GFP_KERNEL); - add->map_ops =3D kcalloc(count, sizeof(add->map_ops[0]), GFP_KERNEL); - add->unmap_ops =3D kcalloc(count, sizeof(add->unmap_ops[0]), GFP_KERNEL); - add->kmap_ops =3D kcalloc(count, sizeof(add->kmap_ops[0]), GFP_KERNEL); - add->kunmap_ops =3D kcalloc(count, sizeof(add->kunmap_ops[0]), GFP_KERNEL= ); - add->pages =3D kcalloc(count, sizeof(add->pages[0]), GFP_KERNEL); + add->grants =3D kvcalloc(count, sizeof(add->grants[0]), GFP_KERNEL); + add->map_ops =3D kvcalloc(count, sizeof(add->map_ops[0]), GFP_KERNEL); + add->unmap_ops =3D kvcalloc(count, sizeof(add->unmap_ops[0]), GFP_KERNEL); + add->kmap_ops =3D kvcalloc(count, sizeof(add->kmap_ops[0]), GFP_KERNEL); + add->kunmap_ops =3D kvcalloc(count, sizeof(add->kunmap_ops[0]), GFP_KERNE= L); + add->pages =3D kvcalloc(count, sizeof(add->pages[0]), GFP_KERNEL); if (NULL =3D=3D add->grants || NULL =3D=3D add->map_ops || NULL =3D=3D add->unmap_ops || @@ -160,8 +160,8 @@ struct gntdev_grant_map *gntdev_alloc_map(struct gntdev= _priv *priv, int count, if (dma_flags & (GNTDEV_DMA_FLAG_WC | GNTDEV_DMA_FLAG_COHERENT)) { struct gnttab_dma_alloc_args args; =20 - add->frames =3D kcalloc(count, sizeof(add->frames[0]), - GFP_KERNEL); + add->frames =3D kvcalloc(count, sizeof(add->frames[0]), + GFP_KERNEL); if (!add->frames) goto err; =20 --=20 2.16.4 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel