[compiler-rt] [scudo] Enable "Delayed release to OS" feature for Android (PR #65942)

via llvm-commits llvm-commits at lists.llvm.org
Mon Sep 11 02:43:16 PDT 2023


https://github.com/andersdellien-arm created https://github.com/llvm/llvm-project/pull/65942:

Instead of immediately releasing any mapped memory back to the OS (via overlapping mmaps when MTE is enabled, madvise when not), the memory is retained and only given back after a configurable interval (5000 ms for now)

This change gives a slight performance increase in two ways:
* When MTE is enabled, mappings are made non-accessible with one mprotect instead of two mmaps
* If the mapping is reused within the specified time interval, the contents are retained. This reduces the number of page faults.

>From d36e78bc072c3d2ffd3b3ab418c8aabc6fffaa5e Mon Sep 17 00:00:00 2001
From: Anders Dellien <anders.dellien at arm.com>
Date: Tue, 22 Aug 2023 10:12:03 +0100
Subject: [PATCH] [scudo] Enable "Delayed release to OS" feature for Android

Instead of immediately releasing any mapped memory back to the
OS (via overlapping mmaps when MTE is enabled, madvise when not),
the memory is retained and only given back after a configurable
interval (5000 ms for now)

This change gives a slight performance increase in two ways:
* When MTE is enabled, mappings are made non-accessible with one
  mprotect instead of two mmaps
* If the mapping is reused within the specified time interval,
  the contents are retained. This reduces the number of page faults.

Signed-off-by: Anders Dellien <anders.dellien at arm.com>
---
 compiler-rt/lib/scudo/standalone/flags.inc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/compiler-rt/lib/scudo/standalone/flags.inc b/compiler-rt/lib/scudo/standalone/flags.inc
index 60aeb1f1df570ac..5c4b63f939fd0b3 100644
--- a/compiler-rt/lib/scudo/standalone/flags.inc
+++ b/compiler-rt/lib/scudo/standalone/flags.inc
@@ -42,7 +42,7 @@ SCUDO_FLAG(bool, may_return_null, true,
            "returning NULL in otherwise non-fatal error scenarios, eg: OOM, "
            "invalid allocation alignments, etc.")
 
-SCUDO_FLAG(int, release_to_os_interval_ms, SCUDO_ANDROID ? INT32_MIN : 5000,
+SCUDO_FLAG(int, release_to_os_interval_ms, 5000,
            "Interval (in milliseconds) at which to attempt release of unused "
            "memory to the OS. Negative values disable the feature.")
 



More information about the llvm-commits mailing list