]> git.ipfire.org Git - thirdparty/linux.git/commit
drm/gem-shmem: Track folio accessed/dirty status in mmap
authorThomas Zimmermann <tzimmermann@suse.de>
Fri, 27 Feb 2026 11:42:10 +0000 (12:42 +0100)
committerThomas Zimmermann <tzimmermann@suse.de>
Wed, 11 Mar 2026 08:33:43 +0000 (09:33 +0100)
commit28e3918179aa75cfd4490b3b0281496ed91d829a
tree7746c70021ed238ac81b2c0bf44bc2c4ae7089ac
parent06f3662cb3ba95aa895c1036910555a81c8bcd95
drm/gem-shmem: Track folio accessed/dirty status in mmap

Invoke folio_mark_accessed() in mmap page faults to add the folio to
the memory manager's LRU list. Userspace invokes mmap to get the memory
for software rendering. Compositors do the same when creating the final
on-screen image, so keeping the pages in LRU makes sense. Avoids paging
out graphics buffers when under memory pressure.

In pfn_mkwrite, further invoke the folio_mark_dirty() to add the folio
for writeback should the underlying file be paged out from system memory.
This rarely happens in practice, yet it would corrupt the buffer content.

This has little effect on a system's hardware-accelerated rendering, which
only mmaps for an initial setup of textures, meshes, shaders, etc.

v4:
- test for VM_FAULT_NOPAGE before marking folio as accessed (Boris)
- test page-array bounds in mkwrite handler (Boris)
v3:
- rewrite for VM_PFNMAP
v2:
- adapt to changes in drm_gem_shmem_try_mmap_pmd()

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com>
Link: https://patch.msgid.link/20260227114509.165572-6-tzimmermann@suse.de
drivers/gpu/drm/drm_gem_shmem_helper.c