msm_gpu_convert_priority(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… 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 understands
  • ring_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 πŸ”₯

  • 0 on success πŸ’–
  • -errno on 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