Skip to contentSkip to conversation

RDMA/rxe: Break endless pagefault loop for RO pages

PATCH Applied Leon Romanovsky 3 participants 9 messages May 22, 2025 – May 23, 2025

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 RDMA/rxe: Break endless pagefault loop for RO pages

From: Leon Romanovsky <[email protected]>

RO pages has "perm" equal to 0, that caused to the situation where such pages were marked as needed to have fault and caused to infinite loop.

Fixes eedd5b1276e7 ("RDMA/umem: Store ODP access mask information in PFN")
---
 drivers/infiniband/sw/rxe/rxe_odp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/infiniband/sw/rxe/rxe_odp.c +1 -1
index a1416626f61a5..0f67167ddddd1 100644
@@ -137,7 +137,7 @@ static inline bool rxe_check_pagefault(struct ib_umem_odp *umem_odp,
 	while (addr < iova + length) {
 		idx = (addr - ib_umem_start(umem_odp)) >> umem_odp->page_shift;
 
-		if (!(umem_odp->map.pfn_list[idx] & perm)) {
+		if (!(umem_odp->map.pfn_list[idx] & HMM_PFN_VALID)) {
 			need_fault = true;
 			break;
 		}
Signature · 1 line
2.49.0
Tested-by on v1 1/1
#1 lore raw
Quoted 10 lines · Leon Romanovsky

From: Leon Romanovsky <[email protected]>

RO pages has "perm" equal to 0, that caused to the situation where such pages were marked as needed to have fault and caused to infinite loop.

Fixes eedd5b1276e7 ("RDMA/umem: Store ODP access mask information in PFN")

Thank you!
This change fixes one of the two issues I reported.
The kernel module does not get stuck in rxe_ib_invalidate_range() anymore.

The remaining one is the stuck issue in uverbs_destroy_ufile_hw(). cf. https://lore.kernel.org/all/[email protected]/

The issue occurs with test_odp_async_prefetch_rc_traffic, which is not yet enabled in rxe. It might indicate that the root cause lies in ib_uverbs layer. I will take a closer look anyway.

Thanks,
Daisuke

Quoted 17 lines
---
  drivers/infiniband/sw/rxe/rxe_odp.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/infiniband/sw/rxe/rxe_odp.c +1 -1
index a1416626f61a5..0f67167ddddd1 100644
@@ -137,7 +137,7 @@ static inline bool rxe_check_pagefault(struct ib_umem_odp *umem_odp,
  	while (addr < iova + length) {
  		idx = (addr - ib_umem_start(umem_odp)) >> umem_odp->page_shift;
 
-		if (!(umem_odp->map.pfn_list[idx] & perm)) {
+		if (!(umem_odp->map.pfn_list[idx] & HMM_PFN_VALID)) {
  			need_fault = true;
  			break;
  		}
#2 lore raw
Quoted 15 lines · Daisuke Matsuda
Quoted 10 lines · Leon Romanovsky

From: Leon Romanovsky <[email protected]>

RO pages has "perm" equal to 0, that caused to the situation where such pages were marked as needed to have fault and caused to infinite loop.

Fixes eedd5b1276e7 ("RDMA/umem: Store ODP access mask information in PFN")
Quoted 7 lines

Thank you!
This change fixes one of the two issues I reported.
The kernel module does not get stuck in rxe_ib_invalidate_range() anymore.

The remaining one is the stuck issue in uverbs_destroy_ufile_hw(). cf. https://lore.kernel.org/all/[email protected]/

Thanks, I updated the link to point to https://lore.kernel.org/all/[email protected]/

Quoted 3 lines

The issue occurs with test_odp_async_prefetch_rc_traffic, which is not yet enabled in rxe. It might indicate that the root cause lies in ib_uverbs layer.

Unlikely, up till now, it indicated that driver didn't release some uverb object.

Quoted 23 lines

I will take a closer look anyway.

Thanks,
Daisuke

Quoted 16 lines
---
  drivers/infiniband/sw/rxe/rxe_odp.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/infiniband/sw/rxe/rxe_odp.c +1 -1
index a1416626f61a5..0f67167ddddd1 100644
@@ -137,7 +137,7 @@ static inline bool rxe_check_pagefault(struct ib_umem_odp *umem_odp,
  	while (addr < iova + length) {
  		idx = (addr - ib_umem_start(umem_odp)) >> umem_odp->page_shift;
-		if (!(umem_odp->map.pfn_list[idx] & perm)) {
+		if (!(umem_odp->map.pfn_list[idx] & HMM_PFN_VALID)) {
  			need_fault = true;
  			break;
  		}
#3 lore raw
Quoted 24 lines · Leon Romanovsky
Quoted 15 lines · Daisuke Matsuda
Quoted 10 lines · Leon Romanovsky

From: Leon Romanovsky <[email protected]>

RO pages has "perm" equal to 0, that caused to the situation where such pages were marked as needed to have fault and caused to infinite loop.

Fixes eedd5b1276e7 ("RDMA/umem: Store ODP access mask information in PFN")
Quoted 7 lines

Thank you!
This change fixes one of the two issues I reported.
The kernel module does not get stuck in rxe_ib_invalidate_range() anymore.

The remaining one is the stuck issue in uverbs_destroy_ufile_hw(). cf. https://lore.kernel.org/all/[email protected]/

Quoted 8 lines

Thanks, I updated the link to point to https://lore.kernel.org/all/[email protected]/

Quoted 3 lines

The issue occurs with test_odp_async_prefetch_rc_traffic, which is not yet enabled in rxe. It might indicate that the root cause lies in ib_uverbs layer.

Unlikely, up till now, it indicated that driver didn't release some uverb object.

BTW, all places in RXE driver which do the following:
page = hmm_pfn_to_page(umem_odp->map.pfn_list[index]); if (!page) {
...

are incorrect, hmm_pfn_to_page() will always return something.

Thanks

#4 lore raw
In reply to Daisuke Matsuda
Quoted 8 lines · Daisuke Matsuda
Quoted 6 lines · Leon Romanovsky

From: Leon Romanovsky <[email protected]>

RO pages has "perm" equal to 0, that caused to the situation where such pages were marked as needed to have fault and caused to infinite loop.

Quoted 6 lines
Quoted 4 lines
Fixes eedd5b1276e7 ("RDMA/umem: Store ODP access mask information in PFN")

In the bug report mail, you mentioned
"
After these two patches are merged to the for-next tree, RXE ODP test always hangs:
RDMA/core: Convert UMEM ODP DMA mapping to caching IOVA and page linkage RDMA/umem: Store ODP access mask information in PFN
"

After this commit is applied, which of the two previous commits is innocent, and which one causes the "stuck issue in uverbs_destroy_ufile_hw"?

Best Regards,
Yanjun.Zhu

Quoted 35 lines

Thank you!
This change fixes one of the two issues I reported.
The kernel module does not get stuck in rxe_ib_invalidate_range() anymore.

The remaining one is the stuck issue in uverbs_destroy_ufile_hw(). cf. https://lore.kernel.org/all/[email protected]/

The issue occurs with test_odp_async_prefetch_rc_traffic, which is not yet enabled in rxe. It might indicate that the root cause lies in ib_uverbs layer. I will take a closer look anyway.

Thanks,
Daisuke

Quoted 17 lines

---
  drivers/infiniband/sw/rxe/rxe_odp.c | 2 +-

  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/infiniband/sw/rxe/rxe_odp.c +1 -1
index a1416626f61a5..0f67167ddddd1 100644
@@ -137,7 +137,7 @@ static inline bool rxe_check_pagefault(struct 
 ib_umem_odp *umem_odp,
       while (addr < iova + length) {
           idx = (addr - ib_umem_start(umem_odp)) >> umem_odp->page_shift;
-        if (!(umem_odp->map.pfn_list[idx] & perm)) {
+        if (!(umem_odp->map.pfn_list[idx] & HMM_PFN_VALID)) {
               need_fault = true;
               break;
           }
#5 lore raw
Quoted 16 lines · Zhu Yanjun
Quoted 8 lines · Daisuke Matsuda
Quoted 6 lines · Leon Romanovsky

From: Leon Romanovsky <[email protected]>

RO pages has "perm" equal to 0, that caused to the situation where such pages were marked as needed to have fault and caused to infinite loop.

Quoted 6 lines
Quoted 4 lines
Fixes eedd5b1276e7 ("RDMA/umem: Store ODP access mask information in PFN")
Quoted 8 lines

In the bug report mail, you mentioned
"
After these two patches are merged to the for-next tree, RXE ODP test always hangs:
  RDMA/core: Convert UMEM ODP DMA mapping to caching IOVA and page linkage RDMA/umem: Store ODP access mask information in PFN
"

After this commit is applied, which of the two previous commits is innocent, and which one causes the "stuck issue in uverbs_destroy_ufile_hw"?

The issue caused by "RDMA/umem: Store ODP access mask information in PFN" has been resolved, and after applying "RDMA/core: Convert UMEM ODP DMA mapping to caching IOVA and page linkage", the stuck issue in uverbs_destroy_ufile_hw() emerges.

I have added some details to the bug report. I am going post a fix though I am not sure people like changing hmm.c to fix this one.

Thanks,
Daisuke

Quoted 39 lines

Best Regards,
Yanjun.Zhu

Quoted 34 lines

Thank you!
This change fixes one of the two issues I reported.
The kernel module does not get stuck in rxe_ib_invalidate_range() anymore.

The remaining one is the stuck issue in uverbs_destroy_ufile_hw(). cf. https://lore.kernel.org/all/[email protected]/

The issue occurs with test_odp_async_prefetch_rc_traffic, which is not yet enabled in rxe. It might indicate that the root cause lies in ib_uverbs layer. I will take a closer look anyway.

Thanks,
Daisuke

Quoted 16 lines

---
  drivers/infiniband/sw/rxe/rxe_odp.c | 2 +-

  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/infiniband/sw/rxe/rxe_odp.c +1 -1
index a1416626f61a5..0f67167ddddd1 100644
@@ -137,7 +137,7 @@ static inline bool rxe_check_pagefault(struct ib_umem_odp *umem_odp,
       while (addr < iova + length) {
           idx = (addr - ib_umem_start(umem_odp)) >> umem_odp->page_shift;
-        if (!(umem_odp->map.pfn_list[idx] & perm)) {
+        if (!(umem_odp->map.pfn_list[idx] & HMM_PFN_VALID)) {
               need_fault = true;
               break;
           }
#7 lore raw
In reply to Leon Romanovsky
Quoted 19 lines · Leon Romanovsky

From: Leon Romanovsky <[email protected]>

RO pages has "perm" equal to 0, that caused to the situation where such pages were marked as needed to have fault and caused to infinite loop.

Fixes eedd5b1276e7 ("RDMA/umem: Store ODP access mask information in PFN")
---
  drivers/infiniband/sw/rxe/rxe_odp.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/infiniband/sw/rxe/rxe_odp.c +0 -0
index a1416626f61a5..0f67167ddddd1 100644

drivers/infiniband/sw/rxe/rxe_odp.c static inline bool rxe_check_pagefault(struct ib_umem_odp *umem_odp, · line 140

Quoted 5 lines
drivers/infiniband/sw/rxe/rxe_odp.c +1 -1
@@ -137,7 +137,7 @@ static inline bool rxe_check_pagefault(struct ib_umem_odp *umem_odp,
  	while (addr < iova + length) {
  		idx = (addr - ib_umem_start(umem_odp)) >> umem_odp->page_shift;
 
-		if (!(umem_odp->map.pfn_list[idx] & perm)) {
+		if (!(umem_odp->map.pfn_list[idx] & HMM_PFN_VALID)) {

Because perm is not used, it is not necessary to calculate and pass perm to rxe_check_pagefault. The cleanup is as below:

drivers/infiniband/sw/rxe/rxe_odp.c +1 -1
index 9f6e2bb2a269..f385fccd5988 100644
@@ -125,7 +125,7 @@ int rxe_odp_mr_init_user(struct rxe_dev *rxe, u64 start, u64 length,
 }
 
 static inline bool rxe_check_pagefault(struct ib_umem_odp *umem_odp,
-                                      u64 iova, int length, u32 perm)
+                                      u64 iova, int length)
 {
        bool need_fault = false;
        u64 addr;
@@ -137,7 +137,7 @@ static inline bool rxe_check_pagefault(struct ib_umem_odp *umem_odp,
        while (addr < iova + length) {
                idx = (addr - ib_umem_start(umem_odp)) >> 

umem_odp->page_shift;

- if (!(umem_odp->dma_list[idx] & perm)) {

+               if (!(umem_odp->dma_list[idx] & HMM_PFN_VALID)) {
                        need_fault = true;
                        break;
                }
@@ -151,19 +151,14 @@ static int rxe_odp_map_range_and_lock(struct rxe_mr *mr, u64 iova, int length, u
 {
        struct ib_umem_odp *umem_odp = to_ib_umem_odp(mr->umem);
        bool need_fault;
-       u64 perm;
        int err;

        if (unlikely(length < 1))
                return -EINVAL;

- perm = ODP_READ_ALLOWED_BIT;
- if (!(flags & RXE_PAGEFAULT_RDONLY))
- perm |= ODP_WRITE_ALLOWED_BIT;
-

        mutex_lock(&umem_odp->umem_mutex);

- need_fault = rxe_check_pagefault(umem_odp, iova, length, perm);

+       need_fault = rxe_check_pagefault(umem_odp, iova, length);
        if (need_fault) {
                mutex_unlock(&umem_odp->umem_mutex);

@@ -173,7 +168,7 @@ static int rxe_odp_map_range_and_lock(struct rxe_mr *mr, u64 iova, int length, u

                if (err < 0)
                        return err;

- need_fault = rxe_check_pagefault(umem_odp, iova, length, perm);

+               need_fault = rxe_check_pagefault(umem_odp, iova, length);
                if (need_fault)
                        return -EFAULT;
        }

Zhu Yanjun

Quoted 3 lines
drivers/infiniband/sw/rxe/rxe_odp.c +0 -0
  			need_fault = true;
  			break;
  		}
#8 lore raw
Quoted 15 lines · Zhu Yanjun
Quoted 14 lines · Leon Romanovsky

From: Leon Romanovsky <[email protected]>

RO pages has "perm" equal to 0, that caused to the situation where such pages were marked as needed to have fault and caused to infinite loop.

Fixes eedd5b1276e7 ("RDMA/umem: Store ODP access mask information in PFN")
---
  drivers/infiniband/sw/rxe/rxe_odp.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 12 lines

drivers/infiniband/sw/rxe/rxe_odp.c static inline bool rxe_check_pagefault(struct ib_umem_odp *umem_odp, · line 139

Quoted 9 lines
drivers/infiniband/sw/rxe/rxe_odp.c +1 -1
index a1416626f61a5..0f67167ddddd1 100644
@@ -137,7 +137,7 @@ static inline bool rxe_check_pagefault(struct ib_umem_odp *umem_odp,
  	while (addr < iova + length) {
  		idx = (addr - ib_umem_start(umem_odp)) >> umem_odp->page_shift;
-		if (!(umem_odp->map.pfn_list[idx] & perm)) {
+		if (!(umem_odp->map.pfn_list[idx] & HMM_PFN_VALID)) {

Because perm is not used, it is not necessary to calculate and pass perm to rxe_check_pagefault. The cleanup is as below:

Thanks a lot, I folded this cleanup to the fix.