On Wed, May 01, 2019 at 08:22:27AM +0300, Leon Romanovsky wrote: > @@ -84,6 +85,24 @@ static inline struct ib_umem_odp *to_ib_umem_odp(struct ib_umem *umem) > return container_of(umem, struct ib_umem_odp, umem); > } > > +/* Returns the first page of an ODP umem. */ > +static inline unsigned long ib_umem_start(struct ib_umem_odp *umem_odp) > +{ > + return ALIGN_DOWN(umem_odp->umem.address, 1UL << umem_odp->page_shift); > +} > + > +/* Returns the address of the page after the last one of an ODP umem. */ > +static inline unsigned long ib_umem_end(struct ib_umem_odp *umem_odp) > +{ > + return ALIGN(umem_odp->umem.address + umem_odp->umem.length, > + 1UL << umem_odp->page_shift); > +} > + > +static inline size_t ib_umem_odp_num_pages(struct ib_umem_odp *umem_odp) > +{ > + return (ib_umem_end(umem_odp) - ib_umem_start(umem_odp)) >> PAGE_SHIFT; It seems there are some testing failures with this patch, I think the above PAGE_SHIFT may need to be umem_odp->page_shift But I need to check it Jason