On Wed, Nov 29, 2023 at 02:21:41PM -0600, Shiraz Saleem wrote: > be arbitrary, but for 64k pages, the VA may be offset by some > number of HCA 4k pages and followed by some number of HCA 4k > pages. > > The current iterator doesn't account for either the preceding > 4k pages or the following 4k pages. > > Fix the issue by extending the ib_block_iter to contain > the number of DMA pages like comment [1] says and by using > __sg_advance to start the iterator at the first live HCA page. > > The changes are contained in a parallel set of iterator start > and next functions that are umem aware and specfic to umem > since there is one user of the rdma_for_each_block() without > umem. > > These two fixes prevents the extra pages before and after the > user MR data. > > Fix the preceding pages by using the __sq_advance field to start > at the first 4k page containing MR data. > > Fix the following pages by saving the number of pgsz blocks in > the iterator state and downcounting on each next. > > This fix allows for the elimination of the small page crutch noted > in the Fixes. > > Fixes: 10c75ccb54e4 ("RDMA/umem: Prevent small pages from being returned by ib_umem_find_best_pgsz()") > Link: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/include/rdma/ib_umem.h#n91 [1] > Signed-off-by: Mike Marciniszyn <mike.marciniszyn@xxxxxxxxx> > Signed-off-by: Shiraz Saleem <shiraz.saleem@xxxxxxxxx> > --- > drivers/infiniband/core/umem.c | 6 ------ > include/rdma/ib_umem.h | 9 ++++++++- > include/rdma/ib_verbs.h | 1 + > 3 files changed, 9 insertions(+), 7 deletions(-) Reviewed-by: Jason Gunthorpe <jgg@xxxxxxxxxx> I admit this fix looks so easy and simple I wonder if there was some tricky reason why I didn't do it back then.. Oh well, I've forgotten, I guess we will find out! Jason