From: "Christian König" <christian.koenig@amd.com>
To: "Khatri, Sunil" <sukhatri@amd.com>,
Sunil Khatri <sunil.khatri@amd.com>,
Alex Deucher <alexander.deucher@amd.com>
Cc: amd-gfx@lists.freedesktop.org
Subject: Re: [PATCH v4] drm/amdgpu/userq: refcount userqueues to avoid any race conditions
Date: Tue, 3 Mar 2026 15:06:13 +0100 [thread overview]
Message-ID: <e7b07f6f-c90c-4b78-910e-860c36280ced@amd.com> (raw)
In-Reply-To: <aeafbd1a-49a4-4049-8523-b29f78344fd3@amd.com>
On 3/3/26 14:49, Khatri, Sunil wrote:
>>> @@ -1000,11 +1018,14 @@ int amdgpu_userq_ioctl(struct drm_device *dev, void *data,
>>> drm_file_err(filp, "Failed to create usermode queue\n");
>>> break;
>>> - case AMDGPU_USERQ_OP_FREE:
>>> - r = amdgpu_userq_destroy(filp, args->in.queue_id);
>>> - if (r)
>>> - drm_file_err(filp, "Failed to destroy usermode queue\n");
>>> + case AMDGPU_USERQ_OP_FREE: {
>>> + queue = xa_erase(&fpriv->userq_mgr.userq_xa, args->in.queue_id);
>> You need to have xa_lock around that or otherwise xa_load/kref_get can race.
> __xa_erase is unlocked version, but xa_erase internally does have xa_lock, since there is nothing else but just erase here to it made more sense to have clear xa_erase.
No, that doesn't work like that.
The problem is that xa_erase() takes the lock only optionally when it can't exchange the entry with NULL atomically (e.g. because a full page needs to be freed up or similar).
But in our use case taking the lock is mandatory because kref_get otherwise doesn't work.
Regards,
Christian.
next prev parent reply other threads:[~2026-03-03 14:06 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-03 12:06 [PATCH v4] drm/amdgpu/userq: refcount userqueues to avoid any race conditions Sunil Khatri
2026-03-03 13:46 ` Christian König
2026-03-03 13:49 ` Khatri, Sunil
2026-03-03 14:06 ` Christian König [this message]
2026-03-03 14:13 ` Khatri, Sunil
-- strict thread matches above, loose matches on Subject: below --
2026-03-03 12:08 Sunil Khatri
2026-03-03 12:48 ` Khatri, Sunil
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=e7b07f6f-c90c-4b78-910e-860c36280ced@amd.com \
--to=christian.koenig@amd.com \
--cc=alexander.deucher@amd.com \
--cc=amd-gfx@lists.freedesktop.org \
--cc=sukhatri@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