Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp639717yba; Fri, 3 May 2019 08:08:16 -0700 (PDT) X-Google-Smtp-Source: APXvYqx/7puxNLMpQ+o9u0f/IQoJ58dDnFLnbFI30YJOX9QeiRRixzsbNR0CiuF5p7J9imD0oyoy X-Received: by 2002:aa7:92d1:: with SMTP id k17mr11571133pfa.91.1556896096776; Fri, 03 May 2019 08:08:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556896096; cv=none; d=google.com; s=arc-20160816; b=LCr2w9r4lY45PN5iN6Jp1mVCi6CTw6//tMnzTpAxtHmcqWwvQkSOY6AqfwbtoSCzqQ g/vFfxGKXNI5xp5rsb2wDX7kAMvRiTi+MpalX5IM9oaUMNo1z8kDa6VS7k/A552S05qW P6QtZ1bJvpSVtb02dBtgmplCNsNbWR6fLtUHhpS3n/ksubTKNhvKHynXf0pd3M6VQCQz kr3vqsPlSUisEPBCBLloTQ/fGA7TZcZbQ6XOvmz32qEMahLD1I2uxDvmXcDd9OMo5O54 bE2MJKjkKYKgEjHGZf8RcOZ/LFsPrF+1ypVgpXorGC1rGG55y3WkxSgFYVIhB1iSjW42 W+dw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=nEhFxqVNThUQk1XHh0tyW3wO+zhOrmpy17w0QcweHdE=; b=QdP6TGbMrA3CVf5DJqUDpwceudnxD5J+77bBVDjK8VXOQTiWDYyMCvQvYCUKGCBlAu 9xsLclJZTgSIZz7vhxvjBXNjeFZectbsD/NaHpmI0NwK3fYXs/ysvdLgGdODJ4XgzlVq 8Q1gn6Y3m93nvbXOoWpi3SR1hy1Yc5hQZOK5hePjPqc67eiFsz6rgS5ItaabvwQ6EdIN m3z0oiG8ZhfSbfCjatbrX4c/xnTWN7O72dgK7Kh5RUPKcfekJNBFdp3YChWRRkUpI2Q4 ce8KxxaT1BSqRAPTZLrvEaGMAUoW3Cr1qSGr4NIDtHPXULmSfwaGMYFuKJniq3Kqsl6j sP3w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r10si2355504pgp.30.2019.05.03.08.07.47; Fri, 03 May 2019 08:08:16 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728182AbfECPEi (ORCPT + 99 others); Fri, 3 May 2019 11:04:38 -0400 Received: from smtp03.citrix.com ([162.221.156.55]:19873 "EHLO SMTP03.CITRIX.COM" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727398AbfECPEi (ORCPT ); Fri, 3 May 2019 11:04:38 -0400 X-IronPort-AV: E=Sophos;i="5.60,426,1549929600"; d="scan'208";a="85072069" From: Roger Pau Monne To: CC: Roger Pau Monne , Boris Ostrovsky , Juergen Gross , Stefano Stabellini , Konrad Rzeszutek Wilk , Jens Axboe , , , Subject: [PATCH] xen-blkfront: switch kcalloc to kvcalloc for large array allocation 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 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org There's no reason to request physically contiguous memory for those allocations. Reported-by: Ian Jackson Signed-off-by: Roger Pau Monné --- 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_info *rinfo) } free_shadow: - kfree(rinfo->shadow[i].grants_used); + kvfree(rinfo->shadow[i].grants_used); rinfo->shadow[i].grants_used = NULL; - kfree(rinfo->shadow[i].indirect_grants); + kvfree(rinfo->shadow[i].indirect_grants); rinfo->shadow[i].indirect_grants = NULL; - kfree(rinfo->shadow[i].sg); + kvfree(rinfo->shadow[i].sg); rinfo->shadow[i].sg = NULL; } @@ -1353,7 +1353,7 @@ static void blkif_free(struct blkfront_info *info, int suspend) for (i = 0; i < info->nr_rings; i++) blkif_free_ring(&info->rinfo[i]); - kfree(info->rinfo); + kvfree(info->rinfo); info->rinfo = NULL; info->nr_rings = 0; } @@ -1914,9 +1914,9 @@ static int negotiate_mq(struct blkfront_info *info) if (!info->nr_rings) info->nr_rings = 1; - info->rinfo = kcalloc(info->nr_rings, - sizeof(struct blkfront_ring_info), - GFP_KERNEL); + info->rinfo = 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 = 0; @@ -2232,17 +2232,17 @@ static int blkfront_setup_indirect(struct blkfront_ring_info *rinfo) for (i = 0; i < BLK_RING_SIZE(info); i++) { rinfo->shadow[i].grants_used = - kcalloc(grants, - sizeof(rinfo->shadow[i].grants_used[0]), - GFP_NOIO); - rinfo->shadow[i].sg = 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 = kvcalloc(psegs, + sizeof(rinfo->shadow[i].sg[0]), + GFP_NOIO); if (info->max_indirect_segments) rinfo->shadow[i].indirect_grants = - 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 == NULL) || (rinfo->shadow[i].sg == NULL) || (info->max_indirect_segments && @@ -2256,11 +2256,11 @@ static int blkfront_setup_indirect(struct blkfront_ring_info *rinfo) out_of_memory: for (i = 0; i < BLK_RING_SIZE(info); i++) { - kfree(rinfo->shadow[i].grants_used); + kvfree(rinfo->shadow[i].grants_used); rinfo->shadow[i].grants_used = NULL; - kfree(rinfo->shadow[i].sg); + kvfree(rinfo->shadow[i].sg); rinfo->shadow[i].sg = NULL; - kfree(rinfo->shadow[i].indirect_grants); + kvfree(rinfo->shadow[i].indirect_grants); rinfo->shadow[i].indirect_grants = NULL; } if (!list_empty(&rinfo->indirect_pages)) { -- 2.17.2 (Apple Git-113)