ib: mlx4 map fix for large hugetlb areas
Subsystems (2)
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
@@ -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
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
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
-1n = 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