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

Felix Kuehling felix.kuehling at amd.com
Wed Jul 19 16:55:44 UTC 2023


Am 2023-07-08 um 12:57 schrieb Alex Sierra:
> svm_range_debug_dump should not be called at all when dynamic debug
> is disabled to avoid iterating over SVM lists. This could drop
> performance, specially with big number of SVM ranges.
>
> Signed-off-by: Alex Sierra <alex.sierra at amd.com>
> Signed-off-by: Philip Yang <Philip.Yang at amd.com>
> ---
>   drivers/gpu/drm/amd/amdkfd/kfd_svm.c | 6 ++++--
>   1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_svm.c b/drivers/gpu/drm/amd/amdkfd/kfd_svm.c
> index 479c4f66afa7..4fb427fc5942 100644
> --- a/drivers/gpu/drm/amd/amdkfd/kfd_svm.c
> +++ b/drivers/gpu/drm/amd/amdkfd/kfd_svm.c
> @@ -821,7 +821,7 @@ svm_range_is_same_attrs(struct kfd_process *p, struct svm_range *prange,
>    *
>    * Context: The caller must hold svms->lock
>    */
> -static void svm_range_debug_dump(struct svm_range_list *svms)
> +static int svm_range_debug_dump(struct svm_range_list *svms)
>   {
>   	struct interval_tree_node *node;
>   	struct svm_range *prange;
> @@ -847,6 +847,8 @@ static void svm_range_debug_dump(struct svm_range_list *svms)
>   			 prange->actual_loc);
>   		node = interval_tree_iter_next(node, 0, ~0ULL);
>   	}
> +
> +	return 0;
>   }
>   
>   static int
> @@ -3563,7 +3565,7 @@ svm_range_set_attr(struct kfd_process *p, struct mm_struct *mm,
>   			break;
>   	}
>   
> -	svm_range_debug_dump(svms);
> +	pr_debug("%d", svm_range_debug_dump(svms));

This is a bit hacky. I would use the way dynamic_hex_dump is defined as 
an example for how to do this without the dummy pr_debug and without 
returning a dummy result from svm_range_debug_dump:

#define dynamic_svm_range_dump(svms) \
	_dynamic_func_call_no_desc("svm_range_dump", svm_range_debug_dump, svms)

Then instead of calling svm_range_debug_dump directly, call 
dynamic_svm_range_dump(svms).

Regards,
   Felix


>   
>   	mutex_unlock(&svms->lock);
>   	mmap_read_unlock(mm);


More information about the amd-gfx mailing list