diff options
Diffstat (limited to 'src/util/HugeAllocator.hxx')
-rw-r--r-- | src/util/HugeAllocator.hxx | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/util/HugeAllocator.hxx b/src/util/HugeAllocator.hxx index 46b65e29a..421cf7da4 100644 --- a/src/util/HugeAllocator.hxx +++ b/src/util/HugeAllocator.hxx @@ -57,6 +57,13 @@ void HugeFree(void *p, size_t size) noexcept; /** + * Control whether this allocation is copied to newly forked child + * processes. Disabling that makes forking a little bit cheaper. + */ +void +HugeForkCow(void *p, size_t size, bool enable) noexcept; + +/** * Discard any data stored in the allocation and give the memory back * to the kernel. After returning, the allocation still exists and * can be reused at any time, but its contents are undefined. @@ -81,6 +88,11 @@ HugeFree(void *p, gcc_unused size_t size) noexcept } static inline void +HugeForkCow(void *, size_t, bool) noexcept +{ +} + +static inline void HugeDiscard(void *p, size_t size) noexcept { VirtualAlloc(p, size, MEM_RESET, PAGE_NOACCESS); @@ -107,6 +119,11 @@ HugeFree(void *_p, size_t) noexcept } static inline void +HugeForkCow(void *, size_t, bool) noexcept +{ +} + +static inline void HugeDiscard(void *, size_t) noexcept { } @@ -140,6 +157,10 @@ public: return *this; } + void ForkCow(bool enable) noexcept { + HugeForkCow(data, size, enable); + } + void Discard() noexcept { HugeDiscard(data, size); } |