From: Eric Huang <jinhuieric.huang@amd.com>
To: amd-gfx@lists.freedesktop.org
Subject: Re: [PATCH] drm/amdkfd: Fix a race condition of vram buffer unref in svm code
Date: Wed, 27 Sep 2023 10:19:24 -0400 [thread overview]
Message-ID: <101279ab-0c40-e169-e1b8-3a171d20bbb7@amd.com> (raw)
In-Reply-To: <20230927030008.278066-1-xiaogang.chen@amd.com>
On 2023-09-26 23:00, Xiaogang.Chen wrote:
> From: Xiaogang Chen <xiaogang.chen@amd.com>
>
> prange->svm_bo unref can happen in both mmu callback and a callback after
> migrate to system ram. Both are async call in different tasks. Sync svm_bo
> unref operation to avoid random "use-after-free".
>
> Signed-off-by: Xiaogang.Chen <Xiaogang.Chen@amd.com>
> ---
> drivers/gpu/drm/amd/amdkfd/kfd_svm.c | 9 +++++++++
> 1 file changed, 9 insertions(+)
>
> diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_svm.c b/drivers/gpu/drm/amd/amdkfd/kfd_svm.c
> index 70aa882636ab..8e246e848018 100644
> --- a/drivers/gpu/drm/amd/amdkfd/kfd_svm.c
> +++ b/drivers/gpu/drm/amd/amdkfd/kfd_svm.c
> @@ -637,6 +637,15 @@ void svm_range_vram_node_free(struct svm_range *prange)
> {
> svm_range_bo_unref(prange->svm_bo);
> prange->ttm_res = NULL;
Are above two lines not removed?
Regards,
Eric
> + /* serialize prange->svm_bo unref */
> + mutex_lock(&prange->lock);
> + /* prange->svm_bo has not been unref */
> + if (prange->ttm_res) {
> + prange->ttm_res = NULL;
> + mutex_unlock(&prange->lock);
> + svm_range_bo_unref(prange->svm_bo);
> + } else
> + mutex_unlock(&prange->lock);
> }
>
> struct kfd_node *
next prev parent reply other threads:[~2023-09-27 14:19 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-27 3:00 [PATCH] drm/amdkfd: Fix a race condition of vram buffer unref in svm code Xiaogang.Chen
2023-09-27 3:13 ` Zhang, Jesse(Jie)
2023-09-27 13:59 ` Philip Yang
2023-09-27 14:19 ` Eric Huang [this message]
2023-09-27 15:10 ` Chen, Xiaogang
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=101279ab-0c40-e169-e1b8-3a171d20bbb7@amd.com \
--to=jinhuieric.huang@amd.com \
--cc=amd-gfx@lists.freedesktop.org \
/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