ttm_bo_lru_f...rved_guarded(9)
π 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β thestruct ttm_bo_lru_cursoryou'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β thestruct ttm_lru_walk_argthat governs the LRU walk. it's the vibe check for how the walk goes down π_boβ thestruct ttm_buffer_objectpointer 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 π§
- Kernel file
./include/drm/ttm/ttm_bo.h enum ttm_bo_type(9)struct ttm_buffer_object(9)struct ttm_bo_kmap_obj(9)struct ttm_operation_ctx(9)struct ttm_lru_walk_arg(9)struct ttm_lru_walk(9)struct ttm_bo_shrink_flags(9)ttm_bo_reserve(9)ttm_bo_reserve_slowpath(9)ttm_bo_move_null(9)ttm_bo_unreserve(9)ttm_kmap_obj_virtual(9)struct ttm_bo_lru_cursor(9)
π« 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
- 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