summaryrefslogtreecommitdiffstats
path: root/src/platformsupport/platformsupport.pro
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@intel.com>2024-04-23 17:26:30 -0700
committerThiago Macieira <thiago.macieira@intel.com>2024-05-06 14:32:55 -0700
commit1b64b7c672a63d4221d7c6fd6f5a77e77979a6c6 (patch)
tree72ebf88fd02324bca48a2ec742703df8a140c2b2 /src/platformsupport/platformsupport.pro
parent62e0080a6a504e394bf55077e351e28c271a04fa (diff)
QResource: add support for duplicating mapped memory on Linux
This makes QResourceFileEngine avoid allocating heap memory in the implementation of QFile::map() calls with MapPrivateOption. We do that by asking the kernel to duplicate the mapping to the same memory pages, which increases our virtual memory space but doesn't initially take up any more RAM. We have to be careful to ensure the resulting mapping is copy-on-write and that this setting is independent of the original map's. The former is easy: the mremap() system call with MREMAP_DONTUNMAP only works on private memory blocks, so by definition any private + writable block is copy-on-write. The latter is slightly more difficult: if the original block was already writable, then the kernel could give us a new map to the exact same pages[*], which isn't exactly helpful. Therefore, we need to check if the QResourceRoot points to a private, read-only block. [*] in those conditions, mremap() is documented to replace the original mapping with a zero page, which means we have a near certainty of crashing, instead of accidentally, silently corrupting memory. Change-Id: I6979d02a7395405cbf23fffd17c90fb1f1612ed7 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/platformsupport/platformsupport.pro')
0 files changed, 0 insertions, 0 deletions