kgd_gfx_v12_...cu_occupancy(9)
π kgd_gfx_v12_1_get_cu_occupancy β Kernel API Manual edition π
okay so bestie, welcome to the <pink>Kernel API Manual</pink> β¨ and honestly? this one is a whole mood. it's kgd_gfx_v12_...cu_occupancy(9) (the full function name is kgd_gfx_v12_1_get_cu_occupancy, yes the header is doing that little abbreviation thing, we love her anyway π
).
πΈ NAME πΈ
kgd_gfx_v12_1_get_cu_occupancy β reads the relevant registers that are associated with each shader engine, and aggregates the number of waves that are in flight for the process whose pasid is passed in as a parameter π¦. and like, no big deal, but that process could have <hotpink>ZERO</hotpink> or more queues running and submitting waves to compute units. zero. or more. the range is giving "anything is possible" energy fr fr π
β SYNOPSIS β
void kgd_gfx_v12_1_get_cu_occupancy (struct amdgpu_device *adev , struct
kfd_cu_occupancy *cu_occupancy , int *max_waves_per_cu , uint32_t inst );
β¨ ARGUMENTS β¨
adevβ handle of the device you're pulling the number of waves in flight from π«Άcu_occupancyβ the array that gets filled withwave_cntand the doorbell offset, so you can compare stuff later πmax_waves_per_cuβ output parameter, gets updated with the maximum number of waves possible per Compute Unit πinstβ the xcc's instance number, for when you're on a multi-XCC setup π
π NOTE π
π¨ bestie listen. it's possible that the device has<red>too many queues</red>(that's oversubscription, iykyk) and in that case a VMID could get remapped to a different PASID. and that? that could lead to an<red>inaccurate wave count</red>π. here's the high-level sequence, laid out for you:
- Time T1:
vmid = getVmidβ thevmidis associated with PasidP1 - Time T2:
passId = getPasId(vmid)β thevmidis associated with PasidP2
so in that sequence up there, the wave count you got from time T1 will be <yellow>incorrectly lost or added to the total wave count</yellow>. not the vibe. π
the registers that provide the waves in flight are:
SPI_CSQ_WF_ACTIVE_STATUSβ a bit-map of queues per pipe π§. the bit is<green>ON</green>if a queue is slotted,<red>OFF</red>if there's no queue at all. a process could have ZERO or more queues slotted and submitting waves to be run on compute units. and even when there is a queue, it's possible there could be zero wave fronts β that happens when the queue is waiting on top-of-pipe events, like awaitRegMemcommand, for example π
for each bit that's ON from the above:
- read the
(SPI_CSQ_WF_ACTIVE_COUNT_0 + queue_idx)register π. it gives you the number of waves that are in flight for the queue at that specified index, and the index ranges from0to7 - if there are non-zero waves in flight, store the corresponding doorbell offset of the queue, along with the wave count π
- determine if the queue belongs to the process by comparing the doorbell offset against the process's queues. if it matches, aggregate the wave count for the process β
- reading the registers referenced above involves programming GRBM appropriately, that's just how it is β
π¦ SEE ALSO π¦
- Kernel file
./drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v12_1.c get_wave_count(9)
and that's the whole page bestie, no cap, every last detail intact π β¨
this little icon came out of the source <cyan>./drivers/gpu/drm/amd/amdgpu</cyan> and it's stamped <mint>October 2026</mint> β so like, shoutout to the manual, she's dated and she's slaying π«Άπ
π¦ 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