From 5c5f1d096c3a2a6cb8fb3dc5cb3efad5782c1d78 Mon Sep 17 00:00:00 2001 From: Daniel Eklöf Date: Tue, 24 Mar 2020 17:46:48 +0100 Subject: shm: scroll: implement offset wrap-around * Impose a maximum memfd size limit. In theory, this can be 2GB (wl_shm_create_pool() is the limiting factor - its size argument is an int32_t). For now, use 256MB. This is mainly to reduce the amount of virtual address space used by the compositor, which keeps at least one mmapping (of the entire memfd) around. One mmapping *per terminal window* that is. Given that we have 128TB with 48-bit virtual addresses, we could probably bump this to 2GB without any issues. However, 256MB should be enough. TODO: check how much we typically move the offset when scrolling in a fullscreen window on a 4K monitor. 256MB may turn out to be too small. On 32-bit shm_scroll() is completely disabled. There simply isn't enough address space. * Wrapping is done by moving the offset to "the other end" of the memfd, and copying the buffer contents to the new, wrapped offset. The "normal" scrolling code then does the actual scrolling. This means we'll re-instantiate all objects twice when wrapping. --- shm.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'shm.h') diff --git a/shm.h b/shm.h index 6637182c..d67b3567 100644 --- a/shm.h +++ b/shm.h @@ -2,6 +2,7 @@ #include #include +#include #include #include @@ -24,7 +25,7 @@ struct buffer { int fd; /* memfd */ void *real_mmapped; /* Address returned from mmap */ size_t mmap_size; /* Size of mmap (>= size) */ - size_t offset; /* Offset into memfd where data begins */ + off_t offset; /* Offset into memfd where data begins */ bool purge; /* True if this buffer should be destroyed */ }; -- cgit v1.3