linux-block.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] xen-blkfront: switch kcalloc to kvcalloc for large array allocation
@ 2019-05-03 15:04 Roger Pau Monne
  2019-05-05 19:12 ` Sasha Levin
  2019-05-06  8:11 ` Juergen Gross
  0 siblings, 2 replies; 6+ messages in thread
From: Roger Pau Monne @ 2019-05-03 15:04 UTC (permalink / raw)
  To: linux-kernel
  Cc: Roger Pau Monne, Boris Ostrovsky, Juergen Gross,
	Stefano Stabellini, Konrad Rzeszutek Wilk, Jens Axboe, xen-devel,
	linux-block, stable

There's no reason to request physically contiguous memory for those
allocations.

Reported-by: Ian Jackson <ian.jackson@citrix.com>
Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
---
Cc: Boris Ostrovsky <boris.ostrovsky@oracle.com>
Cc: Juergen Gross <jgross@suse.com>
Cc: Stefano Stabellini <sstabellini@kernel.org>
Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Cc: Jens Axboe <axboe@kernel.dk>
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)


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] xen-blkfront: switch kcalloc to kvcalloc for large array allocation
  2019-05-03 15:04 [PATCH] xen-blkfront: switch kcalloc to kvcalloc for large array allocation Roger Pau Monne
@ 2019-05-05 19:12 ` Sasha Levin
  2019-05-06  8:11 ` Juergen Gross
  1 sibling, 0 replies; 6+ messages in thread
From: Sasha Levin @ 2019-05-05 19:12 UTC (permalink / raw)
  To: Roger Pau Monne
  Cc: linux-kernel, Boris Ostrovsky, Juergen Gross, Stefano Stabellini,
	Konrad Rzeszutek Wilk, Jens Axboe, xen-devel, linux-block,
	stable

On Fri, May 03, 2019 at 05:04:01PM +0200, Roger Pau Monne wrote:
>There's no reason to request physically contiguous memory for those
>allocations.
>
>Reported-by: Ian Jackson <ian.jackson@citrix.com>
>Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
>---

You really don't want this scissor line here, git will trim all your
message content below it.

--
Thanks,
Sasha

>Cc: Boris Ostrovsky <boris.ostrovsky@oracle.com>
>Cc: Juergen Gross <jgross@suse.com>
>Cc: Stefano Stabellini <sstabellini@kernel.org>
>Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
>Cc: Jens Axboe <axboe@kernel.dk>
>Cc: xen-devel@lists.xenproject.org
>Cc: linux-block@vger.kernel.org
>Cc: stable@vger.kernel.org
>---

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] xen-blkfront: switch kcalloc to kvcalloc for large array allocation
  2019-05-03 15:04 [PATCH] xen-blkfront: switch kcalloc to kvcalloc for large array allocation Roger Pau Monne
  2019-05-05 19:12 ` Sasha Levin
@ 2019-05-06  8:11 ` Juergen Gross
  2019-05-31 14:41   ` [Xen-devel] " Juergen Gross
  1 sibling, 1 reply; 6+ messages in thread
From: Juergen Gross @ 2019-05-06  8:11 UTC (permalink / raw)
  To: Roger Pau Monne, linux-kernel
  Cc: Boris Ostrovsky, Stefano Stabellini, Konrad Rzeszutek Wilk,
	Jens Axboe, xen-devel, linux-block, stable

On 03/05/2019 17:04, Roger Pau Monne wrote:
> There's no reason to request physically contiguous memory for those
> allocations.
> 
> Reported-by: Ian Jackson <ian.jackson@citrix.com>
> Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>

Reviewed-by: Juergen Gross <jgross@suse.com>


Juergen

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Xen-devel] [PATCH] xen-blkfront: switch kcalloc to kvcalloc for large array allocation
  2019-05-06  8:11 ` Juergen Gross
@ 2019-05-31 14:41   ` Juergen Gross
  2019-05-31 14:44     ` Konrad Rzeszutek Wilk
  0 siblings, 1 reply; 6+ messages in thread
From: Juergen Gross @ 2019-05-31 14:41 UTC (permalink / raw)
  To: Roger Pau Monne, linux-kernel, Jens Axboe
  Cc: Stefano Stabellini, Konrad Rzeszutek Wilk, stable, linux-block,
	xen-devel, Boris Ostrovsky

On 06/05/2019 10:11, Juergen Gross wrote:
> On 03/05/2019 17:04, Roger Pau Monne wrote:
>> There's no reason to request physically contiguous memory for those
>> allocations.
>>
>> Reported-by: Ian Jackson <ian.jackson@citrix.com>
>> Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
> 
> Reviewed-by: Juergen Gross <jgross@suse.com>

Jens, are you going to tkae this patch or should I carry it through the
Xen tree?


Juergen

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Xen-devel] [PATCH] xen-blkfront: switch kcalloc to kvcalloc for large array allocation
  2019-05-31 14:41   ` [Xen-devel] " Juergen Gross
@ 2019-05-31 14:44     ` Konrad Rzeszutek Wilk
  2019-06-04 13:11       ` Boris Ostrovsky
  0 siblings, 1 reply; 6+ messages in thread
From: Konrad Rzeszutek Wilk @ 2019-05-31 14:44 UTC (permalink / raw)
  To: Juergen Gross, Roger Pau Monne, linux-kernel, Jens Axboe
  Cc: Stefano Stabellini, stable, linux-block, xen-devel, Boris Ostrovsky

On May 31, 2019 10:41:16 AM EDT, Juergen Gross <jgross@suse.com> wrote:
>On 06/05/2019 10:11, Juergen Gross wrote:
>> On 03/05/2019 17:04, Roger Pau Monne wrote:
>>> There's no reason to request physically contiguous memory for those
>>> allocations.
>>>
>>> Reported-by: Ian Jackson <ian.jackson@citrix.com>
>>> Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
>> 
>> Reviewed-by: Juergen Gross <jgross@suse.com>
>
>Jens, are you going to tkae this patch or should I carry it through the
>Xen tree?

Usually I ended up picking them (and then asking Jens to git pull into his branch) but if you want to handle them that would be much easier!

(And if so, please add Acked-by on them from me).
>
>
>Juergen


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Xen-devel] [PATCH] xen-blkfront: switch kcalloc to kvcalloc for large array allocation
  2019-05-31 14:44     ` Konrad Rzeszutek Wilk
@ 2019-06-04 13:11       ` Boris Ostrovsky
  0 siblings, 0 replies; 6+ messages in thread
From: Boris Ostrovsky @ 2019-06-04 13:11 UTC (permalink / raw)
  To: Konrad Rzeszutek Wilk, Juergen Gross, Roger Pau Monne,
	linux-kernel, Jens Axboe
  Cc: Stefano Stabellini, stable, linux-block, xen-devel

On 5/31/19 10:44 AM, Konrad Rzeszutek Wilk wrote:
> On May 31, 2019 10:41:16 AM EDT, Juergen Gross <jgross@suse.com> wrote:
>> On 06/05/2019 10:11, Juergen Gross wrote:
>>> On 03/05/2019 17:04, Roger Pau Monne wrote:
>>>> There's no reason to request physically contiguous memory for those
>>>> allocations.
>>>>
>>>> Reported-by: Ian Jackson <ian.jackson@citrix.com>
>>>> Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
>>> Reviewed-by: Juergen Gross <jgross@suse.com>
>> Jens, are you going to tkae this patch or should I carry it through the
>> Xen tree?
> Usually I ended up picking them (and then asking Jens to git pull into his branch) but if you want to handle them that would be much easier!
>
> (And if so, please add Acked-by on them from me).


Applied to for-linus-5.2b

-boris

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2019-06-04 13:13 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-03 15:04 [PATCH] xen-blkfront: switch kcalloc to kvcalloc for large array allocation Roger Pau Monne
2019-05-05 19:12 ` Sasha Levin
2019-05-06  8:11 ` Juergen Gross
2019-05-31 14:41   ` [Xen-devel] " Juergen Gross
2019-05-31 14:44     ` Konrad Rzeszutek Wilk
2019-06-04 13:11       ` Boris Ostrovsky

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).