AMD-GFX Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: "Khatri, Sunil" <sukhatri@amd.com>
To: "Christian König" <christian.koenig@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 19:43:28 +0530	[thread overview]
Message-ID: <9c4b7ff3-ec22-43d3-93fc-1c0cb7de0e65@amd.com> (raw)
In-Reply-To: <e7b07f6f-c90c-4b78-910e-860c36280ced@amd.com>


On 03-03-2026 07:36 pm, Christian König wrote:
> 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.
Ok sure i would add explicit locks in that case. Thanks for that 
information.

Regards
Sunil Khatri
>
> Regards,
> Christian.
>

  reply	other threads:[~2026-03-03 14:13 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
2026-03-03 14:13       ` Khatri, Sunil [this message]
  -- 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=9c4b7ff3-ec22-43d3-93fc-1c0cb7de0e65@amd.com \
    --to=sukhatri@amd.com \
    --cc=alexander.deucher@amd.com \
    --cc=amd-gfx@lists.freedesktop.org \
    --cc=christian.koenig@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