On Tue, Apr 30, 2019 at 01:36:14PM +0000, Saleem, Shiraz wrote: > >If we make a MR with VA 0x6400FFF and length 2M-4095 I expect the 2M page > >size with the NIC. > > > >We will have dma_addr_start = 0x2600000 and sg_dma_len = 0x200000 as the > >SGL is always rounded to pages > > why isn't it the sg_dma_len 2M-4095? Is it because we compute npages in ib_umem_get() > to build the SGL? Could using (addr & PAGE_MASK) and then adding dma_len help take > care of this? We always round to page sizes when building the SGL, so the start is rounded down and the end remains the same. > >I have a feeling the uvirt_addr should be computed more like > > > > if (flags & IB_UMEM_VA_BASED_OFFSET) > > mask |= uvirt_addr ^ umem->addr; > > I am not following. > > For a case like below where uvirt_addr = umem_addr, mask = 0 and we run rdma_find_pgbit on it > we ll pick 4K instead of 2M which is wrong. > uvirt_addr [0x7f2b98200000] > best_pgsz [0x201000] > umem->address [0x7f2b98200000] > dma_addr_start [0x130e200000] > dma_addr_end [0x130e400000] > sg_dma_len [2097152] ?? 0x7f2b98200000 ^ 0x7f2b98200000 = 0 So mask isn't altered by the requested VA and you get 2M pages. > Somewhere in the computation of mask, we need to take the va_addr + len and > make sure that's 2M aligned? Correct? No, we only care about the bits in the VA that differ from bits in the PA, ie the bits that can't just pass through the lookup process ie we want to compute the maximum value such that (VA + off) & MASK == (PA + off) Which is the hard upper bound on our page size. > >.. and a more resonable case of say, uvirt_addr = 0 and umem->addr = > >0x271000, then 0 ^ 0x271000 -> means the biggest page size is 4k, which is > >correct. > > > > For ZERO_BASED, is the uvirt_addr just added to umem->addr or not? No, for ZERO_BASED uvirt_addr == 0 and umem->addr is some userspace address Jason