diff options
| author | Florian Fischer <florian.fl.fischer@fau.de> | 2019-08-11 19:24:58 +0200 |
|---|---|---|
| committer | Florian Fischer <florian.fl.fischer@fau.de> | 2019-08-11 19:24:58 +0200 |
| commit | 71ae933f5af528f9a8cda8f3066e61f8dddb8559 (patch) | |
| tree | 6ae45967806d663f3e15ed990c8bec7a0fa1cc78 | |
| parent | 070731ecd8a80c23b9745020a570ad385ea14aee (diff) | |
| download | allocbench-71ae933f5af528f9a8cda8f3066e61f8dddb8559.tar.gz allocbench-71ae933f5af528f9a8cda8f3066e61f8dddb8559.zip | |
check if vm.overcommit_memory is set before building scalloc
Scalloc checks if it is allowed to overcommit memory at runtime and
aborts. Calling abort() does not set an exit code and therefore does not
trigger allocbenchs failure handling.
To prevent crashing at runtime we now fail early.
| -rw-r--r-- | src/allocators/scalloc.py | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/allocators/scalloc.py b/src/allocators/scalloc.py index 3314fc4..f2f15b4 100644 --- a/src/allocators/scalloc.py +++ b/src/allocators/scalloc.py @@ -1,4 +1,5 @@ from src.allocator import Allocator, Allocator_Sources, library_path +from src.util import print_error version = "v1.0.0" @@ -26,5 +27,12 @@ class Scalloc (Allocator): super().__init__(name, **kwargs) + def build(self): + with open("/proc/sys/vm/overcommit_memory", "r") as f: + if f.read()[0] != "1": + print_error("Scalloc needs permission to overcommit_memory") + raise AssertionError("vm.overcommit_memory not set") + return super().build() + scalloc = Scalloc("scalloc", color="xkcd:magenta") |
