Skip to contentSkip to conversation

drm/amdgpu: fix huge page handling on Vega10

PATCH In review Christian König 4 participants 7 messages Nov 12, 2018 – Nov 13, 2018 5 messages not in the archive

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

PATCH 1/1 drm/amdgpu: fix huge page handling on Vega10

We accidentially set the huge flag on the parent instead of the childs. This caused some VM faults under memory pressure.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 18 ++++++++++--------
 1 file changed, 10 insertions(+), 8 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +10 -8
index 352b30409060..dad0e2342df9 100644
@@ -1632,13 +1632,6 @@ static int amdgpu_vm_update_ptes(struct amdgpu_pte_update_params *params,
 			continue;
 		}
 
-		/* First check if the entry is already handled */
-		if (cursor.pfn < frag_start) {
-			cursor.entry->huge = true;
-			amdgpu_vm_pt_next(adev, &cursor);
-			continue;
-		}
-
 		/* If it isn't already handled it can't be a huge page */
 		if (cursor.entry->huge) {
 			/* Add the entry to the relocated list to update it. */
@@ -1701,8 +1694,17 @@ static int amdgpu_vm_update_ptes(struct amdgpu_pte_update_params *params,
 			}
 		} while (frag_start < entry_end);
 
-		if (frag >= shift)
+		if (amdgpu_vm_pt_descendant(adev, &cursor)) {
+			/* Mark all child entries as huge */
+			while (cursor.pfn < frag_start) {
+				cursor.entry->huge = true;
+				amdgpu_vm_pt_next(adev, &cursor);
+			}
+
+		} else if (frag >= shift) {
+			/* or just move on to the next on the same level. */
 			amdgpu_vm_pt_next(adev, &cursor);
+		}
 	}
 
 	return 0;
Signature · 6 lines
2.14.1

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): 20181112170942.10674-1-christian.koenig-5C7GfCeVMHo@public.gmane.org

Acked-by
#2 lore raw
Quoted 5 lines · Christian König

We accidentially set the huge flag on the parent instead of the childs. This caused some VM faults under memory pressure.

Quoted 44 lines
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 18 ++++++++++--------
 1 file changed, 10 insertions(+), 8 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +10 -9
index 352b30409060..dad0e2342df9 100644
@@ -1632,13 +1632,6 @@ static int amdgpu_vm_update_ptes(struct amdgpu_pte_update_params *params,
                        continue;
                }
 
-               /* First check if the entry is already handled */
-               if (cursor.pfn < frag_start) {
-                       cursor.entry->huge = true;
-                       amdgpu_vm_pt_next(adev, &cursor);
-                       continue;
-               }
-
                /* If it isn't already handled it can't be a huge page */
                if (cursor.entry->huge) {
                        /* Add the entry to the relocated list to update it. */
@@ -1701,8 +1694,17 @@ static int amdgpu_vm_update_ptes(struct amdgpu_pte_update_params *params,
                        }
                } while (frag_start < entry_end);
 
-               if (frag >= shift)
+               if (amdgpu_vm_pt_descendant(adev, &cursor)) {
+                       /* Mark all child entries as huge */
+                       while (cursor.pfn < frag_start) {
+                               cursor.entry->huge = true;
+                               amdgpu_vm_pt_next(adev, &cursor);
+                       }
+
+               } else if (frag >= shift) {
+                       /* or just move on to the next on the same level. */
                        amdgpu_vm_pt_next(adev, &cursor);
+               }
        }
 
        return 0;
--

2.14.1

Quoted 4 lines

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): CADnq5_MORq4h3zMq_YF+_8HjMyqn61AweLxwYfr+oo4kfkxdfA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org

#4 lore raw
Quoted 7 lines · Alex Deucher
Quoted 5 lines · Christian König

We accidentially set the huge flag on the parent instead of the childs. This caused some VM faults under memory pressure.

Yes, this fixes GPU hangs with F12017 and RoTR with RADV.

Thanks for the fix Christian!

Quoted 47 lines
Quoted 44 lines
---
  drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 18 ++++++++++--------
  1 file changed, 10 insertions(+), 8 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +10 -9
index 352b30409060..dad0e2342df9 100644
@@ -1632,13 +1632,6 @@ static int amdgpu_vm_update_ptes(struct amdgpu_pte_update_params *params,
                         continue;
                 }
 
-               /* First check if the entry is already handled */
-               if (cursor.pfn < frag_start) {
-                       cursor.entry->huge = true;
-                       amdgpu_vm_pt_next(adev, &cursor);
-                       continue;
-               }
-
                 /* If it isn't already handled it can't be a huge page */
                 if (cursor.entry->huge) {
                         /* Add the entry to the relocated list to update it. */
@@ -1701,8 +1694,17 @@ static int amdgpu_vm_update_ptes(struct amdgpu_pte_update_params *params,
                         }
                 } while (frag_start < entry_end);
 
-               if (frag >= shift)
+               if (amdgpu_vm_pt_descendant(adev, &cursor)) {
+                       /* Mark all child entries as huge */
+                       while (cursor.pfn < frag_start) {
+                               cursor.entry->huge = true;
+                               amdgpu_vm_pt_next(adev, &cursor);
+                       }
+
+               } else if (frag >= shift) {
+                       /* or just move on to the next on the same level. */
                         amdgpu_vm_pt_next(adev, &cursor);
+               }
         }
 
         return 0;
--

2.14.1

Quoted 9 lines
Quoted 4 lines

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): f460f333-e31c-2347-4d96-dd04d7416451-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org

#6 lore raw

Am 12.11.18 um 22:45 schrieb Samuel Pitoiset:

Quoted 14 lines · Alex Deucher
Quoted 7 lines
Quoted 5 lines · Christian König

We accidentially set the huge flag on the parent instead of the childs. This caused some VM faults under memory pressure.

Yes, this fixes GPU hangs with F12017 and RoTR with RADV.

Thanks for the fix Christian!

Just FYI I take sentences as this as a "Tested-by: Samuel Pitoiset <[email protected]>".

So if you don't want your mail address to show up in a kernel commit start better say so before Alex pushes it upstream :)

Christian.

Quoted 51 lines
Quoted 51 lines
Quoted 47 lines

---
  drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 18 ++++++++++--------

  1 file changed, 10 insertions(+), 8 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +0 -7
index 352b30409060..dad0e2342df9 100644
@@ -1632,13 +1632,6 @@ static int amdgpu_vm_update_ptes(struct 
 amdgpu_pte_update_params *params,
                          continue;
                  }
 
-               /* First check if the entry is already handled */
-               if (cursor.pfn < frag_start) {
-                       cursor.entry->huge = true;
-                       amdgpu_vm_pt_next(adev, &cursor);
-                       continue;
-               }
-
                  /* If it isn't already handled it can't be a huge page */
                  if (cursor.entry->huge) {

                         /* Add the entry to the relocated list to update it. */

drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +9 -1
@@ -1701,8 +1694,17 @@ static int amdgpu_vm_update_ptes(struct 
 amdgpu_pte_update_params *params,
                          }
                  } while (frag_start < entry_end);
 
-               if (frag >= shift)
+               if (amdgpu_vm_pt_descendant(adev, &cursor)) {
+                       /* Mark all child entries as huge */
+                       while (cursor.pfn < frag_start) {
+                               cursor.entry->huge = true;
+                               amdgpu_vm_pt_next(adev, &cursor);
+                       }
+
+               } else if (frag >= shift) {
+                       /* or just move on to the next on the same 

level. */
                         amdgpu_vm_pt_next(adev, &cursor); +               }
         }

         return 0;

Signature · 1 line
2.14.1
Quoted 9 lines
Quoted 9 lines
Quoted 4 lines

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): 34255c9f-b167-f8bc-7ce9-e1e75123cef4-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org

#8 lore raw
Quoted 12 lines · Christian König

Am 12.11.18 um 22:45 schrieb Samuel Pitoiset:

Quoted 11 lines · Alex Deucher
Quoted 7 lines
Quoted 5 lines · Christian König

We accidentially set the huge flag on the parent instead of the childs. This caused some VM faults under memory pressure.

Quoted 7 lines
Quoted 3 lines

Yes, this fixes GPU hangs with F12017 and RoTR with RADV.

Thanks for the fix Christian!

Just FYI I take sentences as this as a "Tested-by: Samuel Pitoiset <[email protected]>".

So if you don't want your mail address to show up in a kernel commit start better say so before Alex pushes it upstream :)

Feel free to add that tag :)

Quoted 64 lines

Christian.

Quoted 60 lines
Quoted 60 lines
Quoted 43 lines

---
  drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 18 ++++++++++--------

  1 file changed, 10 insertions(+), 8 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +0 -7
index 352b30409060..dad0e2342df9 100644
@@ -1632,13 +1632,6 @@ static int amdgpu_vm_update_ptes(struct 
 amdgpu_pte_update_params *params,
                          continue;
                  }
 
-               /* First check if the entry is already handled */
-               if (cursor.pfn < frag_start) {
-                       cursor.entry->huge = true;
-                       amdgpu_vm_pt_next(adev, &cursor);
-                       continue;
-               }
-
                  /* If it isn't already handled it can't be a huge page */
                  if (cursor.entry->huge) {

                         /* Add the entry to the relocated list to update it. */

drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +9 -1
@@ -1701,8 +1694,17 @@ static int amdgpu_vm_update_ptes(struct 
 amdgpu_pte_update_params *params,
                          }
                  } while (frag_start < entry_end);
 
-               if (frag >= shift)
+               if (amdgpu_vm_pt_descendant(adev, &cursor)) {
+                       /* Mark all child entries as huge */
+                       while (cursor.pfn < frag_start) {
+                               cursor.entry->huge = true;
+                               amdgpu_vm_pt_next(adev, &cursor);
+                       }
+
+               } else if (frag >= shift) {
+                       /* or just move on to the next on the same 

level. */
                         amdgpu_vm_pt_next(adev, &cursor); +               }
         }

Quoted 8 lines

         return 0;

Signature · 6 lines
2.14.1

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

Reviewed-by Felix Kuehling
#9 lore raw
In reply to a message not in the archive
Quoted 2 lines · Christian König

We accidentially set the huge flag on the parent instead of the childs. This caused some VM faults under memory pressure.

I got a bit confused when re-reading this code. Maybe part of it is that cursor.entry is not really an entry (as in PTE), but a page table. cursor.pfn identifies the entry within the table. Maybe renaming cursor.entry to something like cursor.table would make it slightly more intuitive.

Regards,
  Felix

Quoted 33 lines
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 18 ++++++++++--------
 1 file changed, 10 insertions(+), 8 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +4 -8
index 352b30409060..dad0e2342df9 100644
@@ -1632,13 +1632,6 @@ static int amdgpu_vm_update_ptes(struct amdgpu_pte_update_params *params,
 			continue;
 		}
 
-		/* First check if the entry is already handled */
-		if (cursor.pfn < frag_start) {
-			cursor.entry->huge = true;
-			amdgpu_vm_pt_next(adev, &cursor);
-			continue;
-		}
-
 		/* If it isn't already handled it can't be a huge page */
 		if (cursor.entry->huge) {
 			/* Add the entry to the relocated list to update it. */
@@ -1701,8 +1694,17 @@ static int amdgpu_vm_update_ptes(struct amdgpu_pte_update_params *params,
 			}
 		} while (frag_start < entry_end);
 
-		if (frag >= shift)
+		if (amdgpu_vm_pt_descendant(adev, &cursor)) {
+			/* Mark all child entries as huge */
+			while (cursor.pfn < frag_start) {
+				cursor.entry->huge = true;

drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c static int amdgpu_vm_update_ptes(struct amdgpu_pte_update_params *params, · line 1710

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +6 -0
+				amdgpu_vm_pt_next(adev, &cursor);
+			}
+
+		} else if (frag >= shift) {
+			/* or just move on to the next on the same level. */
 			amdgpu_vm_pt_next(adev, &cursor);
+		}
 	}
 
 	return 0;

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): 076d08d0-bdf8-4c59-88aa-0d45383e66cb-5C7GfCeVMHo@public.gmane.org

#11 lore raw

Am 13.11.18 um 00:50 schrieb Kuehling, Felix:

Quoted 10 lines · Christian König
Quoted 2 lines

We accidentially set the huge flag on the parent instead of the childs. This caused some VM faults under memory pressure.

I got a bit confused when re-reading this code. Maybe part of it is that cursor.entry is not really an entry (as in PTE), but a page table. cursor.pfn identifies the entry within the table. Maybe renaming cursor.entry to something like cursor.table would make it slightly more intuitive.

Good point and suggestion how to improve the naming. Going to make that change when I improve things further towards recoverable page faults.

Christian.

Quoted 46 lines

Regards,
  Felix

Quoted 41 lines
---
  drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 18 ++++++++++--------
  1 file changed, 10 insertions(+), 8 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +10 -8
index 352b30409060..dad0e2342df9 100644
@@ -1632,13 +1632,6 @@ static int amdgpu_vm_update_ptes(struct amdgpu_pte_update_params *params,
  			continue;
  		}
 
-		/* First check if the entry is already handled */
-		if (cursor.pfn < frag_start) {
-			cursor.entry->huge = true;
-			amdgpu_vm_pt_next(adev, &cursor);
-			continue;
-		}
-
  		/* If it isn't already handled it can't be a huge page */
  		if (cursor.entry->huge) {
  			/* Add the entry to the relocated list to update it. */
@@ -1701,8 +1694,17 @@ static int amdgpu_vm_update_ptes(struct amdgpu_pte_update_params *params,
  			}
  		} while (frag_start < entry_end);
 
-		if (frag >= shift)
+		if (amdgpu_vm_pt_descendant(adev, &cursor)) {
+			/* Mark all child entries as huge */
+			while (cursor.pfn < frag_start) {
+				cursor.entry->huge = true;
+				amdgpu_vm_pt_next(adev, &cursor);
+			}
+
+		} else if (frag >= shift) {
+			/* or just move on to the next on the same level. */
  			amdgpu_vm_pt_next(adev, &cursor);
+		}
  	}
 
Quoted 1 line

drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c static int amdgpu_vm_update_ptes(struct amdgpu_pte_update_params *params, · line 1710

Quoted 1 line
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +0 -0
  	return 0;

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx