drm_gem_lru_scan(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’– drm_gem_lru_scan(9) β€” the kernel API manual, but make it cute πŸ’–

okay so bestie, we're in the Kernel API Manual and this one is called drm_gem_lru_scan. it's a helper to implement shrinker.scan_objects, no cap. let's get into it πŸŽ€


✨ NAME ✨

drm_gem_lru_scan β€” a little helper that does the shrinker.scan_objects thing for you 🫢


🌸 SYNOPSIS 🌸

unsigned long drm_gem_lru_scan (struct drm_device *dev , struct
drm_gem_lru *lru , unsigned int nr_to_scan , unsigned long *remaining ,
bool (*shrink)(struct drm_gem_object *obj, struct ww_acquire_ctx
*ticket) , struct ww_acquire_ctx *ticket );

πŸ¦‹ ARGUMENTS πŸ¦‹

  • dev β€” the DRM device this LRU belongs to. it's giving "who's your parent" energy πŸ‘‘
  • lru β€” the LRU we're scanning. yes, that LRU πŸ’…
  • nr_to_scan β€” how many pages we're gonna try to reclaim. it's the page count goal, periodt ✨
  • remaining β€” the number of pages left to reclaim, and the caller is supposed to initialize this one. don't forget, bestie 😭
  • shrink β€” the callback that tries to shrink/reclaim the object. main character energy fr πŸ”₯
  • ticket β€” an optional ww_acquire_ctx context to use for locking. optional, so you can skip it if you want πŸ’€

🌈 DESCRIPTION 🌈

okay so if the shrink callback succeeds, the driver is expected to move the object out of this LRU. that's the vibe check β€” callback pops off, object leaves πŸ’–

and if the LRU possibly contains active buffers, it's the responsibility of the shrink callback to check for that (like, dma_resv_test_signaled) or, if necessary, block until the buffer becomes idle. yes, that's on the callback, not on this function, sorry bestie πŸ™ˆ


πŸ‘‘ SEE ALSO πŸ‘‘

Kernel file ./drivers/gpu/drm/drm_gem.c plus the whole friend group:

drm_gem_huge_mnt_create(9),
drm_gem_init(9),
drm_gem_object_init(9),
drm_gem_private_object_init(9),
drm_gem_private_object_fini(9),
drm_gem_object_handle_get_if_exists_unlocked(9),
drm_gem_object_handle_free(9),
drm_gem_object_handle_put_unlocked(9),
drm_gem_handle_delete(9),
drm_gem_dumb_map_offset(9),
drm_gem_handle_create_tail(9),
drm_gem_handle_create(9),
drm_gem_free_mmap_offset(9),
drm_gem_create_mmap_offset_size(9),
drm_gem_create_mmap_offset(9),
drm_gem_get_pages(9),
drm_gem_put_pages(9),
drm_gem_objects_lookup(9),
drm_gem_object_lookup(9),
drm_gem_dma_resv_wait(9),
drm_gem_open(9),
drm_gem_release(9),
drm_gem_object_release(9),
drm_gem_object_free(9),
drm_gem_vm_open(9),
drm_gem_vm_close(9),
drm_gem_mmap_obj(9),
drm_gem_get_unmapped_area(9),
drm_gem_mmap(9),
drm_gem_lock_reservations(9),
drm_gem_lru_init(9),
drm_gem_lru_remove(9),
drm_gem_lru_move_tail_locked(9),
drm_gem_lru_move_tail(9),
drm_gem_evict_locked(9)

literally the whole squad, iykyk πŸ’œ


ngl this whole thing lives at ./drivers/gpu/drm and it's from October 2026, and it's the drm_gem_lru_scan(9) page. slay. that's the whole manpage bestie, mwah πŸ’‹βœ¨πŸŽ€πŸ¦‹πŸŒΈ
πŸ“¦ where this page comes from