Skip to contentSkip to conversation

drm/amdgpu/userq: gnome shell uses max priority

PATCH In review Sunil Khatri 5 participants 10 messages Apr 13 – Apr 16

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/amdgpu/userq: gnome shell uses max priority

In function amdgpu_userq_priority_permit allow till maximum priority i.e 3 which is seen for gnome shell.

This is needed to fix the issue of unable to create queue for gnome shell.

logs:
[drm] *ERROR* comm: gnome-shell pid: 2802 client-id:10 client: Unset ... SK: Priority 3

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c +1 -1
index 6a635bb8bb30..b4f7229c21c5 100644
@@ -701,7 +701,7 @@ void amdgpu_userq_put(struct amdgpu_usermode_queue *queue)
 static int amdgpu_userq_priority_permit(struct drm_file *filp,
 					int priority)
 {
-	if (priority < AMDGPU_USERQ_CREATE_FLAGS_QUEUE_PRIORITY_HIGH)
+	if (priority <= AMDGPU_USERQ_CREATE_FLAGS_QUEUE_PRIORITY_HIGH)
 		return 0;
 
 	if (capable(CAP_SYS_NICE))
Signature · 1 line
2.34.1
maintainer
#1 lore raw
Quoted 8 lines · Sunil Khatri

In function amdgpu_userq_priority_permit allow till maximum priority i.e 3 which is seen for gnome shell.

This is needed to fix the issue of unable to create queue for gnome shell.

logs:
[drm] *ERROR* comm: gnome-shell pid: 2802 client-id:10 client: Unset ... SK: Priority 3

Clear NAK, as far as I can see the existing code is correct.

AMDGPU_USERQ_CREATE_FLAGS_QUEUE_PRIORITY_HIGH is only allowed when you have CAP_SYS_NICE, e.g. you are root.

That is also documented in the UAPI. Question is why is gnome shell trying to use that?

Regards,
Christian.

Quoted 19 lines
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c +1 -1
index 6a635bb8bb30..b4f7229c21c5 100644
@@ -701,7 +701,7 @@ void amdgpu_userq_put(struct amdgpu_usermode_queue *queue)
 static int amdgpu_userq_priority_permit(struct drm_file *filp,
 					int priority)
 {
-	if (priority < AMDGPU_USERQ_CREATE_FLAGS_QUEUE_PRIORITY_HIGH)
+	if (priority <= AMDGPU_USERQ_CREATE_FLAGS_QUEUE_PRIORITY_HIGH)
 		return 0;
 
 	if (capable(CAP_SYS_NICE))
#2 lore raw
Quoted 7 lines · Christian König
Quoted 6 lines · Sunil Khatri

In function amdgpu_userq_priority_permit allow till maximum priority i.e 3 which is seen for gnome shell.

This is needed to fix the issue of unable to create queue for gnome shell.

Quoted 7 lines
Quoted 2 lines

logs:
[drm] *ERROR* comm: gnome-shell pid: 2802 client-id:10 client: Unset ... SK: Priority 3

Clear NAK, as far as I can see the existing code is correct.

AMDGPU_USERQ_CREATE_FLAGS_QUEUE_PRIORITY_HIGH is only allowed when you have CAP_SYS_NICE, e.g. you are root.

That is also documented in the UAPI. Question is why is gnome shell trying to use that?

I see, let me add Yogesh for his inputs, @yogesh, why gnome shell is asking for priority AMDGPU_USERQ_CREATE_FLAGS_QUEUE_PRIORITY_HIGH. Based on the code seems mesa is getting a flag set flags & PIPE_CONTEXT_HIGH_PRIORITY -> this sets AMDGPU_USERQ_CREATE_FLAGS_QUEUE_PRIORITY_HIGH for graphics queue. Regards Sunil Khatri

Quoted 22 lines

Regards,
Christian.

Quoted 18 lines
---
  drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c +1 -1
index 6a635bb8bb30..b4f7229c21c5 100644
@@ -701,7 +701,7 @@ void amdgpu_userq_put(struct amdgpu_usermode_queue *queue)
  static int amdgpu_userq_priority_permit(struct drm_file *filp,
  					int priority)
  {
-	if (priority < AMDGPU_USERQ_CREATE_FLAGS_QUEUE_PRIORITY_HIGH)
+	if (priority <= AMDGPU_USERQ_CREATE_FLAGS_QUEUE_PRIORITY_HIGH)
  		return 0;
 
  	if (capable(CAP_SYS_NICE))
#3 lore raw
Quoted 8 lines · Sunil
Quoted 7 lines · Christian König
Quoted 6 lines · Sunil Khatri

In function amdgpu_userq_priority_permit allow till maximum priority i.e 3 which is seen for gnome shell.

This is needed to fix the issue of unable to create queue for gnome shell.

Quoted 8 lines
Quoted 7 lines
Quoted 2 lines

logs:
[drm] *ERROR* comm: gnome-shell pid: 2802 client-id:10 client: Unset ... SK: Priority 3

Clear NAK, as far as I can see the existing code is correct.

AMDGPU_USERQ_CREATE_FLAGS_QUEUE_PRIORITY_HIGH is only allowed when you have CAP_SYS_NICE, e.g. you are root.

That is also documented in the UAPI. Question is why is gnome shell trying to use that?

I see, let me add Yogesh for his inputs, @yogesh, why gnome shell is asking for priority AMDGPU_USERQ_CREATE_FLAGS_QUEUE_PRIORITY_HIGH. Based on the code seems mesa is getting a flag set flags & PIPE_CONTEXT_HIGH_PRIORITY -> this sets AMDGPU_USERQ_CREATE_FLAGS_QUEUE_PRIORITY_HIGH for graphics queue.

For some background, mutter uses EGL_CONTEXT_PRIORITY_HIGH_IMG when EGL_IMG_context_priority is supported, to try and prevent its GPU work from getting starved by clients.

This works (or at least doesn't fail similarly) with kernel queues, presumably via DRM master status. I'd argue that should suffice with user queues as well.

Signature · 2 lines
Earthling Michel Dänzer       \        GNOME / Xwayland / Mesa developer
https://redhat.com             \               Libre software enthusiast
#4 lore raw
Quoted 13 lines · Michel Dänzer
Quoted 12 lines · Sunil
Quoted 11 lines · Christian König
Quoted 8 lines · Sunil Khatri

In function amdgpu_userq_priority_permit allow till maximum priority i.e 3 which is seen for gnome shell.

This is needed to fix the issue of unable to create queue for gnome shell.

logs:
[drm] *ERROR* comm: gnome-shell pid: 2802 client-id:10 client: Unset ... SK: Priority 3

Clear NAK, as far as I can see the existing code is correct.

Quoted 8 lines
Quoted 4 lines
Quoted 3 lines

AMDGPU_USERQ_CREATE_FLAGS_QUEUE_PRIORITY_HIGH is only allowed when you have CAP_SYS_NICE, e.g. you are root.

That is also documented in the UAPI. Question is why is gnome shell trying to use that?

I see, let me add Yogesh for his inputs, @yogesh, why gnome shell is asking for priority AMDGPU_USERQ_CREATE_FLAGS_QUEUE_PRIORITY_HIGH. Based on the code seems mesa is getting a flag set flags & PIPE_CONTEXT_HIGH_PRIORITY -> this sets AMDGPU_USERQ_CREATE_FLAGS_QUEUE_PRIORITY_HIGH for graphics queue.

For some background, mutter uses EGL_CONTEXT_PRIORITY_HIGH_IMG when EGL_IMG_context_priority is supported, to try and prevent its GPU work from getting starved by clients.

This works (or at least doesn't fail similarly) with kernel queues, presumably via DRM master status. I'd argue that should suffice with user queues as well.

Below is the check that we have for userqueues during queue creation, and for gnome it did not hit any of the condition and eventually return with -EACCES that is wrong. It has to be maste or CAP_SYS_NICE capable. if(priority<AMDGPU_USERQ_CREATE_FLAGS_QUEUE_PRIORITY_HIGH)
return0;
if(capable(CAP_SYS_NICE))
return0;
if(drm_is_current_master(filp))
return0;
return-EACCES;

regards
Sunil khatri

Quoted 2 lines
#5 lore raw
Quoted 31 lines · Sunil

On 14-04-2026 07:12 pm, Michel Dänzer wrote:

On 4/13/26 11:24, Khatri, Sunil wrote:

On 13-04-2026 02:32 pm, Christian König wrote:

On 4/13/26 10:49, Sunil Khatri wrote:

In function amdgpu_userq_priority_permit allow till maximum priority i.e 3 which is seen for gnome shell.

This is needed to fix the issue of unable to create queue for gnome shell.

logs:
[drm] *ERROR* comm: gnome-shell pid: 2802 client-id:10 client: Unset ... SK: Priority 3

Clear NAK, as far as I can see the existing code is correct.

AMDGPU_USERQ_CREATE_FLAGS_QUEUE_PRIORITY_HIGH is only allowed when you have CAP_SYS_NICE, e.g. you are root.

That is also documented in the UAPI. Question is why is gnome shell trying to use that?

I see, let me add Yogesh for his inputs, @yogesh, why gnome shell is asking for priority AMDGPU_USERQ_CREATE_FLAGS_QUEUE_PRIORITY_HIGH. Based on the code seems mesa is getting a flag set flags & PIPE_CONTEXT_HIGH_PRIORITY -> this sets AMDGPU_USERQ_CREATE_FLAGS_QUEUE_PRIORITY_HIGH for graphics queue.

For some background, mutter uses EGL_CONTEXT_PRIORITY_HIGH_IMG when EGL_IMG_context_priority is supported, to try and prevent its GPU work from getting starved by clients.

This works (or at least doesn't fail similarly) with kernel queues, presumably via DRM master status. I'd argue that should suffice with user queues as well.

Quoted 8 lines

Below is the check that we have for userqueues during queue creation, and for gnome it did not hit any of the condition and eventually return with -EACCES that is wrong. It has to be maste or CAP_SYS_NICE capable. if (priority < AMDGPU_USERQ_CREATE_FLAGS_QUEUE_PRIORITY_HIGH)

                return 0;
        if (capable(CAP_SYS_NICE))
                return 0;
        if (drm_is_current_master(filp))
                return 0;
        return -EACCES;

This is the same logic as kernel queues:

        /* NORMAL and below are accessible by everyone */
        if (priority <= AMDGPU_CTX_PRIORITY_NORMAL)
                return 0;

        if (capable(CAP_SYS_NICE))
                return 0;

        if (drm_is_current_master(filp))
                return 0;

        return -EACCES;

Maybe there is a timing difference?

Alex

#6 lore raw
In reply to Khatri, Sunil
Quoted 22 lines · Sunil
Quoted 13 lines · Michel Dänzer
Quoted 12 lines · Sunil
Quoted 11 lines · Christian König
Quoted 8 lines · Sunil Khatri

In function amdgpu_userq_priority_permit allow till maximum priority i.e 3 which is seen for gnome shell.

This is needed to fix the issue of unable to create queue for gnome shell.

logs:
[drm] *ERROR* comm: gnome-shell pid: 2802 client-id:10 client: Unset ... SK: Priority 3

Clear NAK, as far as I can see the existing code is correct.

Quoted 8 lines
Quoted 4 lines
Quoted 3 lines

AMDGPU_USERQ_CREATE_FLAGS_QUEUE_PRIORITY_HIGH is only allowed when you have CAP_SYS_NICE, e.g. you are root.

That is also documented in the UAPI. Question is why is gnome shell trying to use that?

I see, let me add Yogesh for his inputs, @yogesh, why gnome shell is asking for priority AMDGPU_USERQ_CREATE_FLAGS_QUEUE_PRIORITY_HIGH. Based on the code seems mesa is getting a flag set flags & PIPE_CONTEXT_HIGH_PRIORITY -> this sets AMDGPU_USERQ_CREATE_FLAGS_QUEUE_PRIORITY_HIGH for graphics queue.

For some background, mutter uses EGL_CONTEXT_PRIORITY_HIGH_IMG when EGL_IMG_context_priority is supported, to try and prevent its GPU work from getting starved by clients.

This works (or at least doesn't fail similarly) with kernel queues, presumably via DRM master status. I'd argue that should suffice with user queues as well.

Quoted 8 lines

Below is the check that we have for userqueues during queue creation, and for gnome it did not hit any of the condition and eventually return with -EACCES that is wrong. It has to be maste or CAP_SYS_NICE capable. if(priority<AMDGPU_USERQ_CREATE_FLAGS_QUEUE_PRIORITY_HIGH)
                return0;
        if(capable(CAP_SYS_NICE))
                return0;
        if(drm_is_current_master(filp))
                return0;
        return-EACCES;

Indeed, looks like at least in some cases mutter creates the EGL context before it has DRM master status. I'll look into fixing this in mutter.

With kernel queues, radeonsi silently falls back to a normal-priority context in this case, but then still claims it's high priority. I filed https://gitlab.freedesktop.org/mesa/mesa/-/work_items/15282 about this.

Meanwhile, user queues should probably also fail without logging an error in this case.

Signature · 2 lines
Earthling Michel Dänzer       \        GNOME / Xwayland / Mesa developer
https://redhat.com             \               Libre software enthusiast
#7 lore raw
Quoted 32 lines · Michel Dänzer
Quoted 22 lines · Sunil
Quoted 13 lines · Michel Dänzer
Quoted 12 lines · Sunil
Quoted 11 lines · Christian König
Quoted 8 lines · Sunil Khatri

In function amdgpu_userq_priority_permit allow till maximum priority i.e 3 which is seen for gnome shell.

This is needed to fix the issue of unable to create queue for gnome shell.

logs:
[drm] *ERROR* comm: gnome-shell pid: 2802 client-id:10 client: Unset ... SK: Priority 3

Clear NAK, as far as I can see the existing code is correct.

Quoted 8 lines
Quoted 4 lines
Quoted 3 lines

AMDGPU_USERQ_CREATE_FLAGS_QUEUE_PRIORITY_HIGH is only allowed when you have CAP_SYS_NICE, e.g. you are root.

That is also documented in the UAPI. Question is why is gnome shell trying to use that?

I see, let me add Yogesh for his inputs, @yogesh, why gnome shell is asking for priority AMDGPU_USERQ_CREATE_FLAGS_QUEUE_PRIORITY_HIGH. Based on the code seems mesa is getting a flag set flags & PIPE_CONTEXT_HIGH_PRIORITY -> this sets AMDGPU_USERQ_CREATE_FLAGS_QUEUE_PRIORITY_HIGH for graphics queue.

For some background, mutter uses EGL_CONTEXT_PRIORITY_HIGH_IMG when EGL_IMG_context_priority is supported, to try and prevent its GPU work from getting starved by clients.

This works (or at least doesn't fail similarly) with kernel queues, presumably via DRM master status. I'd argue that should suffice with user queues as well.

Quoted 8 lines

Below is the check that we have for userqueues during queue creation, and for gnome it did not hit any of the condition and eventually return with -EACCES that is wrong. It has to be maste or CAP_SYS_NICE capable. if(priority<AMDGPU_USERQ_CREATE_FLAGS_QUEUE_PRIORITY_HIGH)
                return0;
        if(capable(CAP_SYS_NICE))
                return0;
        if(drm_is_current_master(filp))
                return0;
        return-EACCES;

Quoted 1 line

Indeed, looks like at least in some cases mutter creates the EGL context before it has DRM master status. I'll look into fixing this in mutter.

I realized what I'm seeing is a regression from https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/40519 , since a render node file description can't have DRM master status.

I created https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/40974 to fix that.

Signature · 2 lines
Earthling Michel Dänzer       \        GNOME / Xwayland / Mesa developer
https://redhat.com             \               Libre software enthusiast
#8 lore raw

Seems to work. Not seeing the queue creation failures anymore after i used the change.

Regards
Sunil khatri

Quoted 37 lines · Michel Dänzer
Quoted 31 lines · Michel Dänzer
Quoted 22 lines · Sunil
Quoted 13 lines · Michel Dänzer
Quoted 12 lines · Sunil
Quoted 11 lines · Christian König
Quoted 8 lines · Sunil Khatri

In function amdgpu_userq_priority_permit allow till maximum priority i.e 3 which is seen for gnome shell.

This is needed to fix the issue of unable to create queue for gnome shell.

logs:
[drm] *ERROR* comm: gnome-shell pid: 2802 client-id:10 client: Unset ... SK: Priority 3

Clear NAK, as far as I can see the existing code is correct.

Quoted 8 lines
Quoted 4 lines
Quoted 3 lines

AMDGPU_USERQ_CREATE_FLAGS_QUEUE_PRIORITY_HIGH is only allowed when you have CAP_SYS_NICE, e.g. you are root.

That is also documented in the UAPI. Question is why is gnome shell trying to use that?

I see, let me add Yogesh for his inputs, @yogesh, why gnome shell is asking for priority AMDGPU_USERQ_CREATE_FLAGS_QUEUE_PRIORITY_HIGH. Based on the code seems mesa is getting a flag set flags & PIPE_CONTEXT_HIGH_PRIORITY -> this sets AMDGPU_USERQ_CREATE_FLAGS_QUEUE_PRIORITY_HIGH for graphics queue.

For some background, mutter uses EGL_CONTEXT_PRIORITY_HIGH_IMG when EGL_IMG_context_priority is supported, to try and prevent its GPU work from getting starved by clients.

This works (or at least doesn't fail similarly) with kernel queues, presumably via DRM master status. I'd argue that should suffice with user queues as well.

Quoted 8 lines

Below is the check that we have for userqueues during queue creation, and for gnome it did not hit any of the condition and eventually return with -EACCES that is wrong. It has to be maste or CAP_SYS_NICE capable. if(priority<AMDGPU_USERQ_CREATE_FLAGS_QUEUE_PRIORITY_HIGH)
                return0;
        if(capable(CAP_SYS_NICE))
                return0;
        if(drm_is_current_master(filp))
                return0;
        return-EACCES;

Quoted 1 line

Indeed, looks like at least in some cases mutter creates the EGL context before it has DRM master status. I'll look into fixing this in mutter.

I realized what I'm seeing is a regression from https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/40519 , since a render node file description can't have DRM master status.

I created https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/40974 to fix that.

#9 lore raw
Quoted 12 lines · Sunil
Quoted 11 lines · Michel Dänzer
Quoted 10 lines · Michel Dänzer
Quoted 9 lines · Sunil

Below is the check that we have for userqueues during queue creation, and for gnome it did not hit any of the condition and eventually return with -EACCES that is wrong. It has to be maste or CAP_SYS_NICE capable. if(priority<AMDGPU_USERQ_CREATE_FLAGS_QUEUE_PRIORITY_HIGH)
                 return0;
         if(capable(CAP_SYS_NICE))
                 return0;
         if(drm_is_current_master(filp))
                 return0;
         return-EACCES;

Quoted 6 lines
Quoted 4 lines
Quoted 1 line

Indeed, looks like at least in some cases mutter creates the EGL context before it has DRM master status. I'll look into fixing this in mutter.

I realized what I'm seeing is a regression from https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/40519 , since a render node file description can't have DRM master status.

I created https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/40974 to fix that.

Seems to work. Not seeing the queue creation failures anymore after i used the change.

That's good.

There can still be scenarios where it'll fail though, which should be handled as gracefully with user queues as with kernel ones.

P.S. Please don't top-post.

Signature · 2 lines
Earthling Michel Dänzer       \        GNOME / Xwayland / Mesa developer
https://redhat.com             \               Libre software enthusiast