for_each_old...obj_in_state(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… for_each_old...obj_in_state(9) πŸ’…

okay bestie, welcome to the Kernel API Manual β€” yes this is a real kernel macro page and yes it's lowkey iconic ✨


🌸 NAME 🌸

for_each_oldnew_private_obj_in_state β€” iterate over all private objects in an atomic update 🫢


πŸ¦‹ SYNOPSIS πŸ¦‹

for_each_oldnew_private_obj_in_state (__state , obj , old_obj_state , new_obj_state , __i );

✨ ARGUMENTS ✨

  • __state β€” struct drm_atomic_commit pointer. this is your main character, the atomic update itself πŸ’«
  • obj β€” struct drm_private_obj iteration cursor. it walks the loop for you, no cap
  • old_obj_state β€” struct drm_private_state iteration cursor for the old state πŸ™ˆ
  • new_obj_state β€” struct drm_private_state iteration cursor for the new state πŸ’–
  • __i β€” int iteration cursor, strictly for macro-internal use. bestie do NOT touch this one, it's giving backstage pass only πŸŽ€

🌈 DESCRIPTION 🌈

so the way that this works is it iterates over all private objects in an atomic update, and it tracks both the old state AND the new state at the same time. like a glow-up in real time, obsessed πŸ’…

that makes it super useful in places where you actually need to look at the state delta β€” i.e. what changed between old and new β€” for example in atomic check functions. it's giving "spot the difference" but make it kernel πŸ”₯


🧚 SEE ALSO 🧚

the whole friend group, fr fr:

ok that's a lot of siblings but every single one of them is mandatory reading, i don't make the rules 😭

πŸ“ SIGN-OFF πŸ“

this little gem lives in ./include/drm and the page is dated October 2026 β€” and the title at the tippy top is still for_each_old...obj_in_state(9), no cap. stay hydrated, read your state deltas, and slay πŸ’œπŸ‘‘

πŸ“¦ where this page comes from