drm_gem_get_unmapped_area(9)
π drm_gem_get_unmapped_area(9) π
okay bestie, welcome to the Kernel API Manual β yes we're in kernel-land today, and yes this one's a little niche but it's actually so good once you get it. sit with me π«Ά
β¨ NAME β¨
drm_gem_get_unmapped_area β the get-memory-mapping-region routine for GEM objects. it literally finds you a place to map your GEM stuff. iconic behavior π
πΈ SYNOPSIS πΈ
unsigned long drm_gem_get_unmapped_area (struct file *filp , unsigned
long uaddr , unsigned long len , unsigned long pgoff , unsigned long
flags );
no cap, that's the whole signature. arguments below, keep scrolling π
π ARGUMENTS π
filpβ the DRM file pointer. yeah, the file, we love her πuaddrβ user address hint. it's a hint, she's not obligated π«Άlenβ mapping length. how much space we're asking for, be honest about itpgoffβ offset, measured in pages (important!! pages not bytes, iykyk) πflagsβ mapping flags. the vibe settings for the mapping β¨
π¦ DESCRIPTION π¦
so here's the situation. if a driver supports GEM object mapping, then before you ever end up in drm_gem_mmap, mmap calls on the DRM file descriptor will first try to find a free linear address space that's big enough for a mapping. that's the whole errand. literally just finding a spot πΊοΈ
and because GEM objects are backed by shmem buffers, this should preferably be handled by the shmem virtual memory filesystem β she's the one who can appropriately align addresses to huge page sizes when needed. like, that's her speciality, let her cook ππ₯
then: look up the GEM object based on the offset you passed in (vma->vm_pgoff will contain the fake offset we created β yes, fake, that's the word, don't come for me π) and call shmem_get_unmapped_area with the right file pointer.
and if a GEM object is not available at the given offset, or if the caller is not granted access to it? no drama, we fall back to mm_get_unmapped_area. plan B is still a plan bestie π
β SEE ALSO β
kernel file ./drivers/gpu/drm/drm_gem.c β go read her, she's the main character of this whole directory π
and like the entire extended friend group, all here:
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_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)
mwah π that's the page. sourced from ./drivers/gpu/drm, dated October 2026, filed under drm_gem_get_unmapped_area(9) β go forth and map responsibly, 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