drm_gem_cre..._offset_size(9)
β¨ drm_gem_cre..._offset_size(9) β¨
okay bestie, welcome to the Kernel API Manual π you're about to read all about drm_gem_create_mmap_offset_size and honestly? it's a little baddie of a function. let's get into it π«Ά
πΈ NAME πΈ
drm_gem_create_mmap_offset_size β create a fake mmap offset for an object π
like yes it's fake, that's the whole point, don't @ me
β SYNOPSIS β
int drm_gem_create_mmap_offset_size (struct drm_gem_object *obj , size_t
size );
that's it, that's the whole signature, she's lowkey compact β¨
π ARGUMENTS π
objβ the obj in question π like the actual GEM object you're doing this forsizeβ the virtual size π¦ (not the physical size, keep that distinction in your head bestie, it matters)
π DESCRIPTION π
so here's the vibe: GEM memory mapping works by handing back to userspace a fake mmap offset β and yes, "fake" is the technical term, the kernel said what it said π β which userspace can then use in a subsequent mmap(2) call. then the DRM core code looks up the object based on that offset and sets up all the various memory mapping structures. it's giving matchmaker energy fr fr π
this routine allocates and attaches a fake offset for obj, specifically in the cases where the virtual size differs from the physical size (ie. drm_gem_object.size). otherwise?? just use drm_gem_create_mmap_offset, it's that simple bestie β¨
and here's the iconic part: this function is idempotent π and handles an already allocated mmap offset transparently. drivers do not need to check for this case. like at all. not even a little bit. she said "I got it" and she meant it π periodt
ngl this is the kind of function that just works and doesn't make you think about it, which is the highest compliment I can give a kernel API π
π¦ SEE ALSO π¦
Kernel file ./drivers/gpu/drm/drm_gem.c β and the whole squad, in order, no skips, we're doing the full roster π€:
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(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)
and that's the page!! π this little love letter to the DRM core came from the source tree at ./drivers/gpu/drm, dated October 2026, and it lives forever under the name drm_gem_cre..._offset_size(9) β¨ mwah, go read your kernel docs bestie ππ§ββοΈ
π¦ 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