drm_gem_get_pages(9)
π drm_gem_get_pages π
okay so bestie, welcome to drm_gem_get_pages(9) from the Kernel API Manual β we're hanging out in the DRM/GEM corner of the kernel today and honestly? it's giving "I majored in page arrays" and I'm obsessed π
β¨ NAME β¨
drm_gem_get_pages β the helper bestie that allocates backing pages for a GEM object straight out of shmem π¦
β¨ SYNOPSIS β¨
struct page ** drm_gem_get_pages (struct drm_gem_object *obj );
β¨ ARGUMENTS β¨
objβ the obj in question, aka the GEM object you're doing all this for. that's the whole vibe check right there π
β¨ DESCRIPTION β¨
so what does this actually do? it reads the page-array of the shmem-backing storage for the gem object you passed in, and hands you back an array of pages. that's it, that's the tea β¨
and like β if a page isn't allocated yet, or it got swapped out? no worries, it will allocate it / swap it back in for you. but heads up, bestie: the whole object is covered by that page-array, and it gets pinned in memory. the entire thing. periodt π
when you're done with your little page-array moment, use drm_gem_put_pages to release the array and unpin all the pages. don't just ghost them, okay? π«Ά
this function uses the GFP-mask that's set on the shmem-mapping β you know, the one from mapping_set_gfp_mask. so if you need other GFP-masks, too bad, you're doing those allocations yourself. your mask, your problem, your character arc π
β οΈ important lore drop: you are not allowed to change gfp-zones during runtime. like, at all. meaningshmem_read_mapping_page_gfpmust be called with the samegfp_zone(gfp)that was set during initialization. if you have special zone constraints, set them afterdrm_gem_object_initviamapping_set_gfp_maskβ and don't stress, shmem-core takes care of keeping pages in the required zone during swap-in π§
and the big one: this function is only valid on objects initialized with drm_gem_object_init. it does not work for objects initialized with drm_gem_private_object_init only. not even a little bit. no cap π
β¨ SEE ALSO β¨
Kernel file ./drivers/gpu/drm/drm_gem.c β plus the whole friend group, all together now π:
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_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 whole page, bestie!! π this little number lives in ./drivers/gpu/drm and it's dated October 2026 β go forth, allocate those backing pages, and remember to drm_gem_put_pages when you're done πβ¨π
π¦ 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