drm_gem_handle_create_tail(9)
π drm_gem_handle_create_tail(9) π
okay bestie so we're in the Kernel API Manual today, and this one is literally a kernel-internals page β drm_gem_handle_create_tail(9). it's the internal handle-maker. the tail-end bestie. the one that does the messy part. let's get into it π
β¨ SYNOPSIS β¨
int drm_gem_handle_create_tail (struct drm_file *file_priv , struct
drm_gem_object *obj , u32 *handlep );
that's the whole signature, no cap. takes three things, hands you back an int. π
π«Ά ARGUMENTS π«Ά
file_privβ the drm file-private structure you're registering the handle for. this is whose handle it becomes πobjβ the object getting registered. the actual star of the show β¨handlepβ a pointer where the newly created handle gets handed back to whoever called. it's giving "you get a handle, you get a handle" π
πΈ DESCRIPTION πΈ
okay so listen. this function expects the drm_device.object_name_lock to already be held when you call it β you hold it, not her β and she will drop it before returning. like, she takes the lock from your hands and puts it away on her way out the door πͺβ¨ and the whole reason is to dodge races when you're establishing new handles while importing an object from either an flink name or a dma-buf. race conditions are NOT the vibe, so we prevent them π§
π¨ and bestie, important: handles must be released again through drm_gem_handle_delete. not optional. no skipping. that's how it stays clean π
so when does that releasing happen? two ways, and both are the system doing it for you-ish:
- when userspace closes
file_privβ then all attached handles get released π - through the
GEM_CLOSEioctl, for individual handles π
π SEE ALSO π
the whole friend group, fr fr. kernel file ./drivers/gpu/drm/drm_gem.c and then this absolutely iconic list:
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(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_lru_scan(9)drm_gem_evict_locked(9)
likeβ¦ that's the entire group chat and every single one of them is relevant. read them. iykyk π¦
π that's the whole page bestie, go forth and make handles responsibly π
this iconic little page lives in ./drivers/gpu/drm, dated October 2026 β and drm_gem_handle_create_tail(9) will see you next time, mwah ππΈ
π¦ 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