drm_gem_get_unmapped_area(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… 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 it
  • pgoff β€” 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:


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