Skip to contentSkip to conversation

drm/amdgpu: Fix a NULL pointer of fence

PATCH In review xinhui pan 5 participants 9 messages Jul 7, 2022 – Jul 18, 2022

Subsystems (3)
lore
Share & tools
lore

xinhui pan

author
#0 lore raw

PATCH 1/1 drm/amdgpu: Fix a NULL pointer of fence

Fence is accessed by dma_resv_add_fence() now.
Use amdgpu_amdkfd_remove_eviction_fence instead.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c +2 -2
index 0036c9e405af..1e25c400ce4f 100644
@@ -1558,10 +1558,10 @@ void amdgpu_amdkfd_gpuvm_destroy_cb(struct amdgpu_device *adev,
 
 	if (!process_info)
 		return;
-
 	/* Release eviction fence from PD */
 	amdgpu_bo_reserve(pd, false);
-	amdgpu_bo_fence(pd, NULL, false);
+	amdgpu_amdkfd_remove_eviction_fence(pd,
+					process_info->eviction_fence);
 	amdgpu_bo_unreserve(pd);
 
 	/* Update process info */
Signature · 1 line
2.34.1
#1 lore raw

Am 07.07.22 um 11:50 schrieb xinhui pan:

Quoted 13 lines

Fence is accessed by dma_resv_add_fence() now.
Use amdgpu_amdkfd_remove_eviction_fence instead.

---
  drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c +0 -0
index 0036c9e405af..1e25c400ce4f 100644

drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c void amdgpu_amdkfd_gpuvm_destroy_cb(struct amdgpu_device *adev, · line 1564

Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c +2 -2
@@ -1558,10 +1558,10 @@ void amdgpu_amdkfd_gpuvm_destroy_cb(struct amdgpu_device *adev,
 
  	if (!process_info)
  		return;
-
  	/* Release eviction fence from PD */
  	amdgpu_bo_reserve(pd, false);
-	amdgpu_bo_fence(pd, NULL, false);
+	amdgpu_amdkfd_remove_eviction_fence(pd,
+					process_info->eviction_fence);

Good catch as well, but Felix needs to take a look at this.

Regards,
Christian.

Quoted 3 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c +0 -0
  	amdgpu_bo_unreserve(pd);
 
  	/* Update process info */
maintainer
#2 lore raw

Am 2022-07-07 um 05:54 schrieb Christian König:

Quoted 9 lines

Am 07.07.22 um 11:50 schrieb xinhui pan:

Quoted 8 lines

Fence is accessed by dma_resv_add_fence() now.
Use amdgpu_amdkfd_remove_eviction_fence instead.

---
  drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c | 4 ++--

  1 file changed, 2 insertions(+), 2 deletions(-)
Quoted 16 lines
Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c +0 -0
index 0036c9e405af..1e25c400ce4f 100644

drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c void amdgpu_amdkfd_gpuvm_destroy_cb(struct · line 1564

Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c +2 -2
@@ -1558,10 +1558,10 @@ void amdgpu_amdkfd_gpuvm_destroy_cb(struct 
 amdgpu_device *adev,
         if (!process_info)
           return;
-
       /* Release eviction fence from PD */
       amdgpu_bo_reserve(pd, false);
-    amdgpu_bo_fence(pd, NULL, false);
+    amdgpu_amdkfd_remove_eviction_fence(pd,
+                    process_info->eviction_fence);

Good catch as well, but Felix needs to take a look at this.

This is weird. We used amdgpu_bo_fence(pd, NULL, false) here, which would have removed an exclusive fence. But as far as I can tell we added the fence as a shared fence in init_kfd_vm and amdgpu_amdkfd_gpuvm_restore_process_bos. So this probably never worked as intended.

You could try if this is really needed. Just remove the eviction fence removal. Then enable eviction debugging with

    echo Y > /sys/module/amdgpu/parameters/debug_evictions

Run some simple tests and check the kernel log to see if process termination is causing any unexpected evictions.

Regards,
  Felix

Quoted 7 lines

Regards,
Christian.

Quoted 2 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c +0 -0
       amdgpu_bo_unreserve(pd);
         /* Update process info */
#3 lore raw

[AMD Official Use Only - General]

Felix,
Shared fences depend on exclusive fence, so add a new exclusive fence, say NULL would also remove all shared fences. That works before 5.18 . 😉 From 5.18, adding a new exclusive fence(the write usage fence) did not remove any shared fences(the read usage fence). So that is broken.

And I also try the debug_evictions parameter. No unexpected eviction shows anyway.
I did a quick check and found amdgpu implement BO release notify and it will remove kfd ef on pt/pd BO. So we don’t need this duplicated ef removal. The interesting thing is that is done by patch f4a3c42b5c52("drm/amdgpu: Remove kfd eviction fence before release bo (v2)") which is from me 😉 I totally forgot it.

So I would make a new patch to remove this duplicated ef removal.

-----Original Message-----
From: Kuehling, Felix <[email protected]>
Sent: Thursday, July 7, 2022 11:47 PM
To: Christian König <[email protected]>; Pan, Xinhui <[email protected]>; [email protected]
Cc: Deucher, Alexander <[email protected]>; Koenig, Christian <[email protected]>
Subject: Re: [PATCH] drm/amdgpu: Fix a NULL pointer of fence

Am 2022-07-07 um 05:54 schrieb Christian König:

Quoted 18 lines

Am 07.07.22 um 11:50 schrieb xinhui pan:

Quoted 17 lines

Fence is accessed by dma_resv_add_fence() now.
Use amdgpu_amdkfd_remove_eviction_fence instead.

---
  drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c +0 -0
index 0036c9e405af..1e25c400ce4f 100644
@@ -1558,10 +1558,10 @@ void amdgpu_amdkfd_gpuvm_destroy_cb(struct
 amdgpu_device *adev,
        if (!process_info)
          return;
Quoted 8 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c void amdgpu_amdkfd_gpuvm_destroy_cb(struct amdgpu_device *adev, · line 1564

Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c +2 -2
-
      /* Release eviction fence from PD */
      amdgpu_bo_reserve(pd, false);
-    amdgpu_bo_fence(pd, NULL, false);
+    amdgpu_amdkfd_remove_eviction_fence(pd,
+                    process_info->eviction_fence);

Good catch as well, but Felix needs to take a look at this.

This is weird. We used amdgpu_bo_fence(pd, NULL, false) here, which would have removed an exclusive fence. But as far as I can tell we added the fence as a shared fence in init_kfd_vm and amdgpu_amdkfd_gpuvm_restore_process_bos. So this probably never worked as intended.

You could try if this is really needed. Just remove the eviction fence removal. Then enable eviction debugging with

echo Y > /sys/module/amdgpu/parameters/debug_evictions

Run some simple tests and check the kernel log to see if process termination is causing any unexpected evictions.

Regards,
Felix

Quoted 7 lines

Regards,
Christian.

Quoted 2 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c +0 -0
      amdgpu_bo_unreserve(pd);
        /* Update process info */
#4 lore raw

Hi guys,

well the practice to remove all fences by adding a NULL exclusive fence was pretty much illegal in the first place because this also removes kernel internal fences which can lead to freeing up memory which is still accessed.

I've just didn't noticed that this was used by the KFD code as well otherwise I would have pushed to clean that up much earlier.

Regards,
Christian.

Am 08.07.22 um 03:08 schrieb Pan, Xinhui:

Quoted 61 lines

[AMD Official Use Only - General]

Felix,
Shared fences depend on exclusive fence, so add a new exclusive fence, say NULL would also remove all shared fences. That works before 5.18 . 😉
From 5.18, adding a new exclusive fence(the write usage fence) did not remove any shared fences(the read usage fence). So that is broken.

And I also try the debug_evictions parameter. No unexpected eviction shows anyway.
I did a quick check and found amdgpu implement BO release notify and it will remove kfd ef on pt/pd BO. So we don’t need this duplicated ef removal. The interesting thing is that is done by patch f4a3c42b5c52("drm/amdgpu: Remove kfd eviction fence before release bo (v2)") which is from me 😉 I totally forgot it.

So I would make a new patch to remove this duplicated ef removal.

-----Original Message-----
From: Kuehling, Felix <[email protected]>
Sent: Thursday, July 7, 2022 11:47 PM
To: Christian König <[email protected]>; Pan, Xinhui <[email protected]>; [email protected]
Cc: Deucher, Alexander <[email protected]>; Koenig, Christian <[email protected]>
Subject: Re: [PATCH] drm/amdgpu: Fix a NULL pointer of fence

Am 2022-07-07 um 05:54 schrieb Christian König:

Quoted 9 lines

Am 07.07.22 um 11:50 schrieb xinhui pan:

Quoted 8 lines

Fence is accessed by dma_resv_add_fence() now.
Use amdgpu_amdkfd_remove_eviction_fence instead.

---
   drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c | 4 ++--
   1 file changed, 2 insertions(+), 2 deletions(-)
Quoted 16 lines
Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c +0 -0
index 0036c9e405af..1e25c400ce4f 100644

drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c void amdgpu_amdkfd_gpuvm_destroy_cb(struct · line 1564

Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c +2 -2
@@ -1558,10 +1558,10 @@ void amdgpu_amdkfd_gpuvm_destroy_cb(struct
 amdgpu_device *adev,
         if (!process_info)
           return;
-
       /* Release eviction fence from PD */
       amdgpu_bo_reserve(pd, false);
-    amdgpu_bo_fence(pd, NULL, false);
+    amdgpu_amdkfd_remove_eviction_fence(pd,
+                    process_info->eviction_fence);

Good catch as well, but Felix needs to take a look at this.

This is weird. We used amdgpu_bo_fence(pd, NULL, false) here, which would have removed an exclusive fence. But as far as I can tell we added the fence as a shared fence in init_kfd_vm and amdgpu_amdkfd_gpuvm_restore_process_bos. So this probably never worked as intended.

You could try if this is really needed. Just remove the eviction fence removal. Then enable eviction debugging with

echo Y > /sys/module/amdgpu/parameters/debug_evictions

Run some simple tests and check the kernel log to see if process termination is causing any unexpected evictions.

Regards,
Felix

Quoted 5 lines

Regards,
Christian.

Quoted 2 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c +0 -0
       amdgpu_bo_unreserve(pd);
         /* Update process info */
#5 lore raw

Is this likely to land before 5.19 final? It's been nearly 2 weeks since I said if fixed an issue I was seeing
https://gitlab.freedesktop.org/drm/amd/-/issues/2074

Quoted 77 lines · Christian König

Hi guys,

well the practice to remove all fences by adding a NULL exclusive fence was pretty much illegal in the first place because this also removes kernel internal fences which can lead to freeing up memory which is still accessed.

I've just didn't noticed that this was used by the KFD code as well otherwise I would have pushed to clean that up much earlier.

Regards,
Christian.

Am 08.07.22 um 03:08 schrieb Pan, Xinhui:

Quoted 61 lines

[AMD Official Use Only - General]

Felix,
Shared fences depend on exclusive fence, so add a new exclusive fence, say NULL would also remove all shared fences. That works before 5.18 . 😉
From 5.18, adding a new exclusive fence(the write usage fence) did not remove any shared fences(the read usage fence). So that is broken.

And I also try the debug_evictions parameter. No unexpected eviction shows anyway.
I did a quick check and found amdgpu implement BO release notify and it will remove kfd ef on pt/pd BO. So we don’t need this duplicated ef removal. The interesting thing is that is done by patch f4a3c42b5c52("drm/amdgpu: Remove kfd eviction fence before release bo (v2)") which is from me 😉 I totally forgot it.

So I would make a new patch to remove this duplicated ef removal.

-----Original Message-----
From: Kuehling, Felix <[email protected]>
Sent: Thursday, July 7, 2022 11:47 PM
To: Christian König <[email protected]>; Pan, Xinhui <[email protected]>; [email protected]
Cc: Deucher, Alexander <[email protected]>; Koenig, Christian <[email protected]>
Subject: Re: [PATCH] drm/amdgpu: Fix a NULL pointer of fence

Am 2022-07-07 um 05:54 schrieb Christian König:

Quoted 9 lines

Am 07.07.22 um 11:50 schrieb xinhui pan:

Quoted 8 lines

Fence is accessed by dma_resv_add_fence() now.
Use amdgpu_amdkfd_remove_eviction_fence instead.

---
   drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c | 4 ++--
   1 file changed, 2 insertions(+), 2 deletions(-)
Quoted 16 lines
Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c +0 -0
index 0036c9e405af..1e25c400ce4f 100644

drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c void amdgpu_amdkfd_gpuvm_destroy_cb(struct · line 1564

Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c +2 -2
@@ -1558,10 +1558,10 @@ void amdgpu_amdkfd_gpuvm_destroy_cb(struct
 amdgpu_device *adev,
         if (!process_info)
           return;
-
       /* Release eviction fence from PD */
       amdgpu_bo_reserve(pd, false);
-    amdgpu_bo_fence(pd, NULL, false);
+    amdgpu_amdkfd_remove_eviction_fence(pd,
+                    process_info->eviction_fence);

Good catch as well, but Felix needs to take a look at this.

This is weird. We used amdgpu_bo_fence(pd, NULL, false) here, which would have removed an exclusive fence. But as far as I can tell we added the fence as a shared fence in init_kfd_vm and amdgpu_amdkfd_gpuvm_restore_process_bos. So this probably never worked as intended.

You could try if this is really needed. Just remove the eviction fence removal. Then enable eviction debugging with

echo Y > /sys/module/amdgpu/parameters/debug_evictions

Run some simple tests and check the kernel log to see if process termination is causing any unexpected evictions.

Regards,
Felix

Quoted 5 lines

Regards,
Christian.

Quoted 2 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c +0 -0
       amdgpu_bo_unreserve(pd);
         /* Update process info */
maintainer
#6 lore raw

Xinhui submitted this patch instead, which should address the same issue: "drm/amdgpu: Remove one duplicated ef removal"

Alex, can you pick up that patch for drm-fixes for 5.19, if it's not too late?

Thanks,
  Felix

Quoted 81 lines · Mike Lothian

Is this likely to land before 5.19 final? It's been nearly 2 weeks since I said if fixed an issue I was seeing
https://gitlab.freedesktop.org/drm/amd/-/issues/2074

Quoted 75 lines · Christian König

Hi guys,

well the practice to remove all fences by adding a NULL exclusive fence was pretty much illegal in the first place because this also removes kernel internal fences which can lead to freeing up memory which is still accessed.

I've just didn't noticed that this was used by the KFD code as well otherwise I would have pushed to clean that up much earlier.

Regards,
Christian.

Am 08.07.22 um 03:08 schrieb Pan, Xinhui:

Quoted 61 lines

[AMD Official Use Only - General]

Felix,
Shared fences depend on exclusive fence, so add a new exclusive fence, say NULL would also remove all shared fences. That works before 5.18 . 😉
From 5.18, adding a new exclusive fence(the write usage fence) did not remove any shared fences(the read usage fence). So that is broken.

And I also try the debug_evictions parameter. No unexpected eviction shows anyway.
I did a quick check and found amdgpu implement BO release notify and it will remove kfd ef on pt/pd BO. So we don’t need this duplicated ef removal. The interesting thing is that is done by patch f4a3c42b5c52("drm/amdgpu: Remove kfd eviction fence before release bo (v2)") which is from me 😉 I totally forgot it.

So I would make a new patch to remove this duplicated ef removal.

-----Original Message-----
From: Kuehling, Felix <[email protected]>
Sent: Thursday, July 7, 2022 11:47 PM
To: Christian König <[email protected]>; Pan, Xinhui <[email protected]>; [email protected]
Cc: Deucher, Alexander <[email protected]>; Koenig, Christian <[email protected]>
Subject: Re: [PATCH] drm/amdgpu: Fix a NULL pointer of fence

Am 2022-07-07 um 05:54 schrieb Christian König:

Quoted 9 lines

Am 07.07.22 um 11:50 schrieb xinhui pan:

Quoted 8 lines

Fence is accessed by dma_resv_add_fence() now.
Use amdgpu_amdkfd_remove_eviction_fence instead.

---
    drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c | 4 ++--
    1 file changed, 2 insertions(+), 2 deletions(-)
Quoted 16 lines
Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c +0 -0
index 0036c9e405af..1e25c400ce4f 100644

drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c void amdgpu_amdkfd_gpuvm_destroy_cb(struct · line 1564

Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c +2 -2
@@ -1558,10 +1558,10 @@ void amdgpu_amdkfd_gpuvm_destroy_cb(struct
 amdgpu_device *adev,
          if (!process_info)
            return;
-
        /* Release eviction fence from PD */
        amdgpu_bo_reserve(pd, false);
-    amdgpu_bo_fence(pd, NULL, false);
+    amdgpu_amdkfd_remove_eviction_fence(pd,
+                    process_info->eviction_fence);

Good catch as well, but Felix needs to take a look at this.

This is weird. We used amdgpu_bo_fence(pd, NULL, false) here, which would have removed an exclusive fence. But as far as I can tell we added the fence as a shared fence in init_kfd_vm and amdgpu_amdkfd_gpuvm_restore_process_bos. So this probably never worked as intended.

You could try if this is really needed. Just remove the eviction fence removal. Then enable eviction debugging with

echo Y > /sys/module/amdgpu/parameters/debug_evictions

Run some simple tests and check the kernel log to see if process termination is causing any unexpected evictions.

Regards,
Felix

Quoted 5 lines

Regards,
Christian.

Quoted 2 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c +0 -0
        amdgpu_bo_unreserve(pd);
          /* Update process info */
#7 lore raw

[Public]

Will do.

Alex

________________________________
From: Kuehling, Felix <[email protected]>
Sent: Monday, July 18, 2022 11:29 AM
To: Mike Lothian <[email protected]>; Christian König <[email protected]>
Cc: Pan, Xinhui <[email protected]>; [email protected] <[email protected]>; Deucher, Alexander <[email protected]>; Koenig, Christian <[email protected]>
Subject: Re: [PATCH] drm/amdgpu: Fix a NULL pointer of fence

Xinhui submitted this patch instead, which should address the same
issue: "drm/amdgpu: Remove one duplicated ef removal"

Alex, can you pick up that patch for drm-fixes for 5.19, if it's not too late?

Thanks,
Felix

Quoted 81 lines · Mike Lothian

Is this likely to land before 5.19 final? It's been nearly 2 weeks since I said if fixed an issue I was seeing
https://gitlab.freedesktop.org/drm/amd/-/issues/2074

Quoted 75 lines · Christian König

Hi guys,

well the practice to remove all fences by adding a NULL exclusive fence was pretty much illegal in the first place because this also removes kernel internal fences which can lead to freeing up memory which is still accessed.

I've just didn't noticed that this was used by the KFD code as well otherwise I would have pushed to clean that up much earlier.

Regards,
Christian.

Am 08.07.22 um 03:08 schrieb Pan, Xinhui:

Quoted 61 lines

[AMD Official Use Only - General]

Felix,
Shared fences depend on exclusive fence, so add a new exclusive fence, say NULL would also remove all shared fences. That works before 5.18 . 😉
From 5.18, adding a new exclusive fence(the write usage fence) did not remove any shared fences(the read usage fence). So that is broken.

And I also try the debug_evictions parameter. No unexpected eviction shows anyway.
I did a quick check and found amdgpu implement BO release notify and it will remove kfd ef on pt/pd BO. So we don’t need this duplicated ef removal. The interesting thing is that is done by patch f4a3c42b5c52("drm/amdgpu: Remove kfd eviction fence before release bo (v2)") which is from me 😉 I totally forgot it.

So I would make a new patch to remove this duplicated ef removal.

-----Original Message-----
From: Kuehling, Felix <[email protected]>
Sent: Thursday, July 7, 2022 11:47 PM
To: Christian König <[email protected]>; Pan, Xinhui <[email protected]>; [email protected]
Cc: Deucher, Alexander <[email protected]>; Koenig, Christian <[email protected]>
Subject: Re: [PATCH] drm/amdgpu: Fix a NULL pointer of fence

Am 2022-07-07 um 05:54 schrieb Christian König:

Quoted 9 lines

Am 07.07.22 um 11:50 schrieb xinhui pan:

Quoted 8 lines

Fence is accessed by dma_resv_add_fence() now.
Use amdgpu_amdkfd_remove_eviction_fence instead.

---
    drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c | 4 ++--
    1 file changed, 2 insertions(+), 2 deletions(-)
Quoted 16 lines
Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c +0 -0
index 0036c9e405af..1e25c400ce4f 100644

drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c void amdgpu_amdkfd_gpuvm_destroy_cb(struct · line 1564

Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c +2 -2
@@ -1558,10 +1558,10 @@ void amdgpu_amdkfd_gpuvm_destroy_cb(struct
 amdgpu_device *adev,
          if (!process_info)
            return;
-
        /* Release eviction fence from PD */
        amdgpu_bo_reserve(pd, false);
-    amdgpu_bo_fence(pd, NULL, false);
+    amdgpu_amdkfd_remove_eviction_fence(pd,
+                    process_info->eviction_fence);

Good catch as well, but Felix needs to take a look at this.

This is weird. We used amdgpu_bo_fence(pd, NULL, false) here, which would have removed an exclusive fence. But as far as I can tell we added the fence as a shared fence in init_kfd_vm and amdgpu_amdkfd_gpuvm_restore_process_bos. So this probably never worked as intended.

You could try if this is really needed. Just remove the eviction fence removal. Then enable eviction debugging with

echo Y > /sys/module/amdgpu/parameters/debug_evictions

Run some simple tests and check the kernel log to see if process termination is causing any unexpected evictions.

Regards,
Felix

Quoted 5 lines

Regards,
Christian.

Quoted 2 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c +0 -0
        amdgpu_bo_unreserve(pd);
          /* Update process info */
#8 lore raw
In reply to xinhui pan

Hi

This appears to fix https://gitlab.freedesktop.org/drm/amd/-/issues/2074

Feel free to add my tested by

Thanks

Mike

Quoted 29 lines · xinhui pan

Fence is accessed by dma_resv_add_fence() now.
Use amdgpu_amdkfd_remove_eviction_fence instead.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c +2 -3
index 0036c9e405af..1e25c400ce4f 100644
@@ -1558,10 +1558,10 @@ void amdgpu_amdkfd_gpuvm_destroy_cb(struct amdgpu_device *adev,
 
        if (!process_info)
                return;
-
        /* Release eviction fence from PD */
        amdgpu_bo_reserve(pd, false);
-       amdgpu_bo_fence(pd, NULL, false);
+       amdgpu_amdkfd_remove_eviction_fence(pd,
+                                       process_info->eviction_fence);
        amdgpu_bo_unreserve(pd);
 
        /* Update process info */
--

2.34.1