Skip to contentSkip to conversation

ib: mlx4 map fix for large hugetlb areas

PATCH In review Dan aloni 3 participants 3 messages Jun 6, 2011 1 message not in the archive

Subsystems (2)
lore
Share & tools
lore

Dan aloni

author
#0 lore raw

PATCH 1/1 ib: mlx4 map fix for large hugetlb areas

When an application tries to map a large area of hugetlb pages, the mlx4 code rightfully reachs handle_hugetlb_user_mr(). This function uses an intermediate allocation in order to pass the list of big pages to mlx4_write_mtt(), however that this allocation, when passing over for example, 128GB of hugetlb memory (63365 pages), maps to 65536*8 bytes of memory, which is not supported by kmalloc() under various kernel configurations.

It would be prudent to use vmalloc() here.

NOTE: core_umem will still hold 1GB of descriptors for mapping 128GB of memory, even though it's hugetlb. This needs to be optimized as well.

---
 drivers/infiniband/hw/mlx4/mr.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
drivers/infiniband/hw/mlx4/mr.c +2 -2
index e6c096c..59f2909 100644
@@ -140,7 +140,7 @@ static int handle_hugetlb_user_mr(struct ib_pd *pd, struct mlx4_ib_mr *mr,
 	int off = start & (HPAGE_SIZE - 1);
 
 	n = DIV_ROUND_UP(off + umem->length, HPAGE_SIZE);
-	arr = kmalloc(n * sizeof *arr, GFP_KERNEL);
+	arr = vmalloc(n * sizeof *arr);
 	if (!arr)
 		return -ENOMEM;
 
@@ -178,7 +178,7 @@ static int handle_hugetlb_user_mr(struct ib_pd *pd, struct mlx4_ib_mr *mr,
 	err = mlx4_write_mtt(dev->dev, &mr->mmr.mtt, 0, n, arr);
 
 out:
-	kfree(arr);
+	vfree(arr);
 	return err;
 #else
 	return -ENOSYS;
Signature · 6 lines
1.7.1

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#1 lore raw

drivers/infiniband/hw/mlx4/mr.c static int handle_hugetlb_user_mr(struct ib_pd *pd, struct mlx4_ib_mr *mr, · line 146

Quoted 11 lines · Dan aloni
drivers/infiniband/hw/mlx4/mr.c +1 -1
@@ -140,7 +140,7 @@ static int handle_hugetlb_user_mr(struct ib_pd *pd, struct mlx4_ib_mr *mr,
        int off = start & (HPAGE_SIZE - 1);
 
        n = DIV_ROUND_UP(off + umem->length, HPAGE_SIZE);
-       arr = kmalloc(n * sizeof *arr, GFP_KERNEL);
+       arr = vmalloc(n * sizeof *arr);
        if (!arr)
                return -ENOMEM;
 

I'm not able to find anywhere in the mlx4 driver where this patch would have a chance at applying??

- R.
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): BANLkTikatAo9FYO=iuNzCk2X9x_mAr3mZg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org

#3 lore raw
Quoted 6 lines · Roland Dreier
Quoted 5 lines · Dan aloni
drivers/infiniband/hw/mlx4/mr.c +0 -0
@@ -140,7 +140,7 @@ static int handle_hugetlb_user_mr(struct ib_pd *pd, struct mlx4_ib_mr *mr,
        int off = start & (HPAGE_SIZE - 1);
 
Quoted 10 lines

drivers/infiniband/hw/mlx4/mr.c static int handle_hugetlb_user_mr(struct ib_pd *pd, struct mlx4_ib_mr *mr, · line 146

Quoted 6 lines
drivers/infiniband/hw/mlx4/mr.c +1 -1
        n = DIV_ROUND_UP(off + umem->length, HPAGE_SIZE);
-       arr = kmalloc(n * sizeof *arr, GFP_KERNEL);
+       arr = vmalloc(n * sizeof *arr);
        if (!arr)
                return -ENOMEM;
 

I'm not able to find anywhere in the mlx4 driver where this patch would have a chance at applying??

I submitted this patch about 2 years ago. As far as I recall there was a problem to obtain the huge page size for powerpc archs and that's were the patch died. We're are using it in OFED for x86_64 and it gives significant improvement when registering huge pages. I will re-submit an up to date version.
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html