RE: [PATCH for-rc] Revert "RDMA/efa: Use API to get contiguous memory blocks aligned to device supported page size"

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> Subject: Re: [PATCH for-rc] Revert "RDMA/efa: Use API to get contiguous
> memory blocks aligned to device supported page size"
> 
> On 23/01/2020 16:24, Leon Romanovsky wrote:
> > On Wed, Jan 22, 2020 at 09:57:07AM +0200, Gal Pressman wrote:
> >> On 21/01/2020 18:24, Leon Romanovsky wrote:
> >>> On Tue, Jan 21, 2020 at 11:07:21AM +0200, Gal Pressman wrote:
> >>>> On 20/01/2020 16:10, Gal Pressman wrote:
> >>>>> The cited commit leads to register MR failures and random hangs
> >>>>> when running different MPI applications. The exact root cause for
> >>>>> the issue is still not clear, this revert brings us back to a stable state.
> >>>>>
> >>>>> This reverts commit 40ddb3f020834f9afb7aab31385994811f4db259.
> >>>>>
> >>>>> Fixes: 40ddb3f02083 ("RDMA/efa: Use API to get contiguous memory
> >>>>> blocks aligned to device supported page size")
> >>>>> Cc: Shiraz Saleem <shiraz.saleem@xxxxxxxxx>
> >>>>> Cc: stable@xxxxxxxxxxxxxxx # 5.3
> >>>>> Signed-off-by: Gal Pressman <galpress@xxxxxxxxxx>
> >>>>
> >>>> Shiraz, I think I found the root cause here.
> >>>> I'm noticing a register MR of size 32k, which is constructed from
> >>>> two sges, the first sge of size 12k and the second of 20k.
> >>>>
> >>>> ib_umem_find_best_pgsz returns page shift 13 in the following way:
> >>>>
> >>>> 0x103dcb2000      0x103dcb5000       0x103dd5d000           0x103dd62000
> >>>>           +----------+                      +------------------+
> >>>>           |          |                      |                  |
> >>>>           |  12k     |                      |     20k          |
> >>>>           +----------+                      +------------------+
> >>>>
> >>>>           +------+------+                 +------+------+------+
> >>>>           |      |      |                 |      |      |      |
> >>>>           | 8k   | 8k   |                 | 8k   | 8k   | 8k   |
> >>>>           +------+------+                 +------+------+------+
> >>>> 0x103dcb2000       0x103dcb6000   0x103dd5c000              0x103dd62000
> >>>>
> >>>>
> >>>> The top row is the original umem sgl, and the bottom is the sgl
> >>>> constructed by rdma_for_each_block with page size of 8k.
> >>>>
> >>>> Is this the expected output? The 8k pages cover addresses which
> >>>> aren't part of the MR. This breaks some of the assumptions in the
> >>>> driver (for example, the way we calculate the number of pages in
> >>>> the MR) and I'm not sure our device can handle such sgl.
> >>>
> >>> Artemy wrote this fix that can help you.
> >>>
> >>> commit 60c9fe2d18b657df950a5f4d5a7955694bd08e63
> >>> Author: Artemy Kovalyov <artemyko@xxxxxxxxxxxx>
> >>> Date:   Sun Dec 15 12:43:13 2019 +0200
> >>>
> >>>     RDMA/umem: Fix ib_umem_find_best_pgsz()
> >>>
> >>>     Except for the last entry, the ending iova alignment sets the maximum
> >>>     possible page size as the low bits of the iova must be zero when
> >>>     starting the next chunk.
> >>>
> >>>     Fixes: 4a35339958f1 ("RDMA/umem: Add API to find best driver supported
> page size in an MR")
> >>>     Signed-off-by: Artemy Kovalyov <artemyko@xxxxxxxxxxxx>
> >>>     Signed-off-by: Leon Romanovsky <leonro@xxxxxxxxxxxx>
> >>>
> >>> diff --git a/drivers/infiniband/core/umem.c
> >>> b/drivers/infiniband/core/umem.c index c3769a5f096d..06b6125b5ae1
> >>> 100644
> >>> --- a/drivers/infiniband/core/umem.c
> >>> +++ b/drivers/infiniband/core/umem.c
> >>> @@ -166,10 +166,13 @@ unsigned long ib_umem_find_best_pgsz(struct
> ib_umem *umem,
> >>>                  * for any address.
> >>>                  */
> >>>                 mask |= (sg_dma_address(sg) + pgoff) ^ va;
> >>> -               if (i && i != (umem->nmap - 1))
> >>> -                       /* restrict by length as well for interior SGEs */
> >>> -                       mask |= sg_dma_len(sg);
> >>>                 va += sg_dma_len(sg) - pgoff;
> >>> +               /* Except for the last entry, the ending iova alignment sets
> >>> +                * the maximum possible page size as the low bits of the iova
> >>> +                * must be zero when starting the next chunk.
> >>> +                */
> >>> +               if (i != (umem->nmap - 1))
> >>> +                       mask |= va;
> >>>                 pgoff = 0;
> >>>         }
> >>>         best_pg_bit = rdma_find_pg_bit(mask, pgsz_bitmap);
> >>
> >> Thanks Leon, I'll test this and let you know if it fixes the issue.
> >> When are you planning to submit this?
> >
> > If it fixes your issues, I will be happy to do it.
> 
> So far it looks good to me, I'll let it run over the weekend to be on the safe side.
> 
> Shiraz, does this fix make sense to you?

I 'think' the current algorithm is off because it is not mandating that the page
size be aligned to end of the first sge.

So if I assumed umem->addr = iova = 0x89002000, pgoff = 0.
mask = 0x8000 to start with before we enter for_each_sgl loop.

In your example of the PA layout.

for_each_sg(umem->sg_head.sgl, sg, umem->nmap, i) {
		/* Walk SGL and reduce max page size if VA/PA bits differ
		 * for any address.
		 */
		mask |= (sg_dma_address(sg) + pgoff) ^ va;
			
			/* In first iteration, 
			 * mask = 0x8000 | (0x103dcb2000 + 0) ^ 0x89002000
			 * mask = 0x10b4cb0000
			*/


		if (i && i != (umem->nmap - 1))
			/* restrict by length as well for interior SGEs */
			mask |= sg_dma_len(sg);
		va += sg_dma_len(sg) - pgoff;

			/* In first iteration, va is updated to,
		 	* va = 0x89002000 + 0x3000 = 0x89005000, aligned to 4K
			*/

		pgoff = 0;
	}


But in the second iteration,
0x10b4cb0000  | (0x103dd5d000+ 0) ^ 0x89005000, sets the mask to 0x10b4df8000
and relaxes the max page size.

It would be good to get the debug data to back this or prove it wrong.
But if this is indeed what's happening, then ORing in the sgl->length for the
first sge to restrict the page size might cut it. So something like,

diff --git a/drivers/infiniband/core/umem.c b/drivers/infiniband/core/umem.c
index 7a3b995..1aceb1b 100644
--- a/drivers/infiniband/core/umem.c
+++ b/drivers/infiniband/core/umem.c
@@ -166,8 +166,8 @@ unsigned long ib_umem_find_best_pgsz(struct ib_umem *umem,
                 * for any address.
                 */
                mask |= (sg_dma_address(sg) + pgoff) ^ va;
-               if (i && i != (umem->nmap - 1))
-                       /* restrict by length as well for interior SGEs */
+               if (i != (umem->nmap - 1))
+                       /* restrict by length for all but last SGE */
                        mask |= sg_dma_len(sg);
                va += sg_dma_len(sg) - pgoff;
                pgoff = 0;


Artemy fix of using the ending iova alignment to restricts the page size
appears to achieve the same ..
> >>>                 va += sg_dma_len(sg) - pgoff;
> >>> +               /* Except for the last entry, the ending iova alignment sets
> >>> +                * the maximum possible page size as the low bits of the iova
> >>> +                * must be zero when starting the next chunk.
> >>> +                */
> >>> +               if (i != (umem->nmap - 1))
> >>> +                       mask |= va;

In our example, at end of first iteration, mask = 0x10b4cb0000  | 0x89005000= 0x10bdcb5000,
you would restrict to 4K.









[Index of Archives]     [Linux Kernel]     [Kernel Development Newbies]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite Hiking]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux