From d169875423ad4576aeaa5ce72c6263372db232d7 Mon Sep 17 00:00:00 2001 From: Steve Atherton Date: Sun, 16 Oct 2022 19:55:07 -0700 Subject: [PATCH] Add a knob for whether to allow guard pages in memory allocations done via mmapInternal(). The knob defaults to false. --- flow/Knobs.cpp | 1 + flow/Platform.actor.cpp | 2 +- flow/include/flow/Knobs.h | 1 + 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/flow/Knobs.cpp b/flow/Knobs.cpp index 0e343af028..06b4e07355 100644 --- a/flow/Knobs.cpp +++ b/flow/Knobs.cpp @@ -73,6 +73,7 @@ void FlowKnobs::initialize(Randomize randomize, IsSimulated isSimulated) { init( RANDOMSEED_RETRY_LIMIT, 4 ); init( FAST_ALLOC_LOGGING_BYTES, 10e6 ); + init( FAST_ALLOC_ALLOW_GUARD_PAGES, false ); init( HUGE_ARENA_LOGGING_BYTES, 100e6 ); init( HUGE_ARENA_LOGGING_INTERVAL, 5.0 ); diff --git a/flow/Platform.actor.cpp b/flow/Platform.actor.cpp index c6d1d49139..409568e858 100644 --- a/flow/Platform.actor.cpp +++ b/flow/Platform.actor.cpp @@ -2126,7 +2126,7 @@ static void mprotectSafe(void* p, size_t s, int prot) { } static void* mmapInternal(size_t length, int flags, bool guardPages) { - if (guardPages) { + if (guardPages && FLOW_KNOBS->FAST_ALLOC_ALLOW_GUARD_PAGES) { static size_t pageSize = sysconf(_SC_PAGESIZE); length = RightAlign(length, pageSize); length += 2 * pageSize; // Map enough for the guard pages diff --git a/flow/include/flow/Knobs.h b/flow/include/flow/Knobs.h index ac2ef9c58a..d0e40dd67f 100644 --- a/flow/include/flow/Knobs.h +++ b/flow/include/flow/Knobs.h @@ -131,6 +131,7 @@ public: int RANDOMSEED_RETRY_LIMIT; double FAST_ALLOC_LOGGING_BYTES; + bool FAST_ALLOC_ALLOW_GUARD_PAGES; double HUGE_ARENA_LOGGING_BYTES; double HUGE_ARENA_LOGGING_INTERVAL;