ttm_bo_lru_f...rved_guarded(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… ttm_bo_lru_for_each_reserved_guarded πŸ’…

okay bestie, buckle up β€” this one is from the Kernel API Manual, and it's a macro that walks LRU lists and reserves buffer objects as it goes. it's giving "for loop but make it fashion" ✨


✨ NAME ✨

ttm_bo_lru_for_each_reserved_guarded β€” literally just iterate over buffer objects that own resources on LRU lists πŸ¦‹ that's the whole vibe.


πŸŽ€ SYNOPSIS πŸŽ€

ttm_bo_lru_for_each_reserved_guarded (_cursor , _man , _arg , _bo );

🌸 ARGUMENTS 🌸

  • _cursor β€” the struct ttm_bo_lru_cursor you're gonna use for the iteration. it's your little tracker bestie, it keeps the place 🫢
  • _man β€” the resource manager whose LRU lists we're walking over. yes, that one πŸ‘‘
  • _arg β€” the struct ttm_lru_walk_arg that governs the LRU walk. it's the vibe check for how the walk goes down πŸ’…
  • _bo β€” the struct ttm_buffer_object pointer that points at the buffer object for the current iteration. main character energy, honestly ⭐

πŸ’– DESCRIPTION πŸ’–

so here's the tea: you iterate over all the resources of _man, and for each resource, it tries to reference and lock the buffer object that resource points to β€” using the locking mode detailed in _ctx πŸ”’ (yes, _ctx, we love a mysterious icon). if that works out, it assigns _bo to the address of the buffer object and updates _cursor. slay. ✨

and the "guarded" part? that's the whole point, bestie β€” _cursor gets initialized before the looping starts and cleaned up when the looping terminates, even if you bail early with, like, a return or a break. the loop has your back fr fr 😭. and when you exit the loop, it also unlocks _bo (if it needs to) and unreferences it. no leftover mess, no leaking, iconic behavior πŸ’œ


πŸ”₯ RETURN πŸ”₯

ngl, if locking a bo returns an error, the iteration just stops there and _bo gets set to a corresponding error pointer. that's it, that's the whole thing 🫠

⚠️ warning bestie: it's illegal to dereference _bo after the loop exits. like, do not do it. not even a little peek. πŸ’€

🧚 SEE ALSO 🧚


πŸ’« and that's the page, babe πŸ’« this cutie lives in ./include/drm/ttm, it's dated October 2026, and the whole thing is filed under ttm_bo_lru_f...rved_guarded(9) β€” go forth and iterate responsibly, ily πŸŽ€πŸ’–πŸŒˆ

πŸ“¦ where this page comes from