msm_gpu_convert_priority(9)
π msm_gpu_convert_priority(9) β from the Kernel API Manual, bestie
okay so real talk, this is one of those tiny little functions that's doing SO much emotional labor behind the scenes. it takes a userspace priority and turns it into a ring number + a scheduler priority. that's it. that's the whole vibe. and it's lowkey iconic for it. π
β¨ SYNOPSIS β¨
int msm_gpu_convert_priority (struct msm_gpu *gpu , int prio , unsigned
*ring_nr , enum drm_sched_priority *sched_prio );
like yes, that's the whole signature, she's not long, she's efficient, we stan π
πΈ ARGUMENTS πΈ
gpuβ the gpu instance. your main character. the whole reason we're here π«Άprioβ the userspace priority level. this is the number the user hands you, and you're about to translate it into something the kernel actually understandsring_nrβ [out] β the ringbuffer that the userspace priority maps to. it's an output, so you're filling this bad boy in, not reading it πsched_prioβ [out] β the gpu scheduler priority level that the userspace priority maps to. also an output. also yours to populate. no cap β¨
π¦ DESCRIPTION π¦
okay so here's the lore. drm/scheduler provides its own level of prioritization, right? so our total number of available priority levels is literally (nr_rings * NR_SCHED_PRIORITIES). multiply it out, that's the whole menu π
each ring is associated with its own scheduler instance β that's the structural tea β
BUT. and this is the plot twist. our UABI says that lower numerical values are higher priority. so mapping that single userspace priority level into ring_nr and sched_prio takes some care, because the directions are kind of opposite-ish and you can't just vibes your way through it π
so the userspace provided priority (like, when a submitqueue is created) gets mapped to ring nr and scheduler priority as such:
ring_nr = userspace_prio / NR_SCHED_PRIORITIES
sched_prio = NR_SCHED_PRIORITIES - (userspace_prio % NR_SCHED_PRIORITIES) - 1
which, honestly? slay. π
and why does this matter: it allows generations without preemption (nr_rings==1) to still have some amount of prioritization, and it provides more priority levels for gens that do have preemption. so everybody eats, just at different amounts π
π₯ RETURN π₯
0on success π-errnoon error π
π SEE ALSO π
- Kernel file
./drivers/gpu/drm/msm/msm_gpu.h struct msm_gpu_devfreq(9)struct msm_perfcntr_group_state(9)struct msm_perfcntr_state(9)struct msm_context(9)msm_context_is_vmbind(9)struct msm_gpu_submitqueue(9)
ngl bestie, if you're touching submitqueue creation, go read struct msm_gpu_submitqueue(9) too. iykyk π§
and that's the page!! brought to you by ./drivers/gpu/drm/msm, dated October 2026 β mwah, go convert some priorities responsibly, ily, bye!! ππ¦β
π¦ where this page comes from
- nixpkgs unstable: linux-manual 7.3.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms