i915_gem_gtt_insert(9)
π i915_gem_gtt_insert β the Kernel API Manual moment β¨
okay so bestie, brace yourself: this is i915_gem_gtt_insert(9) from the kernel's own API manual, and it's lowkey the function that finds your node a home inside an address_space (the GTT). no cap. let's get into it π«Ά
πΈ SYNOPSIS πΈ
int i915_gem_gtt_insert (struct i915_address_space *vm , struct
i915_gem_ww_ctx *ww , struct drm_mm_node *node , u64 size , u64
alignment , unsigned long color , u64 start , u64 end , unsigned int
flags );
like, literally five different types in one signature and every single one of them matters. main character energy fr fr π
π ARGUMENTS π
vmβ thestruct i915_address_space. this is the space we're inserting into, the whole vibe check of the operation β¨wwβ An optionalstruct i915_gem_ww_ctx. optional!! so it can be a whole thing or it can be nothing, she's flexible πnodeβ thestruct drm_mm_node, and typically you're passingi915_vma.nodehere. that's the actual thing getting placed, like the lil nugget we're finding room for πsizeβ how much space to allocate inside the GTT. and listen: it must be#I915_GTT_PAGE_SIZEaligned. not kinda aligned, not almost, aligned. periodt π₯alignmentβ required alignment of the starting offset. may be0, but if you do specify it, it must be a power-of-two and at least#I915_GTT_MIN_ALIGNMENT. two rules, no exceptions, iykyk πcolorβ color to apply to node. yes really, colors, we'll get to why in a sec πstartβ start of any range restriction inside GTT (0for all). must be#I915_GTT_PAGE_SIZEaligned. that aligned thing again, she's consistent πendβ end of any range restriction inside GTT (U64_MAXfor all). must be#I915_GTT_PAGE_SIZEaligned if notU64_MAX. read that conditional twice bestie πflagsβ control search and eviction behaviour. this is where you tell her how spicy to be πΆοΈ
π¦ DESCRIPTION π¦
so first things first: i915_gem_gtt_insert goes hunting for an available hole it can insert the node into. shopping spree, but for address space ποΈ
the hole's address gets aligned to alignment, and then its size must fit entirely within the [start, end] bounds. no half-in-half-out situations, it's all or nothing, we don't do situationships here π€
now β the nodes on either side of that hole? they must match color, or else a guard page gets inserted between the two nodes (or, alternative ending, the node gets evicted). it's giving "you can sit with us but only if you match the aesthetic" π
and if no suitable hole pops up at all? watch this:
- first, a victim is randomly selected and tested for eviction. literally random. chaotic but iconic π²
- otherwise, the LRU list of objects within the GTT gets scanned to find the first set of replacement nodes that can create the hole π
those old overlapping nodes get evicted from the GTT, which means β and this is the important part β they must be rebound before any future use. so write that down π
also: any node that's currently pinned cannot be evicted. see i915_vma_pin. pinned means pinned, she said no π«
similar situation: if the node's VMA is currently active and #PIN_NONBLOCK is specified, that node is also skipped when it's searching for an eviction candidate. skipped!! π
and if you want the gory details on the whole eviction algorithm, go read i915_gem_evict_something β that's where the mess lives π
β RETURN β
0on success π slay-ENOSPCif no suitable hole is found π no space, no vibes-EINTRif it's asked to wait for eviction and gets interrupted π«
π SEE ALSO π
- Kernel file
./drivers/gpu/drm/i915/i915_gem_gtt.c i915_gem_gtt_reserve(9)
okay and finally, the credits moment because we respect the source π«Ά this whole thing lives in ./drivers/gpu/drm/i915, dated October 2026 in the Kernel API Manual. go forth and insert those nodes bestie, you're gonna ate πβ¨ππ¦
π¦ 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