DRM_IOCTL_GEM_CLOSE(9)
π NAME π
Okay so this is the DRM_IOCTL_GEM_CLOSE(9) page from the Kernel API Manual, and it is literally about closing a GEM handle. Bestie, the whole thing is a lifetime-management PSA and I'm obsessed. π
DRM_IOCTL_GEM_CLOSEβ Close a GEM handle. Periodt. β¨
β¨ SYNOPSIS β¨
DRM_IOCTL_GEM_CLOSE
π¦ DESCRIPTION π¦
Okay gather round, because this is the important part: GEM handles are not reference-counted by the kernel. Like, at all. User-space is responsible for managing their lifetime, so that's your job β not the kernel's. π
Example time π: if user-space imports the same memory object twice on the same DRM file description, the same GEM handle is returned by both imports, and user-space needs to ensure DRM_IOCTL_GEM_CLOSE is performed once only. Once. Not twice. That's the whole assignment, bestie. π
The same situation can happen when a memory object is allocated, then exported and imported again on the same DRM file description. Same energy, same once-only rule. π«Ά
But plot twist β¨: the DRM_IOCTL_MODE_GETFB2 IOCTL is an exception and always returns fresh new GEM handles even if an existing GEM handle already refers to the same memory object before the IOCTL is performed. Iconic exception behaviour, honestly. π
β οΈ warning bestie: the kernel does not ref-count these handles, so lifetime management is 100% user-space's problem. Ensure DRM_IOCTL_GEM_CLOSE is performed once only β that's the vibe check. π
π SEE ALSO π
These are all the other pages and symbols in the source list β every single one, no skipping, iykyk π«Ά:
- Kernel file
./tools/perf/trace/beauty/include/uapi/drm/drm.hβstruct drm_gem_close(9) struct drm_gem_flink(9)struct drm_gem_open(9)struct drm_gem_change_handle(9)DRM_CAP_DUMB_BUFFER(9)DRM_CAP_VBLANK_HIGH_CRTC(9)DRM_CAP_DUMB_PREFERRED_DEPTH(9)DRM_CAP_DUMB_PREFER_SHADOW(9)DRM_CAP_PRIME(9)DRM_PRIME_CAP_IMPORT(9)DRM_PRIME_CAP_EXPORT(9)DRM_CAP_TIMESTAMP_MONOTONIC(9)DRM_CAP_ASYNC_PAGE_FLIP(9)DRM_CAP_CURSOR_WIDTH(9)DRM_CAP_CURSOR_HEIGHT(9)DRM_CAP_ADDFB2_MODIFIERS(9)DRM_CAP_PAGE_FLIP_TARGET(9)DRM_CAP_CRTC_IN_VBLANK_EVENT(9)DRM_CAP_SYNCOBJ(9)DRM_CAP_SYNCOBJ_TIMELINE(9)DRM_CAP_ATOMIC_ASYNC_PAGE_FLIP(9)DRM_CLIENT_CAP_STEREO_3D(9)DRM_CLIENT_CAP_UNIVERSAL_PLANES(9)DRM_CLIENT_CAP_ATOMIC(9)DRM_CLIENT_CAP_ASPECT_RATIO(9)DRM_CLIENT_CAP_WRITEBACK_CONNECTORS(9)DRM_CLIENT_CAP_CURSOR_PLANE_HOTSPOT(9)DRM_CLIENT_CAP_PLANE_COLOR_PIPELINE(9)struct drm_syncobj_eventfd(9)DRM_IOCTL_PRIME_HANDLE_TO_FD(9)DRM_IOCTL_PRIME_FD_TO_HANDLE(9)DRM_IOCTL_MODE_RMFB(9)DRM_IOCTL_MODE_CREATE_DUMB(9)DRM_IOCTL_MODE_GETFB2(9)DRM_IOCTL_SYNCOBJ_EVENTFD(9)DRM_IOCTL_MODE_CLOSEFB(9)DRM_IOCTL_SET_CLIENT_NAME(9)DRM_IOCTL_GEM_CHANGE_HANDLE(9)struct drm_event(9)DRM_EVENT_VBLANK(9)DRM_EVENT_FLIP_COMPLETE(9)DRM_EVENT_CRTC_SEQUENCE(9)
k bye ily π«Ά β this lil page's source/version footer says ./tools/perf/trace/beauty/incl... and the date is October 2026, with the tag DRM_IOCTL_GEM_CLOSE(9) doing its main character thing. 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