diff mbox series

[rdma-next,v1,6/6] RDMA/umem: Remove hugetlb flag

Message ID 20190219145745.13476-7-shiraz.saleem@intel.com (mailing list archive)
State Changes Requested
Delegated to: Jason Gunthorpe
Headers show
Series Add APIs to get contiguous memory blocks aligned to a HW supported page size | expand

Commit Message

Saleem, Shiraz Feb. 19, 2019, 2:57 p.m. UTC
The drivers i40iw and bnxt_re no longer dependent on the
hugetlb flag. So remove this flag from ib_umem structure.

Reviewed-by: Michael J. Ruhl <michael.j.ruhl@intel.com>
Signed-off-by: Shiraz Saleem <shiraz.saleem@intel.com>
---
 drivers/infiniband/core/umem.c     | 15 ---------------
 drivers/infiniband/core/umem_odp.c |  3 ---
 include/rdma/ib_umem.h             |  1 -
 3 files changed, 19 deletions(-)

Comments

Jason Gunthorpe Feb. 19, 2019, 8:54 p.m. UTC | #1
On Tue, Feb 19, 2019 at 08:57:45AM -0600, Shiraz Saleem wrote:
> The drivers i40iw and bnxt_re no longer dependent on the
> hugetlb flag. So remove this flag from ib_umem structure.
> 
> Reviewed-by: Michael J. Ruhl <michael.j.ruhl@intel.com>
> Signed-off-by: Shiraz Saleem <shiraz.saleem@intel.com>
>  drivers/infiniband/core/umem.c     | 15 ---------------
>  drivers/infiniband/core/umem_odp.c |  3 ---
>  include/rdma/ib_umem.h             |  1 -
>  3 files changed, 19 deletions(-)
> 
> diff --git a/drivers/infiniband/core/umem.c b/drivers/infiniband/core/umem.c
> index 8c3ec1b..3e2a262 100644
> +++ b/drivers/infiniband/core/umem.c
> @@ -329,7 +329,6 @@ struct ib_umem *ib_umem_get(struct ib_udata *udata, unsigned long addr,
>  	struct mm_struct *mm;
>  	unsigned long npages;
>  	int ret;
> -	int i;
>  	unsigned long dma_attrs = 0;
>  	struct scatterlist *sg;
>  	unsigned int gup_flags = FOLL_WRITE;
> @@ -378,9 +377,6 @@ struct ib_umem *ib_umem_get(struct ib_udata *udata, unsigned long addr,
>  		return umem;
>  	}
>  
> -	/* We assume the memory is from hugetlb until proved otherwise */
> -	umem->hugetlb   = 1;
> -
>  	page_list = (struct page **) __get_free_page(GFP_KERNEL);
>  	if (!page_list) {
>  		ret = -ENOMEM;
> @@ -392,8 +388,6 @@ struct ib_umem *ib_umem_get(struct ib_udata *udata, unsigned long addr,
>  	 * just assume the memory is not hugetlb memory
>  	 */
>  	vma_list = (struct vm_area_struct **) __get_free_page(GFP_KERNEL);
> -	if (!vma_list)
> -		umem->hugetlb = 0;
>  
>  	npages = ib_umem_num_pages(umem);
>  	if (npages == 0 || npages > UINT_MAX) {
> @@ -437,15 +431,6 @@ struct ib_umem *ib_umem_get(struct ib_udata *udata, unsigned long addr,
>  		npages   -= ret;
>  
>  		sg = ib_umem_add_sg_table(sg, page_list, ret, &umem->sg_nents);
> -
> -		/* Continue to hold the mmap_sem as vma_list access
> -		 * needs to be protected.
> -		 */
> -		for (i = 0; i < ret && umem->hugetlb; i++) {
> -			if (vma_list && !is_vm_hugetlb_page(vma_list[i]))
> -				umem->hugetlb = 0;
> -		}

This is the only place that reads the vma_list, so please delete it as
well.

Jason
Saleem, Shiraz Feb. 23, 2019, 7:45 p.m. UTC | #2
On Tue, Feb 19, 2019 at 01:54:38PM -0700, Jason Gunthorpe wrote:
> On Tue, Feb 19, 2019 at 08:57:45AM -0600, Shiraz Saleem wrote:
> > The drivers i40iw and bnxt_re no longer dependent on the
> > hugetlb flag. So remove this flag from ib_umem structure.
> > 
> > Reviewed-by: Michael J. Ruhl <michael.j.ruhl@intel.com>
> > Signed-off-by: Shiraz Saleem <shiraz.saleem@intel.com>
> >  drivers/infiniband/core/umem.c     | 15 ---------------
> >  drivers/infiniband/core/umem_odp.c |  3 ---
> >  include/rdma/ib_umem.h             |  1 -
> >  3 files changed, 19 deletions(-)
> > 
> > diff --git a/drivers/infiniband/core/umem.c b/drivers/infiniband/core/umem.c
> > index 8c3ec1b..3e2a262 100644
> > +++ b/drivers/infiniband/core/umem.c
> > @@ -329,7 +329,6 @@ struct ib_umem *ib_umem_get(struct ib_udata *udata, unsigned long addr,
> >  	struct mm_struct *mm;
> >  	unsigned long npages;
> >  	int ret;
> > -	int i;
> >  	unsigned long dma_attrs = 0;
> >  	struct scatterlist *sg;
> >  	unsigned int gup_flags = FOLL_WRITE;
> > @@ -378,9 +377,6 @@ struct ib_umem *ib_umem_get(struct ib_udata *udata, unsigned long addr,
> >  		return umem;
> >  	}
> >  
> > -	/* We assume the memory is from hugetlb until proved otherwise */
> > -	umem->hugetlb   = 1;
> > -
> >  	page_list = (struct page **) __get_free_page(GFP_KERNEL);
> >  	if (!page_list) {
> >  		ret = -ENOMEM;
> > @@ -392,8 +388,6 @@ struct ib_umem *ib_umem_get(struct ib_udata *udata, unsigned long addr,
> >  	 * just assume the memory is not hugetlb memory
> >  	 */
> >  	vma_list = (struct vm_area_struct **) __get_free_page(GFP_KERNEL);
> > -	if (!vma_list)
> > -		umem->hugetlb = 0;
> >  
> >  	npages = ib_umem_num_pages(umem);
> >  	if (npages == 0 || npages > UINT_MAX) {
> > @@ -437,15 +431,6 @@ struct ib_umem *ib_umem_get(struct ib_udata *udata, unsigned long addr,
> >  		npages   -= ret;
> >  
> >  		sg = ib_umem_add_sg_table(sg, page_list, ret, &umem->sg_nents);
> > -
> > -		/* Continue to hold the mmap_sem as vma_list access
> > -		 * needs to be protected.
> > -		 */
> > -		for (i = 0; i < ret && umem->hugetlb; i++) {
> > -			if (vma_list && !is_vm_hugetlb_page(vma_list[i]))
> > -				umem->hugetlb = 0;
> > -		}
> 
> This is the only place that reads the vma_list, so please delete it as
> well.
> 
Sure.
diff mbox series

Patch

diff --git a/drivers/infiniband/core/umem.c b/drivers/infiniband/core/umem.c
index 8c3ec1b..3e2a262 100644
--- a/drivers/infiniband/core/umem.c
+++ b/drivers/infiniband/core/umem.c
@@ -329,7 +329,6 @@  struct ib_umem *ib_umem_get(struct ib_udata *udata, unsigned long addr,
 	struct mm_struct *mm;
 	unsigned long npages;
 	int ret;
-	int i;
 	unsigned long dma_attrs = 0;
 	struct scatterlist *sg;
 	unsigned int gup_flags = FOLL_WRITE;
@@ -378,9 +377,6 @@  struct ib_umem *ib_umem_get(struct ib_udata *udata, unsigned long addr,
 		return umem;
 	}
 
-	/* We assume the memory is from hugetlb until proved otherwise */
-	umem->hugetlb   = 1;
-
 	page_list = (struct page **) __get_free_page(GFP_KERNEL);
 	if (!page_list) {
 		ret = -ENOMEM;
@@ -392,8 +388,6 @@  struct ib_umem *ib_umem_get(struct ib_udata *udata, unsigned long addr,
 	 * just assume the memory is not hugetlb memory
 	 */
 	vma_list = (struct vm_area_struct **) __get_free_page(GFP_KERNEL);
-	if (!vma_list)
-		umem->hugetlb = 0;
 
 	npages = ib_umem_num_pages(umem);
 	if (npages == 0 || npages > UINT_MAX) {
@@ -437,15 +431,6 @@  struct ib_umem *ib_umem_get(struct ib_udata *udata, unsigned long addr,
 		npages   -= ret;
 
 		sg = ib_umem_add_sg_table(sg, page_list, ret, &umem->sg_nents);
-
-		/* Continue to hold the mmap_sem as vma_list access
-		 * needs to be protected.
-		 */
-		for (i = 0; i < ret && umem->hugetlb; i++) {
-			if (vma_list && !is_vm_hugetlb_page(vma_list[i]))
-				umem->hugetlb = 0;
-		}
-
 		up_read(&mm->mmap_sem);
 	}
 
diff --git a/drivers/infiniband/core/umem_odp.c b/drivers/infiniband/core/umem_odp.c
index 012044f..63ccf67 100644
--- a/drivers/infiniband/core/umem_odp.c
+++ b/drivers/infiniband/core/umem_odp.c
@@ -416,9 +416,6 @@  int ib_umem_odp_get(struct ib_umem_odp *umem_odp, int access)
 		h = hstate_vma(vma);
 		umem->page_shift = huge_page_shift(h);
 		up_read(&mm->mmap_sem);
-		umem->hugetlb = 1;
-	} else {
-		umem->hugetlb = 0;
 	}
 
 	mutex_init(&umem_odp->umem_mutex);
diff --git a/include/rdma/ib_umem.h b/include/rdma/ib_umem.h
index 49bd444..be9dfeb 100644
--- a/include/rdma/ib_umem.h
+++ b/include/rdma/ib_umem.h
@@ -48,7 +48,6 @@  struct ib_umem {
 	unsigned long address;
 	int page_shift;
 	u32 writable : 1;
-	u32 hugetlb : 1;
 	u32 is_odp : 1;
 	struct work_struct work;
 	struct sg_table sg_head;