STRUCT MSM_PERFCNTR_STATE(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’œ struct msm_perfcntr_state(9) β€” the whole global perfcntr vibe

okay bestie, so this is a page from the Kernel API Manual β€” section 9, kernel API, we love a niche corner of the docs ✨ β€” and today's main character is struct msm_perfcntr_state, which is the overall global perfcntr state. that's the whole assignment. she's global, she's a struct, she holds the perfcntr situation together. periodt πŸ’…


πŸŽ€ SYNOPSIS πŸŽ€

like, literally, this is her:

struct msm_perfcntr_state {
    struct msm_perfcntr_stream *stream;
    uint32_t sel_seqno;
    struct msm_perfcntr_group_state *groups[];
};

no cap, that's it. three fields and a lot of responsibility 🫢


🌸 Members 🌸

okay let's go field by field, i'm obsessed with each of them:

  • stream β€” the current global counter stream, but only if active bestie. if it's not active, she's not streaming, that's the whole point πŸ™ˆ
  • sel_seqno β€” a counter for sel_fence. that's her job. counting. for the fence. iconic behavior honestly ⭐
  • groups β€” the Global perfcntr stream group state</> πŸ¦‹ that's the state of the stream groups, globally. yes queen.

🧚 the lore (a.k.a. why she exists like this)

so, conceptually, this thing is part of msm_perfcntr_stream state. like emotionally, she belongs to the stream. but she doesn't live there, because she's statically pre-allocated when the gpu is initialized β€” and the reason is genuinely so real:

it simplifies error path cleanup in the PERFCNTR_CONFIG ioctl πŸ’€ because as the docs literally put it: __free(kfree) doesn't really help with variable length arrays of allocated pointers. and that's the truth, ngl. the cleanup would be a whole mess, so we just don't go there. static allocation. slay.

lowkey important: the "conceptually part of msm_perfcntr_stream state" thing is the actual explanation from the page β€” she's not physically in that struct, she's just spiritually adjacent, and the pre-allocation at gpu init is why. iykyk πŸŽ€

πŸ”₯ SEE ALSO πŸ”₯

go read these next, bestie, they're the friend group:

  • Kernel file ./drivers/gpu/drm/msm/msm_gpu.h β€” the file, yes, the whole file, go look at it πŸ“
  • struct msm_gpu_devfreq(9)
  • struct msm_perfcntr_group_state(9)
  • struct msm_context(9)
  • msm_context_is_vmbind(9)
  • msm_gpu_convert_priority(9)
  • struct msm_gpu_submitqueue(9)

read them in order or don't, we don't gatekeep 🌈


mwah πŸ’‹ this page lives in ./drivers/gpu/drm/msm, it's from October 2026, and it's the struct msm_perfcntr_state(9) page β€” tag yourself, i'm the variable length array of allocated pointers that nobody wants to free πŸ“βœ¨

πŸ“¦ where this page comes from