From nobody Fri Apr 19 20:18:40 2024 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=1556895983; cv=none; d=zoho.com; s=zohoarc; b=NcLB5MBCNGdU/L01A5aTlU2G1NMIUMYD7meA+dKjaespZIKcAKCXsFtoGFKq3QsgVHghXK11j29nE+QBPIhsKXEiEc/lm9/lfAG/20+zF88U+U+mQxrssCTmRBE4dm1FnbeecHDOfvqFynx7PgF4lI4wj0wj2Z8J/3HH/8zbodU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1556895983; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To:ARC-Authentication-Results; bh=9IGTmaZaxMAuAFLsGjuehRyPJQjjFgaZ7CLOv2kdzAE=; b=KalVAsDp0SbzfCwWaIUNgOE3SrCW9dYUhlv9VtrbA+NP8XtZfc6YjKapDFTIt76Ooc1LwysG3bmNbWs21QNWPY2UT2Le8+w0R6QYliIBRrEgz74nRIqXDBxEbn+DRNxu7VYqYojjg1elcNLtmdRamDQXEPkMs5TmmCG/8aRn+KM= 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 155689598291468.83352807451706; Fri, 3 May 2019 08:06:22 -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 1hMZk6-0001We-36; Fri, 03 May 2019 15:04:54 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hMZk4-0001WZ-79 for xen-devel@lists.xenproject.org; Fri, 03 May 2019 15:04:52 +0000 Received: from SMTP03.CITRIX.COM (unknown [162.221.156.55]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id c4c6c5e2-6db4-11e9-b184-8705b175f1f1; Fri, 03 May 2019 15:04:39 +0000 (UTC) X-Inumbo-ID: c4c6c5e2-6db4-11e9-b184-8705b175f1f1 X-IronPort-AV: E=Sophos;i="5.60,426,1549929600"; d="scan'208";a="85072069" From: Roger Pau Monne To: Date: Fri, 3 May 2019 17:04:01 +0200 Message-ID: <20190503150401.15904-1-roger.pau@citrix.com> X-Mailer: git-send-email 2.17.2 (Apple Git-113) MIME-Version: 1.0 Subject: [Xen-devel] [PATCH] xen-blkfront: switch kcalloc to kvcalloc for large array allocation 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 , Jens Axboe , Stefano Stabellini , Konrad Rzeszutek Wilk , stable@vger.kernel.org, linux-block@vger.kernel.org, xen-devel@lists.xenproject.org, Boris Ostrovsky , Roger Pau Monne Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" There's no reason to request physically contiguous memory for those allocations. Reported-by: Ian Jackson Signed-off-by: Roger Pau Monn=C3=A9 Reviewed-by: Juergen Gross --- Cc: Boris Ostrovsky Cc: Juergen Gross Cc: Stefano Stabellini Cc: Konrad Rzeszutek Wilk Cc: Jens Axboe Cc: xen-devel@lists.xenproject.org Cc: linux-block@vger.kernel.org Cc: stable@vger.kernel.org --- drivers/block/xen-blkfront.c | 38 ++++++++++++++++++------------------ 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/drivers/block/xen-blkfront.c b/drivers/block/xen-blkfront.c index d43a5677ccbc..a74d03913822 100644 --- a/drivers/block/xen-blkfront.c +++ b/drivers/block/xen-blkfront.c @@ -1310,11 +1310,11 @@ static void blkif_free_ring(struct blkfront_ring_in= fo *rinfo) } =20 free_shadow: - kfree(rinfo->shadow[i].grants_used); + kvfree(rinfo->shadow[i].grants_used); rinfo->shadow[i].grants_used =3D NULL; - kfree(rinfo->shadow[i].indirect_grants); + kvfree(rinfo->shadow[i].indirect_grants); rinfo->shadow[i].indirect_grants =3D NULL; - kfree(rinfo->shadow[i].sg); + kvfree(rinfo->shadow[i].sg); rinfo->shadow[i].sg =3D NULL; } =20 @@ -1353,7 +1353,7 @@ static void blkif_free(struct blkfront_info *info, in= t suspend) for (i =3D 0; i < info->nr_rings; i++) blkif_free_ring(&info->rinfo[i]); =20 - kfree(info->rinfo); + kvfree(info->rinfo); info->rinfo =3D NULL; info->nr_rings =3D 0; } @@ -1914,9 +1914,9 @@ static int negotiate_mq(struct blkfront_info *info) if (!info->nr_rings) info->nr_rings =3D 1; =20 - info->rinfo =3D kcalloc(info->nr_rings, - sizeof(struct blkfront_ring_info), - GFP_KERNEL); + info->rinfo =3D kvcalloc(info->nr_rings, + sizeof(struct blkfront_ring_info), + GFP_KERNEL); if (!info->rinfo) { xenbus_dev_fatal(info->xbdev, -ENOMEM, "allocating ring_info structure"); info->nr_rings =3D 0; @@ -2232,17 +2232,17 @@ static int blkfront_setup_indirect(struct blkfront_= ring_info *rinfo) =20 for (i =3D 0; i < BLK_RING_SIZE(info); i++) { rinfo->shadow[i].grants_used =3D - kcalloc(grants, - sizeof(rinfo->shadow[i].grants_used[0]), - GFP_NOIO); - rinfo->shadow[i].sg =3D kcalloc(psegs, - sizeof(rinfo->shadow[i].sg[0]), - GFP_NOIO); + kvcalloc(grants, + sizeof(rinfo->shadow[i].grants_used[0]), + GFP_NOIO); + rinfo->shadow[i].sg =3D kvcalloc(psegs, + sizeof(rinfo->shadow[i].sg[0]), + GFP_NOIO); if (info->max_indirect_segments) rinfo->shadow[i].indirect_grants =3D - kcalloc(INDIRECT_GREFS(grants), - sizeof(rinfo->shadow[i].indirect_grants[0]), - GFP_NOIO); + kvcalloc(INDIRECT_GREFS(grants), + sizeof(rinfo->shadow[i].indirect_grants[0]), + GFP_NOIO); if ((rinfo->shadow[i].grants_used =3D=3D NULL) || (rinfo->shadow[i].sg =3D=3D NULL) || (info->max_indirect_segments && @@ -2256,11 +2256,11 @@ static int blkfront_setup_indirect(struct blkfront_= ring_info *rinfo) =20 out_of_memory: for (i =3D 0; i < BLK_RING_SIZE(info); i++) { - kfree(rinfo->shadow[i].grants_used); + kvfree(rinfo->shadow[i].grants_used); rinfo->shadow[i].grants_used =3D NULL; - kfree(rinfo->shadow[i].sg); + kvfree(rinfo->shadow[i].sg); rinfo->shadow[i].sg =3D NULL; - kfree(rinfo->shadow[i].indirect_grants); + kvfree(rinfo->shadow[i].indirect_grants); rinfo->shadow[i].indirect_grants =3D NULL; } if (!list_empty(&rinfo->indirect_pages)) { --=20 2.17.2 (Apple Git-113) _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel