Skip to contentSkip to conversation

xen-blkfront: switch kcalloc to kvcalloc for large array allocation

PATCH Applied Roger Pau Monne 5 participants 10 messages May 3, 2019 – Jun 4, 2019

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 xen-blkfront: switch kcalloc to kvcalloc for large array allocation

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

---
Cc: Boris Ostrovsky <[email protected]>
Cc: Juergen Gross <[email protected]>
Cc: Stefano Stabellini <[email protected]>
Cc: Konrad Rzeszutek Wilk <[email protected]>
Cc: Jens Axboe <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]

---
 drivers/block/xen-blkfront.c | 38 ++++++++++++++++++------------------
 1 file changed, 19 insertions(+), 19 deletions(-)
drivers/block/xen-blkfront.c +19 -19
index d43a5677ccbc..a74d03913822 100644
@@ -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)) {
Signature · 1 line
2.17.2 (Apple Git-113)
maintainer
#1 lore raw
Quoted 6 lines · Roger Pau Monne

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

---

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

--
Thanks,
Sasha

Quoted 9 lines
Cc Boris Ostrovsky <[email protected]>
Cc Juergen Gross <[email protected]>
Cc Stefano Stabellini <[email protected]>
Cc Konrad Rzeszutek Wilk <[email protected]>
Cc Jens Axboe <[email protected]>

---

maintainer
#2 lore raw
In reply to Roger Pau Monne
Quoted 6 lines · Roger Pau Monne

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

---

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

--
Thanks,
Sasha

Quoted 9 lines
Cc Boris Ostrovsky <[email protected]>
Cc Juergen Gross <[email protected]>
Cc Stefano Stabellini <[email protected]>
Cc Konrad Rzeszutek Wilk <[email protected]>
Cc Jens Axboe <[email protected]>

---

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#5 lore raw
Quoted 5 lines · Juergen Gross
Quoted 4 lines · Juergen Gross
Quoted 3 lines · Roger Pau Monne

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

Quoted 7 lines
Quoted 4 lines
Quoted 2 lines

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).

Quoted 3 lines

Juergen

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#6 lore raw
In reply to Juergen Gross
Quoted 5 lines · Juergen Gross
Quoted 4 lines · Juergen Gross
Quoted 3 lines · Roger Pau Monne

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

Quoted 7 lines
Quoted 4 lines
Quoted 2 lines

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).

Quoted 3 lines

Juergen

#7 lore raw
Quoted 6 lines · Konrad Rzeszutek Wilk
Quoted 5 lines · Juergen Gross
Quoted 4 lines · Juergen Gross
Quoted 3 lines · Roger Pau Monne

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

Quoted 8 lines
Quoted 5 lines
Quoted 3 lines
Quoted 2 lines

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

maintainer
#8 lore raw
In reply to Juergen Gross
Quoted 8 lines · Juergen Gross
Quoted 5 lines · Roger Pau Monne

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

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

Juergen

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

maintainer Reviewed-by on v1 1/1
#9 lore raw
In reply to Roger Pau Monne
Quoted 5 lines · Roger Pau Monne

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

Juergen

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel