Skip to contentSkip to conversation

drm/ttm: Restore ttm prefaulting

PATCH In review Thomas Hellström (VMware) 3 participants 5 messages Sep 12, 2019 – Sep 13, 2019

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

PATCH 1/1 drm/ttm: Restore ttm prefaulting

From: Thomas Hellstrom <[email protected]>

Commit 4daa4fba3a38 ("gpu: drm: ttm: Adding new return type vm_fault_t") broke TTM prefaulting. Since vmf_insert_mixed() typically always returns VM_FAULT_NOPAGE, prefaulting stops after the second PTE.

Restore (almost) the original behaviour. Unfortunately we can no longer with the new vm_fault_t return type determine whether a prefaulting PTE insertion hit an already populated PTE, and terminate the insertion loop. Instead we continue with the pre-determined number of prefaults.

Fixes 4daa4fba3a38 ("gpu: drm: ttm: Adding new return type vm_fault_t")
Cc Souptick Joarder <[email protected]>
Cc Christian König <[email protected]>
---
 drivers/gpu/drm/ttm/ttm_bo_vm.c | 16 +++++++---------
 1 file changed, 7 insertions(+), 9 deletions(-)
drivers/gpu/drm/ttm/ttm_bo_vm.c +7 -9
index 5a580adeb9d1..aa18e8a53727 100644
@@ -290,15 +290,13 @@ vm_fault_t ttm_bo_vm_fault_reserved(struct vm_fault *vmf,
 		else
 			ret = vmf_insert_pfn(&cvma, address, pfn);
 
-		/*
-		 * Somebody beat us to this PTE or prefaulting to
-		 * an already populated PTE, or prefaulting error.
-		 */
-
-		if (unlikely((ret == VM_FAULT_NOPAGE && i > 0)))
-			break;
-		else if (unlikely(ret & VM_FAULT_ERROR))
-			goto out_io_unlock;
+		/* Never error on prefaulted PTEs */
+		if (unlikely((ret & VM_FAULT_ERROR))) {
+			if (i == 0)
+				goto out_io_unlock;
+			else
+				break;
+		}
 
 		address += PAGE_SIZE;
 		if (unlikely(++page_offset >= page_last))
Signature · 6 lines
2.20.1

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#1 lore raw
Quoted 12 lines · Thomas Hellström (VMware)

From: Thomas Hellstrom <[email protected]>

Commit 4daa4fba3a38 ("gpu: drm: ttm: Adding new return type vm_fault_t") broke TTM prefaulting. Since vmf_insert_mixed() typically always returns VM_FAULT_NOPAGE, prefaulting stops after the second PTE.

Restore (almost) the original behaviour. Unfortunately we can no longer with the new vm_fault_t return type determine whether a prefaulting PTE insertion hit an already populated PTE, and terminate the insertion loop. Instead we continue with the pre-determined number of prefaults.

Quoted 4 lines
Fixes 4daa4fba3a38 ("gpu: drm: ttm: Adding new return type vm_fault_t")
Cc Souptick Joarder <[email protected]>
Cc Christian König <[email protected]>

This commit merged into 4.19. Need to Cc stable.

Cc [email protected] # v4.19+
Quoted 34 lines
---
 drivers/gpu/drm/ttm/ttm_bo_vm.c | 16 +++++++---------
 1 file changed, 7 insertions(+), 9 deletions(-)
drivers/gpu/drm/ttm/ttm_bo_vm.c +7 -10
index 5a580adeb9d1..aa18e8a53727 100644
@@ -290,15 +290,13 @@ vm_fault_t ttm_bo_vm_fault_reserved(struct vm_fault *vmf,
                else
                        ret = vmf_insert_pfn(&cvma, address, pfn);
 
-               /*
-                * Somebody beat us to this PTE or prefaulting to
-                * an already populated PTE, or prefaulting error.
-                */
-
-               if (unlikely((ret == VM_FAULT_NOPAGE && i > 0)))
-                       break;
-               else if (unlikely(ret & VM_FAULT_ERROR))
-                       goto out_io_unlock;
+               /* Never error on prefaulted PTEs */
+               if (unlikely((ret & VM_FAULT_ERROR))) {
+                       if (i == 0)
+                               goto out_io_unlock;
+                       else
+                               break;
+               }
 
                address += PAGE_SIZE;
                if (unlikely(++page_offset >= page_last))
--

2.20.1

Reviewed-by on v1 1/1
#2 lore raw
In reply to Thomas Hellström (VMware)

Am 12.09.19 um 20:38 schrieb Thomas Hellström (VMware):

Quoted 11 lines

From: Thomas Hellstrom <[email protected]>

Commit 4daa4fba3a38 ("gpu: drm: ttm: Adding new return type vm_fault_t") broke TTM prefaulting. Since vmf_insert_mixed() typically always returns VM_FAULT_NOPAGE, prefaulting stops after the second PTE.

Restore (almost) the original behaviour. Unfortunately we can no longer with the new vm_fault_t return type determine whether a prefaulting PTE insertion hit an already populated PTE, and terminate the insertion loop. Instead we continue with the pre-determined number of prefaults.

Quoted 4 lines
Fixes 4daa4fba3a38 ("gpu: drm: ttm: Adding new return type vm_fault_t")
Cc Souptick Joarder <[email protected]>
Cc Christian König <[email protected]>

Going to pick that up when Alex rebases our upstream branch.

Christian.

Quoted 21 lines
---
  drivers/gpu/drm/ttm/ttm_bo_vm.c | 16 +++++++---------
  1 file changed, 7 insertions(+), 9 deletions(-)
drivers/gpu/drm/ttm/ttm_bo_vm.c +0 -9
index 5a580adeb9d1..aa18e8a53727 100644
@@ -290,15 +290,13 @@ vm_fault_t ttm_bo_vm_fault_reserved(struct vm_fault *vmf,
  		else
  			ret = vmf_insert_pfn(&cvma, address, pfn);
 
-		/*
-		 * Somebody beat us to this PTE or prefaulting to
-		 * an already populated PTE, or prefaulting error.
-		 */
-
-		if (unlikely((ret == VM_FAULT_NOPAGE && i > 0)))
-			break;
-		else if (unlikely(ret & VM_FAULT_ERROR))
-			goto out_io_unlock;

drivers/gpu/drm/ttm/ttm_bo_vm.c vm_fault_t ttm_bo_vm_fault_reserved(struct vm_fault *vmf, · line 302

Quoted 10 lines
drivers/gpu/drm/ttm/ttm_bo_vm.c +7 -0
+		/* Never error on prefaulted PTEs */
+		if (unlikely((ret & VM_FAULT_ERROR))) {
+			if (i == 0)
+				goto out_io_unlock;
+			else
+				break;
+		}
 
  		address += PAGE_SIZE;
  		if (unlikely(++page_offset >= page_last))

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

#3 lore raw
Quoted 34 lines · Christian

Am 12.09.19 um 20:38 schrieb Thomas Hellström (VMware):

Quoted 11 lines

From: Thomas Hellstrom <[email protected]>

Commit 4daa4fba3a38 ("gpu: drm: ttm: Adding new return type vm_fault_t") broke TTM prefaulting. Since vmf_insert_mixed() typically always returns VM_FAULT_NOPAGE, prefaulting stops after the second PTE.

Restore (almost) the original behaviour. Unfortunately we can no longer with the new vm_fault_t return type determine whether a prefaulting PTE insertion hit an already populated PTE, and terminate the insertion loop. Instead we continue with the pre-determined number of prefaults.

Quoted 4 lines
Fixes 4daa4fba3a38 ("gpu: drm: ttm: Adding new return type vm_fault_t")
Cc Souptick Joarder <[email protected]>
Cc Christian König <[email protected]>

Going to pick that up when Alex rebases our upstream branch.

Christian.

Quoted 12 lines
---
   drivers/gpu/drm/ttm/ttm_bo_vm.c | 16 +++++++---------
   1 file changed, 7 insertions(+), 9 deletions(-)
drivers/gpu/drm/ttm/ttm_bo_vm.c +0 -0
index 5a580adeb9d1..aa18e8a53727 100644
@@ -290,15 +290,13 @@ vm_fault_t ttm_bo_vm_fault_reserved(struct vm_fault *vmf,
   		else
   			ret = vmf_insert_pfn(&cvma, address, pfn);
 
Quoted 14 lines
Quoted 4 lines
drivers/gpu/drm/ttm/ttm_bo_vm.c +0 -4
-		/*
-		 * Somebody beat us to this PTE or prefaulting to
-		 * an already populated PTE, or prefaulting error.
-		 */

drivers/gpu/drm/ttm/ttm_bo_vm.c vm_fault_t ttm_bo_vm_fault_reserved(struct vm_fault *vmf, · line 297

Quoted 10 lines
drivers/gpu/drm/ttm/ttm_bo_vm.c +5 -5
-
-		if (unlikely((ret == VM_FAULT_NOPAGE && i > 0)))
-			break;
-		else if (unlikely(ret & VM_FAULT_ERROR))
-			goto out_io_unlock;
+		/* Never error on prefaulted PTEs */
+		if (unlikely((ret & VM_FAULT_ERROR))) {
+			if (i == 0)
+				goto out_io_unlock;
+			else

We could perhaps skip that else. Let me know if you want me to respin.

/Thomas

Quoted 5 lines

drivers/gpu/drm/ttm/ttm_bo_vm.c vm_fault_t ttm_bo_vm_fault_reserved(struct vm_fault *vmf, · line 302

Quoted 5 lines
drivers/gpu/drm/ttm/ttm_bo_vm.c +2 -0
+				break;
+		}
 
   		address += PAGE_SIZE;
   		if (unlikely(++page_offset >= page_last))

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

#4 lore raw

Am 13.09.19 um 13:07 schrieb Thomas Hellström (VMware):

Quoted 47 lines · Christian
Quoted 46 lines

Am 12.09.19 um 20:38 schrieb Thomas Hellström (VMware):

Quoted 13 lines

From: Thomas Hellstrom <[email protected]>

Commit 4daa4fba3a38 ("gpu: drm: ttm: Adding new return type vm_fault_t")
broke TTM prefaulting. Since vmf_insert_mixed() typically always returns
VM_FAULT_NOPAGE, prefaulting stops after the second PTE.

Restore (almost) the original behaviour. Unfortunately we can no longer with the new vm_fault_t return type determine whether a prefaulting PTE insertion hit an already populated PTE, and terminate the insertion loop. Instead we continue with the pre-determined number of prefaults.

Quoted 5 lines
Fixes 4daa4fba3a38 ("gpu: drm: ttm: Adding new return type

vm_fault_t")

Cc Souptick Joarder <[email protected]>
Cc Christian König <[email protected]>

Going to pick that up when Alex rebases our upstream branch.

Christian.

Quoted 21 lines

---
   drivers/gpu/drm/ttm/ttm_bo_vm.c | 16 +++++++---------

   1 file changed, 7 insertions(+), 9 deletions(-)
drivers/gpu/drm/ttm/ttm_bo_vm.c +0 -0
index 5a580adeb9d1..aa18e8a53727 100644
@@ -290,15 +290,13 @@ vm_fault_t ttm_bo_vm_fault_reserved(struct 
 vm_fault *vmf,

           else
               ret = vmf_insert_pfn(&cvma, address, pfn); -        /*
-         * Somebody beat us to this PTE or prefaulting to -         * an already populated PTE, or prefaulting error. -         */
-
-        if (unlikely((ret == VM_FAULT_NOPAGE && i > 0))) -            break;
-        else if (unlikely(ret & VM_FAULT_ERROR))

Quoted 8 lines
Quoted 6 lines
Quoted 6 lines

-            goto out_io_unlock;
+        /* Never error on prefaulted PTEs */
+        if (unlikely((ret & VM_FAULT_ERROR))) {
+            if (i == 0)
+                goto out_io_unlock;
+            else

We could perhaps skip that else. Let me know if you want me to respin.

I would rather like to keep it, when something goes wrong we should really stop faulting in more.

Christian.

Quoted 11 lines

/Thomas

Quoted 4 lines
Quoted 4 lines

+                break;
+        }
              address += PAGE_SIZE;
           if (unlikely(++page_offset >= page_last))

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