diff options
| author | Kostya Kortchinsky <kostyak@google.com> | 2017-12-13 20:41:35 +0000 |
|---|---|---|
| committer | Kostya Kortchinsky <kostyak@google.com> | 2017-12-13 20:41:35 +0000 |
| commit | f22f5fe9103be03cb93ba4587cec3e6af71ef784 (patch) | |
| tree | 0d9a21b3327b5cc35840c725d88ee3af18b7f494 /compiler-rt/lib/scudo/scudo_allocator.cpp | |
| parent | 51d7798237ba9ecbb4596f8399506485e548290f (diff) | |
| download | bcm5719-llvm-f22f5fe9103be03cb93ba4587cec3e6af71ef784.tar.gz bcm5719-llvm-f22f5fe9103be03cb93ba4587cec3e6af71ef784.zip | |
[scudo] Adding a public Scudo interface
Summary:
The first and only function to start with allows to set the soft or hard RSS
limit at runtime. Add associated tests.
Reviewers: alekseyshl
Reviewed By: alekseyshl
Subscribers: mgorny, #sanitizers, llvm-commits
Differential Revision: https://reviews.llvm.org/D41128
llvm-svn: 320611
Diffstat (limited to 'compiler-rt/lib/scudo/scudo_allocator.cpp')
| -rw-r--r-- | compiler-rt/lib/scudo/scudo_allocator.cpp | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/compiler-rt/lib/scudo/scudo_allocator.cpp b/compiler-rt/lib/scudo/scudo_allocator.cpp index 47804c44c4f..19c89810a3e 100644 --- a/compiler-rt/lib/scudo/scudo_allocator.cpp +++ b/compiler-rt/lib/scudo/scudo_allocator.cpp @@ -597,6 +597,14 @@ struct ScudoAllocator { initThreadMaybe(); return FailureHandler::OnBadRequest(); } + + void setRssLimit(uptr LimitMb, bool HardLimit) { + if (HardLimit) + HardRssLimitMb = LimitMb; + else + SoftRssLimitMb = LimitMb; + CheckRssLimit = HardRssLimitMb || SoftRssLimitMb; + } }; static ScudoAllocator Instance(LINKER_INITIALIZED); @@ -726,3 +734,13 @@ int __sanitizer_get_ownership(const void *Ptr) { uptr __sanitizer_get_allocated_size(const void *Ptr) { return Instance.getUsableSize(Ptr); } + +// Interface functions + +extern "C" { +void __scudo_set_rss_limit(unsigned long LimitMb, int HardLimit) { // NOLINT + if (!SCUDO_CAN_USE_PUBLIC_INTERFACE) + return; + Instance.setRssLimit(LimitMb, !!HardLimit); +} +} // extern "C" |

