amdgpu_gfx_kfd_sch_ctrl(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… amdgpu_gfx_kfd_sch_ctrl β€” a whole kernel API manual, but make it cute

okay so bestie, welcome to amdgpu_gfx_kfd_sch_ctrl(9), a real page from the Kernel API Manual. yes it's a kernel function. yes it's about schedulers. no you don't have to be scared. let's go 🫢


✨ NAME ✨

amdgpu_gfx_kfd_sch_ctrl β€” no cap, this is the function that controls the KFD scheduler from the KGD (that's the Graphics Driver, iykyk) πŸ’…


πŸ¦‹ SYNOPSIS πŸ¦‹

void amdgpu_gfx_kfd_sch_ctrl (struct amdgpu_device *adev , u32 idx ,
       bool enable );

literally the whole signature. three args, one void return, zero drama (until the NOTE section, we'll get there) ✨


πŸŽ€ ARGUMENTS πŸŽ€

  • adev β€” an amdgpu_device pointer. your main character struct 🌸
  • idx β€” the index of the scheduler you wanna control. which one? this one. πŸ”₯
  • enable β€” whether to enable or disable the KFD scheduler. yes it's a bool. yes it's exactly what it sounds like. πŸ’œ

🌈 DESCRIPTION 🌈

so what does this thing actually do? it controls the KFD (Kernel Fusion Driver) scheduler from the KGD, bestie. it's part of the cleaner shader feature, and it plays a key role in enforcing process isolation on the GPU β€” which is kind of a big deal πŸ‘‘

the mechanism? a reference count called kfd_sch_req_count, tracking how many requests there are to enable the KFD scheduler. here's the tea:

  • when a request to enable the KFD scheduler is made, the reference count is decremented. (yes, decremented. that's what the page says. keep your eyes on it πŸ‘€)
  • when the reference count reaches zero, a delayed work is scheduled to enforce isolation after a delay of GFX_SLICE_PERIOD. iconic behaviour, honestly ⏳

and when a request to disable the KFD scheduler comes in, the function goes in this exact order:

  1. first it checks if the reference count is zero πŸ•΅οΈ
  2. if it is, it cancels the delayed work for enforcing isolation, and checks if the KFD scheduler is active
  3. if the KFD scheduler is active, it sends a request to stop the KFD scheduler and sets the KFD scheduler state to inactive πŸ’€
  4. then it increments the reference count ⬆️

the whole thing is synchronized using kfd_sch_mutex, so the KFD scheduler state and the reference count get updated atomically β€” no racing, no messy vibes, periodt πŸ”’


πŸ™ˆ NOTE πŸ™ˆ

listen. if the reference count is already zero when a request to enable the KFD scheduler is made, that means there's an imbalance bug somewhere. the function triggers a warning in this case. so if you see that warning, it's not a vibe, it's a bug hunt 🚨

🧚 SEE ALSO 🧚

the kernel file that started it all:

./drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c

and the whole friend group, in this exact order:

go read them. they're all slaying in their own way πŸ¦‹


πŸ’– and that's the page!! this cutie lives in ./drivers/gpu/drm/amd/amdgpu, dated October 2026, and it's filed under amdgpu_gfx_kfd_sch_ctrl(9) in the Kernel API Manual. mwah, go enforce some isolation bestie πŸŒΈβœ¨πŸŽ€

πŸ“¦ where this page comes from