AMD-GFX Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: "Christian König" <christian.koenig@amd.com>
To: Sunil Khatri <sunil.khatri@amd.com>,
	Felix Kuehling <felix.kuehling@amd.com>,
	Alex Deucher <alexander.deucher@amd.com>,
	Philip Yang <Philip.Yang@amd.com>,
	amd-gfx@lists.freedesktop.org
Subject: Re: [Patch v2 1/2] drm/amdkfd: clean up the code to free hmm_range
Date: Tue, 28 Oct 2025 13:53:27 +0100	[thread overview]
Message-ID: <b78063a2-0356-4e21-8050-71085a559634@amd.com> (raw)
In-Reply-To: <20251028121330.3023032-1-sunil.khatri@amd.com>

On 10/28/25 13:13, Sunil Khatri wrote:
> a. hmm_range is either NULL or a valid pointer so we
> do not need to set range to NULL ever.
> 
> b. keep the hmm_range_free in the end irrespective of
> the other conditions to avoid some additional checks
> and also avoid double free issue.
> 
> Signed-off-by: Sunil Khatri <sunil.khatri@amd.com>
> ---
>  drivers/gpu/drm/amd/amdkfd/kfd_svm.c | 12 ++++--------
>  1 file changed, 4 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_svm.c b/drivers/gpu/drm/amd/amdkfd/kfd_svm.c
> index ffb7b36e577c..fb3daa7cd326 100644
> --- a/drivers/gpu/drm/amd/amdkfd/kfd_svm.c
> +++ b/drivers/gpu/drm/amd/amdkfd/kfd_svm.c
> @@ -1744,11 +1744,8 @@ static int svm_range_validate_and_map(struct mm_struct *mm,
>  			else
>  				r = -ENOMEM;
>  			WRITE_ONCE(p->svms.faulting_task, NULL);
> -			if (r) {
> -				amdgpu_hmm_range_free(range);
> -				range = NULL;
> +			if (r)
>  				pr_debug("failed %d to get svm range pages\n", r);
> -			}
>  		} else {
>  			r = -EFAULT;
>  		}
> @@ -1767,14 +1764,13 @@ static int svm_range_validate_and_map(struct mm_struct *mm,
>  		 * Override return value to TRY AGAIN only if prior returns
>  		 * were successful
>  		 */
> -		if (range && !amdgpu_hmm_range_valid(range) && !r) {
> +		if (range && !amdgpu_hmm_range_valid(range) && !r ) {

Extra unnecessary space here before the ).

With that fixed Acked-by: Christian König <christian.koenig@amd.com> for this patch here and rb for #2 in the series.

Regards,
Christian.

>  			pr_debug("hmm update the range, need validate again\n");
>  			r = -EAGAIN;
>  		}
> -		/* Free the hmm range */
> -		if (range)
> -			amdgpu_hmm_range_free(range);
>  
> +		/* Free the hmm range */
> +		amdgpu_hmm_range_free(range);
>  
>  		if (!r && !list_empty(&prange->child_list)) {
>  			pr_debug("range split by unmap in parallel, validate again\n");


  parent reply	other threads:[~2025-10-28 12:53 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-10-28 12:13 [Patch v2 1/2] drm/amdkfd: clean up the code to free hmm_range Sunil Khatri
2025-10-28 12:13 ` [Patch v2 2/2] drm/amdgpu: caller should make sure not to double free Sunil Khatri
2025-10-28 12:53 ` Christian König [this message]
2025-10-28 15:10 ` [Patch v2 1/2] drm/amdkfd: clean up the code to free hmm_range Kuehling, Felix

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=b78063a2-0356-4e21-8050-71085a559634@amd.com \
    --to=christian.koenig@amd.com \
    --cc=Philip.Yang@amd.com \
    --cc=alexander.deucher@amd.com \
    --cc=amd-gfx@lists.freedesktop.org \
    --cc=felix.kuehling@amd.com \
    --cc=sunil.khatri@amd.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox