Skip to contentSkip to conversation

drm/amdgpu: fix ocl test performance drop

PATCH In review Flora Cui 4 participants 10 messages May 18, 2017 – May 23, 2017 4 messages not in the archive

Subsystems (2)
lore
Share & tools
lore

Flora Cui

author
#0 lore raw

PATCH 1/1 drm/amdgpu: fix ocl test performance drop

partial revert commit <6971d3d> - drm/amdgpu: cleanup logic in amdgpu_vm_flush

Change-Id Iadce9d613dfe9a739643a74050cea55854832adb
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 14 +++++---------
 1 file changed, 5 insertions(+), 9 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +5 -9
index 88420dc..a96bad6 100644
@@ -743,23 +743,19 @@ int amdgpu_vm_flush(struct amdgpu_ring *ring, struct amdgpu_job *job)
 		id->gws_size != job->gws_size ||
 		id->oa_base != job->oa_base ||
 		id->oa_size != job->oa_size);
-	bool vm_flush_needed = job->vm_needs_flush ||
-		amdgpu_vm_ring_has_compute_vm_bug(ring);
 	unsigned patch_offset = 0;
 	int r;
 
-	if (amdgpu_vm_had_gpu_reset(adev, id)) {
-		gds_switch_needed = true;
-		vm_flush_needed = true;
-	}
-
-	if (!vm_flush_needed && !gds_switch_needed)
+	if (!job->vm_needs_flush && !gds_switch_needed &&
+	    !amdgpu_vm_had_gpu_reset(adev, id) &&
+	    !amdgpu_vm_ring_has_compute_vm_bug(ring))
 		return 0;
 
 	if (ring->funcs->init_cond_exec)
 		patch_offset = amdgpu_ring_init_cond_exec(ring);
 
-	if (ring->funcs->emit_vm_flush && vm_flush_needed) {
+	if (ring->funcs->emit_vm_flush &&
+	    (job->vm_needs_flush || amdgpu_vm_had_gpu_reset(adev, id))) {
 		struct fence *fence;
 
 		trace_amdgpu_vm_flush(ring, job->vm_id, job->vm_pd_addr);
Signature · 6 lines
2.7.4

_______________________________________________
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): 1495093501-13313-1-git-send-email-Flora.Cui-5C7GfCeVMHo@public.gmane.org

#2 lore raw

Am 18.05.2017 um 09:45 schrieb Flora Cui:

Quoted 5 lines

partial revert commit <6971d3d> - drm/amdgpu: cleanup logic in amdgpu_vm_flush

Change-Id Iadce9d613dfe9a739643a74050cea55854832adb

I don't see how the revert should be faster than the original.

Especially that amdgpu_vm_had_gpu_reset() is now called twice sounds like more overhead than necessary.

Please explain further.

Christian.

Quoted 27 lines
---
  drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 14 +++++---------
  1 file changed, 5 insertions(+), 9 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +3 -8
index 88420dc..a96bad6 100644
@@ -743,23 +743,19 @@ int amdgpu_vm_flush(struct amdgpu_ring *ring, struct amdgpu_job *job)
  		id->gws_size != job->gws_size ||
  		id->oa_base != job->oa_base ||
  		id->oa_size != job->oa_size);
-	bool vm_flush_needed = job->vm_needs_flush ||
-		amdgpu_vm_ring_has_compute_vm_bug(ring);
  	unsigned patch_offset = 0;
  	int r;
 
-	if (amdgpu_vm_had_gpu_reset(adev, id)) {
-		gds_switch_needed = true;
-		vm_flush_needed = true;
-	}
-
-	if (!vm_flush_needed && !gds_switch_needed)
+	if (!job->vm_needs_flush && !gds_switch_needed &&
+	    !amdgpu_vm_had_gpu_reset(adev, id) &&
+	    !amdgpu_vm_ring_has_compute_vm_bug(ring))
  		return 0;

drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c int amdgpu_vm_flush(struct amdgpu_ring *ring, struct amdgpu_job *job) · line 761

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +2 -1
 
  	if (ring->funcs->init_cond_exec)
  		patch_offset = amdgpu_ring_init_cond_exec(ring);
 
-	if (ring->funcs->emit_vm_flush && vm_flush_needed) {
+	if (ring->funcs->emit_vm_flush &&
+	    (job->vm_needs_flush || amdgpu_vm_had_gpu_reset(adev, id))) {
  		struct fence *fence;
 
  		trace_amdgpu_vm_flush(ring, job->vm_id, job->vm_pd_addr);

_______________________________________________
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): 4b2d410d-544f-4e72-11ae-8db4a1d797d3-ANTagKRnAhcb1SvskN2V4Q@public.gmane.org

author
#4 lore raw
Quoted 37 lines · Christian König

Am 18.05.2017 um 09:45 schrieb Flora Cui:

Quoted 5 lines

partial revert commit <6971d3d> - drm/amdgpu: cleanup logic in amdgpu_vm_flush

Change-Id Iadce9d613dfe9a739643a74050cea55854832adb

I don't see how the revert should be faster than the original.

Especially that amdgpu_vm_had_gpu_reset() is now called twice sounds like more overhead than necessary.

Please explain further.

Christian.

Quoted 21 lines
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 14 +++++---------
 1 file changed, 5 insertions(+), 9 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +0 -7
index 88420dc..a96bad6 100644
@@ -743,23 +743,19 @@ int amdgpu_vm_flush(struct amdgpu_ring *ring, struct amdgpu_job *job)
 		id->gws_size != job->gws_size ||
 		id->oa_base != job->oa_base ||
 		id->oa_size != job->oa_size);
-	bool vm_flush_needed = job->vm_needs_flush ||
-		amdgpu_vm_ring_has_compute_vm_bug(ring);
 	unsigned patch_offset = 0;
 	int r;
-	if (amdgpu_vm_had_gpu_reset(adev, id)) {
-		gds_switch_needed = true;
-		vm_flush_needed = true;
-	}
-
Quoted 8 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c int amdgpu_vm_flush(struct amdgpu_ring *ring, struct amdgpu_job *job) · line 762

Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +3 -2
-	if (!vm_flush_needed && !gds_switch_needed)
+	if (!job->vm_needs_flush && !gds_switch_needed &&
+	    !amdgpu_vm_had_gpu_reset(adev, id) &&
+	    !amdgpu_vm_ring_has_compute_vm_bug(ring))
 		return 0;
 	if (ring->funcs->init_cond_exec)
 		patch_offset = amdgpu_ring_init_cond_exec(ring);
-	if (ring->funcs->emit_vm_flush && vm_flush_needed) {

[flora]: for compute ring & amdgpu_vm_ring_has_compute_vm_bug(), a vm_flush is inserted. This might cause performance drop.

Quoted 6 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c int amdgpu_vm_flush(struct amdgpu_ring *ring, struct amdgpu_job *job) · line 761

Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +2 -0
+	if (ring->funcs->emit_vm_flush &&
+	    (job->vm_needs_flush || amdgpu_vm_had_gpu_reset(adev, id))) {
 		struct fence *fence;
 		trace_amdgpu_vm_flush(ring, job->vm_id, job->vm_pd_addr);

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

author
#5 lore raw

btw, what's about gfx9 for amdgpu_vm_ring_has_compute_vm_bug()? Is the workaround still needed?

Quoted 54 lines · Flora Cui
Quoted 37 lines · Christian König

Am 18.05.2017 um 09:45 schrieb Flora Cui:

Quoted 5 lines

partial revert commit <6971d3d> - drm/amdgpu: cleanup logic in amdgpu_vm_flush

Change-Id Iadce9d613dfe9a739643a74050cea55854832adb

I don't see how the revert should be faster than the original.

Especially that amdgpu_vm_had_gpu_reset() is now called twice sounds like more overhead than necessary.

Please explain further.

Christian.

Quoted 21 lines
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 14 +++++---------
 1 file changed, 5 insertions(+), 9 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +0 -7
index 88420dc..a96bad6 100644
@@ -743,23 +743,19 @@ int amdgpu_vm_flush(struct amdgpu_ring *ring, struct amdgpu_job *job)
 		id->gws_size != job->gws_size ||
 		id->oa_base != job->oa_base ||
 		id->oa_size != job->oa_size);
-	bool vm_flush_needed = job->vm_needs_flush ||
-		amdgpu_vm_ring_has_compute_vm_bug(ring);
 	unsigned patch_offset = 0;
 	int r;
-	if (amdgpu_vm_had_gpu_reset(adev, id)) {
-		gds_switch_needed = true;
-		vm_flush_needed = true;
-	}
-
Quoted 8 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c int amdgpu_vm_flush(struct amdgpu_ring *ring, struct amdgpu_job *job) · line 762

Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +3 -2
-	if (!vm_flush_needed && !gds_switch_needed)
+	if (!job->vm_needs_flush && !gds_switch_needed &&
+	    !amdgpu_vm_had_gpu_reset(adev, id) &&
+	    !amdgpu_vm_ring_has_compute_vm_bug(ring))
 		return 0;
 	if (ring->funcs->init_cond_exec)
 		patch_offset = amdgpu_ring_init_cond_exec(ring);
-	if (ring->funcs->emit_vm_flush && vm_flush_needed) {

[flora]: for compute ring & amdgpu_vm_ring_has_compute_vm_bug(), a vm_flush is inserted. This might cause performance drop.

Quoted 6 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c int amdgpu_vm_flush(struct amdgpu_ring *ring, struct amdgpu_job *job) · line 761

Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +2 -0
+	if (ring->funcs->emit_vm_flush &&
+	    (job->vm_needs_flush || amdgpu_vm_had_gpu_reset(adev, id))) {
 		struct fence *fence;
 		trace_amdgpu_vm_flush(ring, job->vm_id, job->vm_pd_addr);
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

#6 lore raw

I also realized this problem when I did fix for sched fence, I thought if no issue, just left it as current code, it's more safe.
As Flora point it out, it results in performance drop, then we need to correct it back.
pipeline_sync in vm flush should be inserted only when amdgpu_vm_ring_has_compute_vm_bug() is true, not all time for every vm flush for all engines. The bug has been fixed in mec firmware from version 673 in gfx8.
About gfx9 for amdgpu_vm_ring_has_compute_vm_bug(), current implementation is thinking gfx9 doesn't have compute vm bug by default. Not sure it's in there. If no vm fault related to this bug, then we can think gfx9 has no compute vm bug, I believe firmware team does that based on previous generation, otherwise we need identify every generation, that's crazy.

Regards,
David Zhou

Quoted 56 lines · Flora Cui

btw, what's about gfx9 for amdgpu_vm_ring_has_compute_vm_bug()? Is the workaround still needed?

Quoted 52 lines · Flora Cui
Quoted 36 lines · Christian König

Am 18.05.2017 um 09:45 schrieb Flora Cui:

Quoted 5 lines

partial revert commit <6971d3d> - drm/amdgpu: cleanup logic in amdgpu_vm_flush

Change-Id Iadce9d613dfe9a739643a74050cea55854832adb

I don't see how the revert should be faster than the original.

Especially that amdgpu_vm_had_gpu_reset() is now called twice sounds like more overhead than necessary.

Please explain further.

Christian.

Quoted 21 lines
---
  drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 14 +++++---------
  1 file changed, 5 insertions(+), 9 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +0 -7
index 88420dc..a96bad6 100644
@@ -743,23 +743,19 @@ int amdgpu_vm_flush(struct amdgpu_ring *ring, struct amdgpu_job *job)
  		id->gws_size != job->gws_size ||
  		id->oa_base != job->oa_base ||
  		id->oa_size != job->oa_size);
-	bool vm_flush_needed = job->vm_needs_flush ||
-		amdgpu_vm_ring_has_compute_vm_bug(ring);
  	unsigned patch_offset = 0;
  	int r;
-	if (amdgpu_vm_had_gpu_reset(adev, id)) {
-		gds_switch_needed = true;
-		vm_flush_needed = true;
-	}
-
Quoted 8 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c int amdgpu_vm_flush(struct amdgpu_ring *ring, struct amdgpu_job *job) · line 762

Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +3 -2
-	if (!vm_flush_needed && !gds_switch_needed)
+	if (!job->vm_needs_flush && !gds_switch_needed &&
+	    !amdgpu_vm_had_gpu_reset(adev, id) &&
+	    !amdgpu_vm_ring_has_compute_vm_bug(ring))
  		return 0;
  	if (ring->funcs->init_cond_exec)
  		patch_offset = amdgpu_ring_init_cond_exec(ring);
-	if (ring->funcs->emit_vm_flush && vm_flush_needed) {

[flora]: for compute ring & amdgpu_vm_ring_has_compute_vm_bug(), a vm_flush is inserted. This might cause performance drop.

Quoted 5 lines
Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +2 -0
+	if (ring->funcs->emit_vm_flush &&
+	    (job->vm_needs_flush || amdgpu_vm_had_gpu_reset(adev, id))) {
  		struct fence *fence;
  		trace_amdgpu_vm_flush(ring, job->vm_id, job->vm_pd_addr);
Quoted 8 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): [email protected]

#8 lore raw

I'm pretty sure that bug is fixed in GFX9. So we don't need the check there any more.

Regards,
Christian.

Am 19.05.2017 um 07:16 schrieb zhoucm1:

Quoted 75 lines

I also realized this problem when I did fix for sched fence, I thought if no issue, just left it as current code, it's more safe.
As Flora point it out, it results in performance drop, then we need to correct it back.
pipeline_sync in vm flush should be inserted only when amdgpu_vm_ring_has_compute_vm_bug() is true, not all time for every vm flush for all engines. The bug has been fixed in mec firmware from version 673 in gfx8.
About gfx9 for amdgpu_vm_ring_has_compute_vm_bug(), current implementation is thinking gfx9 doesn't have compute vm bug by default. Not sure it's in there. If no vm fault related to this bug, then we can think gfx9 has no compute vm bug, I believe firmware team does that based on previous generation, otherwise we need identify every generation, that's crazy.

Regards,
David Zhou

Quoted 58 lines · Flora Cui

btw, what's about gfx9 for amdgpu_vm_ring_has_compute_vm_bug()? Is the workaround still needed?

Quoted 54 lines · Flora Cui
Quoted 37 lines · Christian König

Am 18.05.2017 um 09:45 schrieb Flora Cui:

Quoted 5 lines

partial revert commit <6971d3d> - drm/amdgpu: cleanup logic in amdgpu_vm_flush

Change-Id Iadce9d613dfe9a739643a74050cea55854832adb

I don't see how the revert should be faster than the original.

Especially that amdgpu_vm_had_gpu_reset() is now called twice sounds like more overhead than necessary.

Please explain further.

Christian.

Quoted 22 lines
---
  drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 14 +++++---------
  1 file changed, 5 insertions(+), 9 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +0 -7
index 88420dc..a96bad6 100644
@@ -743,23 +743,19 @@ int amdgpu_vm_flush(struct amdgpu_ring 
 *ring, struct amdgpu_job *job)
          id->gws_size != job->gws_size ||
          id->oa_base != job->oa_base ||
          id->oa_size != job->oa_size);
-    bool vm_flush_needed = job->vm_needs_flush ||
-        amdgpu_vm_ring_has_compute_vm_bug(ring);
      unsigned patch_offset = 0;
      int r;
-    if (amdgpu_vm_had_gpu_reset(adev, id)) {
-        gds_switch_needed = true;
-        vm_flush_needed = true;
-    }
-
Quoted 8 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c int amdgpu_vm_flush(struct amdgpu_ring · line 760

Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +3 -2
-    if (!vm_flush_needed && !gds_switch_needed)
+    if (!job->vm_needs_flush && !gds_switch_needed &&
+        !amdgpu_vm_had_gpu_reset(adev, id) &&
+        !amdgpu_vm_ring_has_compute_vm_bug(ring))
          return 0;
      if (ring->funcs->init_cond_exec)
          patch_offset = amdgpu_ring_init_cond_exec(ring);
-    if (ring->funcs->emit_vm_flush && vm_flush_needed) {

[flora]: for compute ring & amdgpu_vm_ring_has_compute_vm_bug(), a vm_flush is inserted. This might cause performance drop.

Quoted 6 lines
Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +2 -0
+    if (ring->funcs->emit_vm_flush &&
+        (job->vm_needs_flush || amdgpu_vm_had_gpu_reset(adev, 
 id))) {
          struct fence *fence;
          trace_amdgpu_vm_flush(ring, job->vm_id, job->vm_pd_addr);
Quoted 8 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

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): 0246394a-ddbb-6478-b36f-8fb7e9213acb-ANTagKRnAhcb1SvskN2V4Q@public.gmane.org

author
#10 lore raw

Could anyone give me a RB?

Quoted 100 lines · Christian König

I'm pretty sure that bug is fixed in GFX9. So we don't need the check there any more.

Regards,
Christian.

Am 19.05.2017 um 07:16 schrieb zhoucm1:

Quoted 91 lines

I also realized this problem when I did fix for sched fence, I thought if no issue, just left it as current code, it's more safe.
As Flora point it out, it results in performance drop, then we need to correct it back.
pipeline_sync in vm flush should be inserted only when amdgpu_vm_ring_has_compute_vm_bug() is true, not all time for every vm flush for all engines. The bug has been fixed in mec firmware from version 673 in gfx8.
About gfx9 for amdgpu_vm_ring_has_compute_vm_bug(), current implementation is thinking gfx9 doesn't have compute vm bug by default. Not sure it's in there. If no vm fault related to this bug, then we can think gfx9 has no compute vm bug, I believe firmware team does that based on previous generation, otherwise we need identify every generation, that's crazy.

Regards,
David Zhou

Quoted 61 lines · Flora Cui

btw, what's about gfx9 for amdgpu_vm_ring_has_compute_vm_bug()? Is the workaround still needed?

Quoted 57 lines · Flora Cui
Quoted 39 lines · Christian König

Am 18.05.2017 um 09:45 schrieb Flora Cui:

Quoted 5 lines

partial revert commit <6971d3d> - drm/amdgpu: cleanup logic in amdgpu_vm_flush

Change-Id Iadce9d613dfe9a739643a74050cea55854832adb

I don't see how the revert should be faster than the original.

Especially that amdgpu_vm_had_gpu_reset() is now called twice sounds like
more overhead than necessary.

Please explain further.

Christian.

Quoted 23 lines
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 14 +++++---------
 1 file changed, 5 insertions(+), 9 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +0 -7
index 88420dc..a96bad6 100644
@@ -743,23 +743,19 @@ int amdgpu_vm_flush(struct amdgpu_ring
 *ring, struct amdgpu_job *job)
         id->gws_size != job->gws_size ||
         id->oa_base != job->oa_base ||
         id->oa_size != job->oa_size);
-    bool vm_flush_needed = job->vm_needs_flush ||
-        amdgpu_vm_ring_has_compute_vm_bug(ring);
     unsigned patch_offset = 0;
     int r;
-    if (amdgpu_vm_had_gpu_reset(adev, id)) {
-        gds_switch_needed = true;
-        vm_flush_needed = true;
-    }
-
Quoted 8 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c int amdgpu_vm_flush(struct amdgpu_ring · line 760

Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +3 -2
-    if (!vm_flush_needed && !gds_switch_needed)
+    if (!job->vm_needs_flush && !gds_switch_needed &&
+        !amdgpu_vm_had_gpu_reset(adev, id) &&
+        !amdgpu_vm_ring_has_compute_vm_bug(ring))
         return 0;
     if (ring->funcs->init_cond_exec)
         patch_offset = amdgpu_ring_init_cond_exec(ring);
-    if (ring->funcs->emit_vm_flush && vm_flush_needed) {

[flora]: for compute ring & amdgpu_vm_ring_has_compute_vm_bug(), a vm_flush is
inserted. This might cause performance drop.

Quoted 6 lines
Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +2 -0
+    if (ring->funcs->emit_vm_flush &&
+        (job->vm_needs_flush || amdgpu_vm_had_gpu_reset(adev,
 id))) {
         struct fence *fence;
         trace_amdgpu_vm_flush(ring, job->vm_id, job->vm_pd_addr);
Quoted 8 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

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

#11 lore raw

See my other comment about simplifying the patch in the other mail:

Quoted 10 lines

[flora]: for compute ring & amdgpu_vm_ring_has_compute_vm_bug(), a vm_flush is inserted. This might cause performance drop.

Ah, I see. We only need the pipeline sync, but not the vm flush.

In this case I suggest to just change the following line in amdgpu_vm_flush():

Review

Quoted 2 lines
(quoted diff) +0 -2
-    bool vm_flush_needed = job->vm_needs_flush ||
-        amdgpu_vm_ring_has_compute_vm_bug(ring);

We can keep it in amdgpu_vm_need_pipeline_sync().

With that done we can easily push it.

Christian.

Am 22.05.2017 um 05:42 schrieb Flora Cui:

Quoted 100 lines

Could anyone give me a RB?

Quoted 97 lines · Christian König

I'm pretty sure that bug is fixed in GFX9. So we don't need the check there any more.

Regards,
Christian.

Am 19.05.2017 um 07:16 schrieb zhoucm1:

Quoted 89 lines

I also realized this problem when I did fix for sched fence, I thought if no issue, just left it as current code, it's more safe.
As Flora point it out, it results in performance drop, then we need to correct it back.
pipeline_sync in vm flush should be inserted only when amdgpu_vm_ring_has_compute_vm_bug() is true, not all time for every vm flush for all engines. The bug has been fixed in mec firmware from version 673 in gfx8.
About gfx9 for amdgpu_vm_ring_has_compute_vm_bug(), current implementation is thinking gfx9 doesn't have compute vm bug by default. Not sure it's in there. If no vm fault related to this bug, then we can think gfx9 has no compute vm bug, I believe firmware team does that based on previous generation, otherwise we need identify every generation, that's crazy.

Regards,
David Zhou

Quoted 60 lines · Flora Cui

btw, what's about gfx9 for amdgpu_vm_ring_has_compute_vm_bug()? Is the workaround still needed?

Quoted 56 lines · Flora Cui
Quoted 39 lines · Christian König

Am 18.05.2017 um 09:45 schrieb Flora Cui:

Quoted 5 lines

partial revert commit <6971d3d> - drm/amdgpu: cleanup logic in amdgpu_vm_flush

Change-Id Iadce9d613dfe9a739643a74050cea55854832adb

I don't see how the revert should be faster than the original.

Especially that amdgpu_vm_had_gpu_reset() is now called twice sounds like
more overhead than necessary.

Please explain further.

Christian.

Quoted 23 lines
---
  drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 14 +++++---------
  1 file changed, 5 insertions(+), 9 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +0 -7
index 88420dc..a96bad6 100644
@@ -743,23 +743,19 @@ int amdgpu_vm_flush(struct amdgpu_ring
 *ring, struct amdgpu_job *job)
          id->gws_size != job->gws_size ||
          id->oa_base != job->oa_base ||
          id->oa_size != job->oa_size);
-    bool vm_flush_needed = job->vm_needs_flush ||
-        amdgpu_vm_ring_has_compute_vm_bug(ring);
      unsigned patch_offset = 0;
      int r;
-    if (amdgpu_vm_had_gpu_reset(adev, id)) {
-        gds_switch_needed = true;
-        vm_flush_needed = true;
-    }
-
Quoted 8 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c int amdgpu_vm_flush(struct amdgpu_ring · line 760

Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +3 -2
-    if (!vm_flush_needed && !gds_switch_needed)
+    if (!job->vm_needs_flush && !gds_switch_needed &&
+        !amdgpu_vm_had_gpu_reset(adev, id) &&
+        !amdgpu_vm_ring_has_compute_vm_bug(ring))
          return 0;
      if (ring->funcs->init_cond_exec)
          patch_offset = amdgpu_ring_init_cond_exec(ring);
-    if (ring->funcs->emit_vm_flush && vm_flush_needed) {

[flora]: for compute ring & amdgpu_vm_ring_has_compute_vm_bug(), a vm_flush is
inserted. This might cause performance drop.

Quoted 5 lines
Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +2 -0
+    if (ring->funcs->emit_vm_flush &&
+        (job->vm_needs_flush || amdgpu_vm_had_gpu_reset(adev,
 id))) {
          struct fence *fence;
          trace_amdgpu_vm_flush(ring, job->vm_id, job->vm_pd_addr);
Quoted 8 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

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

#12 lore raw
In reply to Flora Cui
Quoted 11 lines

-----Original Message-----
From: amd-gfx [mailto:[email protected]] On Behalf Of Flora Cui
Sent: Thursday, May 18, 2017 11:37 PM
To: Christian K�nig
Cc: [email protected]
Subject: Re: [PATCH] drm/amdgpu: fix ocl test performance drop

btw, what's about gfx9 for amdgpu_vm_ring_has_compute_vm_bug()? Is the
workaround still needed?

Gfx9 is not affected by that issue.

Alex

Quoted 62 lines · Flora Cui
Quoted 11 lines · Christian König
Quoted 10 lines

Am 18.05.2017 um 09:45 schrieb Flora Cui:

Quoted 5 lines

partial revert commit <6971d3d> - drm/amdgpu: cleanup logic in amdgpu_vm_flush

Change-Id Iadce9d613dfe9a739643a74050cea55854832adb

I don't see how the revert should be faster than the original.

Especially that amdgpu_vm_had_gpu_reset() is now called twice sounds

like

Quoted 11 lines
Quoted 11 lines

more overhead than necessary.

Please explain further.

Christian.

Review

Quoted 5 lines
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 14 +++++---------
 1 file changed, 5 insertions(+), 9 deletions(-)
(quoted diff) +0 -0

b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c

Quoted 4 lines
Quoted 4 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c int amdgpu_vm_flush(struct amdgpu_ring

Quoted 4 lines

index 88420dc..a96bad6 100644

drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +0 -0
@@ -743,23 +743,19 @@ int amdgpu_vm_flush(struct amdgpu_ring

*ring, struct amdgpu_job *job)

Quoted 13 lines
Quoted 13 lines
Quoted 13 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +0 -8
 		id->gws_size != job->gws_size ||
 		id->oa_base != job->oa_base ||
 		id->oa_size != job->oa_size);
-	bool vm_flush_needed = job->vm_needs_flush ||
-		amdgpu_vm_ring_has_compute_vm_bug(ring);
 	unsigned patch_offset = 0;
 	int r;
-	if (amdgpu_vm_had_gpu_reset(adev, id)) {
-		gds_switch_needed = true;
-		vm_flush_needed = true;
-	}
-
-	if (!vm_flush_needed && !gds_switch_needed)
Quoted 8 lines
Quoted 7 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c int amdgpu_vm_flush(struct amdgpu_ring *ring, struct amdgpu_job *job) · line 762

Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +3 -1
+	if (!job->vm_needs_flush && !gds_switch_needed &&
+	    !amdgpu_vm_had_gpu_reset(adev, id) &&
+	    !amdgpu_vm_ring_has_compute_vm_bug(ring))
 		return 0;
 	if (ring->funcs->init_cond_exec)
 		patch_offset = amdgpu_ring_init_cond_exec(ring);
-	if (ring->funcs->emit_vm_flush && vm_flush_needed) {

[flora]: for compute ring & amdgpu_vm_ring_has_compute_vm_bug(), a

vm_flush is

Quoted 3 lines

inserted. This might cause performance drop.

Quoted 2 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c int amdgpu_vm_flush(struct amdgpu_ring · line 755

Quoted 2 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +2 -0
+	if (ring->funcs->emit_vm_flush &&
+	    (job->vm_needs_flush || amdgpu_vm_had_gpu_reset(adev, id)))

{

Quoted 5 lines
Quoted 2 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c int amdgpu_vm_flush(struct amdgpu_ring · line 757

Quoted 2 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +0 -0
 		struct fence *fence;
 		trace_amdgpu_vm_flush(ring, job->vm_id, job-

vm_pd_addr);

Quoted 2 lines
Quoted 8 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

#13 lore raw
In reply to Flora Cui

Am 19.05.2017 um 04:25 schrieb Flora Cui:

Quoted 39 lines · Christian König
Quoted 38 lines

Am 18.05.2017 um 09:45 schrieb Flora Cui:

Quoted 5 lines

partial revert commit <6971d3d> - drm/amdgpu: cleanup logic in amdgpu_vm_flush

Change-Id Iadce9d613dfe9a739643a74050cea55854832adb

I don't see how the revert should be faster than the original.

Especially that amdgpu_vm_had_gpu_reset() is now called twice sounds like more overhead than necessary.

Please explain further.

Christian.

Quoted 23 lines
---
  drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 14 +++++---------
  1 file changed, 5 insertions(+), 9 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +1 -8
index 88420dc..a96bad6 100644
@@ -743,23 +743,19 @@ int amdgpu_vm_flush(struct amdgpu_ring *ring, struct amdgpu_job *job)
  		id->gws_size != job->gws_size ||
  		id->oa_base != job->oa_base ||
  		id->oa_size != job->oa_size);
-	bool vm_flush_needed = job->vm_needs_flush ||
-		amdgpu_vm_ring_has_compute_vm_bug(ring);
  	unsigned patch_offset = 0;
  	int r;
-	if (amdgpu_vm_had_gpu_reset(adev, id)) {
-		gds_switch_needed = true;
-		vm_flush_needed = true;
-	}
-
-	if (!vm_flush_needed && !gds_switch_needed)
+	if (!job->vm_needs_flush && !gds_switch_needed &&
Quoted 8 lines
Quoted 6 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c int amdgpu_vm_flush(struct amdgpu_ring *ring, struct amdgpu_job *job) · line 762

Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +2 -1
+	    !amdgpu_vm_had_gpu_reset(adev, id) &&
+	    !amdgpu_vm_ring_has_compute_vm_bug(ring))
  		return 0;
  	if (ring->funcs->init_cond_exec)
  		patch_offset = amdgpu_ring_init_cond_exec(ring);
-	if (ring->funcs->emit_vm_flush && vm_flush_needed) {

[flora]: for compute ring & amdgpu_vm_ring_has_compute_vm_bug(), a vm_flush is inserted. This might cause performance drop.

Ah, I see. We only need the pipeline sync, but not the vm flush.

In this case I suggest to just change the following line in amdgpu_vm_flush():

drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c int amdgpu_vm_flush(struct amdgpu_ring *ring, struct amdgpu_job *job) · line 747

Quoted 2 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +0 -2
-	bool vm_flush_needed = job->vm_needs_flush ||
-		amdgpu_vm_ring_has_compute_vm_bug(ring);

We can keep it in amdgpu_vm_need_pipeline_sync().

BTW: We should cache the result of amdgpu_vm_ring_has_compute_vm_bug() in the vm manager structure. Computing this on the fly for every command submissions is just a huge bunch of overhead.

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