Skip to contentSkip to conversation

drm/amdkfd: avoid svm dump when dynamic debug disabled

PATCH In review Alex Sierra 3 participants 6 messages Jul 19, 2023 – Aug 11, 2023

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

PATCH 1/1 drm/amdkfd: avoid svm dump when dynamic debug disabled

Set dynamic_svm_range_dump macro to avoid iterating over SVM lists from svm_range_debug_dump when dynamic debug is disabled. Otherwise, it could drop performance, specially with big number of SVM ranges. Make sure both svm_range_set_attr and svm_range_debug_dump functions are dynamically enabled to print svm_range_debug_dump debug traces.

---
 drivers/gpu/drm/amd/amdkfd/kfd_svm.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdkfd/kfd_svm.c +3 -1
index 479c4f66afa7..1b50eae051a4 100644
@@ -46,6 +46,8 @@
  * page table is updated.
  */
 #define AMDGPU_SVM_RANGE_RETRY_FAULT_PENDING	(2UL * NSEC_PER_MSEC)
+#define dynamic_svm_range_dump(svms) \
+	_dynamic_func_call_no_desc("svm_range_dump", svm_range_debug_dump, svms)
 
 /* Giant svm range split into smaller ranges based on this, it is decided using
  * minimum of all dGPU/APU 1/32 VRAM size, between 2MB to 1GB and alignment to
@@ -3563,7 +3565,7 @@ svm_range_set_attr(struct kfd_process *p, struct mm_struct *mm,
 			break;
 	}
 
-	svm_range_debug_dump(svms);
+	dynamic_svm_range_dump(svms);
 
 	mutex_unlock(&svms->lock);
 	mmap_read_unlock(mm);
Signature · 1 line
2.32.0
maintainer Reviewed-by on v1 1/1
#1 lore raw

Am 2023-07-19 um 17:22 schrieb Alex Sierra:

Quoted 10 lines

Set dynamic_svm_range_dump macro to avoid iterating over SVM lists from svm_range_debug_dump when dynamic debug is disabled. Otherwise, it could drop performance, specially with big number of SVM ranges. Make sure both svm_range_set_attr and svm_range_debug_dump functions are dynamically enabled to print svm_range_debug_dump debug traces.

I don't think my name on a Signed-off-by is appropriate here. I didn't write the patch. And I'm not submitting it. However, the patch is

Quoted 26 lines
---
  drivers/gpu/drm/amd/amdkfd/kfd_svm.c | 4 +++-
  1 file changed, 3 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdkfd/kfd_svm.c +3 -1
index 479c4f66afa7..1b50eae051a4 100644
@@ -46,6 +46,8 @@
   * page table is updated.
   */
  #define AMDGPU_SVM_RANGE_RETRY_FAULT_PENDING	(2UL * NSEC_PER_MSEC)
+#define dynamic_svm_range_dump(svms) \
+	_dynamic_func_call_no_desc("svm_range_dump", svm_range_debug_dump, svms)
 
  /* Giant svm range split into smaller ranges based on this, it is decided using
   * minimum of all dGPU/APU 1/32 VRAM size, between 2MB to 1GB and alignment to
@@ -3563,7 +3565,7 @@ svm_range_set_attr(struct kfd_process *p, struct mm_struct *mm,
  			break;
  	}
 
-	svm_range_debug_dump(svms);
+	dynamic_svm_range_dump(svms);
 
  	mutex_unlock(&svms->lock);
  	mmap_read_unlock(mm);
#2 lore raw

Hi

I'm seeing a compiler failure with Clang 16

CC drivers/gpu/drm/amd/amdgpu/../amdkfd/kfd_svm.o
drivers/gpu/drm/amd/amdgpu/../amdkfd/kfd_svm.c:3568:2: error: call to undeclared function '_dynamic_func_call_no_desc'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]

       dynamic_svm_range_dump(svms);
       ^

drivers/gpu/drm/amd/amdgpu/../amdkfd/kfd_svm.c:50:2: note: expanded from macro 'dynamic_svm_range_dump'
_dynamic_func_call_no_desc("svm_range_dump", svm_range_debug_dump, svms) ^
1 error generated.

Cheers

Mike

Quoted 45 lines · Felix Kuehling

Am 2023-07-19 um 17:22 schrieb Alex Sierra:

Quoted 10 lines

Set dynamic_svm_range_dump macro to avoid iterating over SVM lists from svm_range_debug_dump when dynamic debug is disabled. Otherwise, it could drop performance, specially with big number of SVM ranges. Make sure both svm_range_set_attr and svm_range_debug_dump functions are dynamically enabled to print svm_range_debug_dump debug traces.

I don't think my name on a Signed-off-by is appropriate here. I didn't write the patch. And I'm not submitting it. However, the patch is

Quoted 26 lines
---
  drivers/gpu/drm/amd/amdkfd/kfd_svm.c | 4 +++-
  1 file changed, 3 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdkfd/kfd_svm.c +3 -1
index 479c4f66afa7..1b50eae051a4 100644
@@ -46,6 +46,8 @@
   * page table is updated.
   */
  #define AMDGPU_SVM_RANGE_RETRY_FAULT_PENDING        (2UL * NSEC_PER_MSEC)
+#define dynamic_svm_range_dump(svms) \
+     _dynamic_func_call_no_desc("svm_range_dump", svm_range_debug_dump, svms)
 
  /* Giant svm range split into smaller ranges based on this, it is decided using
   * minimum of all dGPU/APU 1/32 VRAM size, between 2MB to 1GB and alignment to
@@ -3563,7 +3565,7 @@ svm_range_set_attr(struct kfd_process *p, struct mm_struct *mm,
                      break;
      }
 
-     svm_range_debug_dump(svms);
+     dynamic_svm_range_dump(svms);
 
      mutex_unlock(&svms->lock);
      mmap_read_unlock(mm);
maintainer
#3 lore raw

Is your kernel configured without dynamic debugging? Maybe we need to wrap this in some #if defined(CONFIG_DYNAMIC_DEBUG_CORE).

Regards,
  Felix

Am 2023-08-03 um 15:38 schrieb Mike Lothian:

Quoted 65 lines

Hi

I'm seeing a compiler failure with Clang 16

CC drivers/gpu/drm/amd/amdgpu/../amdkfd/kfd_svm.o
drivers/gpu/drm/amd/amdgpu/../amdkfd/kfd_svm.c:3568:2: error: call to undeclared function '_dynamic_func_call_no_desc'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]

        dynamic_svm_range_dump(svms);
        ^

drivers/gpu/drm/amd/amdgpu/../amdkfd/kfd_svm.c:50:2: note: expanded from macro 'dynamic_svm_range_dump'
_dynamic_func_call_no_desc("svm_range_dump", svm_range_debug_dump, svms) ^
1 error generated.

Cheers

Mike

Quoted 43 lines · Felix Kuehling

Am 2023-07-19 um 17:22 schrieb Alex Sierra:

Quoted 10 lines

Set dynamic_svm_range_dump macro to avoid iterating over SVM lists from svm_range_debug_dump when dynamic debug is disabled. Otherwise, it could drop performance, specially with big number of SVM ranges. Make sure both svm_range_set_attr and svm_range_debug_dump functions are dynamically enabled to print svm_range_debug_dump debug traces.

I don't think my name on a Signed-off-by is appropriate here. I didn't write the patch. And I'm not submitting it. However, the patch is

Quoted 26 lines
---
   drivers/gpu/drm/amd/amdkfd/kfd_svm.c | 4 +++-
   1 file changed, 3 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdkfd/kfd_svm.c +3 -1
index 479c4f66afa7..1b50eae051a4 100644
@@ -46,6 +46,8 @@
    * page table is updated.
    */
   #define AMDGPU_SVM_RANGE_RETRY_FAULT_PENDING        (2UL * NSEC_PER_MSEC)
+#define dynamic_svm_range_dump(svms) \
+     _dynamic_func_call_no_desc("svm_range_dump", svm_range_debug_dump, svms)
 
   /* Giant svm range split into smaller ranges based on this, it is decided using
    * minimum of all dGPU/APU 1/32 VRAM size, between 2MB to 1GB and alignment to
@@ -3563,7 +3565,7 @@ svm_range_set_attr(struct kfd_process *p, struct mm_struct *mm,
                       break;
       }
 
-     svm_range_debug_dump(svms);
+     dynamic_svm_range_dump(svms);
 
       mutex_unlock(&svms->lock);
       mmap_read_unlock(mm);
#4 lore raw
Quoted 4 lines · Felix Kuehling

Is your kernel configured without dynamic debugging? Maybe we need to wrap this in some #if defined(CONFIG_DYNAMIC_DEBUG_CORE).

Apologies, I thought I'd replied to this, yes I didn't have dynamic debugging enabled

maintainer
#5 lore raw

Am 2023-08-11 um 06:11 schrieb Mike Lothian:

Quoted 6 lines · Felix Kuehling
Quoted 3 lines

Is your kernel configured without dynamic debugging? Maybe we need to wrap this in some #if defined(CONFIG_DYNAMIC_DEBUG_CORE).

Apologies, I thought I'd replied to this, yes I didn't have dynamic debugging enabled

I submitted a fix for this by Arnd Bergman: https://patchwork.freedesktop.org/patch/551367/. It should show up in Alex's public branch soon.

Regards,
  Felix