diff options
author | Derek Bruening <bruening@google.com> | 2016-05-31 13:41:07 +0000 |
---|---|---|
committer | Derek Bruening <bruening@google.com> | 2016-05-31 13:41:07 +0000 |
commit | 53a14668413fab51e500cd3c26eea269e1f09749 (patch) | |
tree | c500b628005023a654a988757d375915e366033c /test/esan | |
parent | 0573d6c7f326a08eeff6e595fd77045a0210c32a (diff) |
[esan|wset] Iterate all memory to compute the total working set
Summary:
Adds iteration of all application memory in an efficient manner using
shadow faults. Shadow memory starts out inaccessible and we mark it
writable one page at a time on each fault when the instrumentation touches
it. This allows iteration over just the mapped shadow memory, saving
significant time.
Adds a process-end iteration and pretty-printing of the final result.
Adds a new test and updates the existing tests.
Reviewers: aizatsky, filcab
Subscribers: vitalybuka, zhaoqin, kcc, eugenis, llvm-commits, kubabrecka
Differential Revision: http://reviews.llvm.org/D20578
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@271277 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/esan')
-rw-r--r-- | test/esan/TestCases/workingset-memset.cpp | 3 | ||||
-rw-r--r-- | test/esan/TestCases/workingset-signal-posix.cpp | 1 | ||||
-rw-r--r-- | test/esan/TestCases/workingset-simple.cpp | 30 |
3 files changed, 32 insertions, 2 deletions
diff --git a/test/esan/TestCases/workingset-memset.cpp b/test/esan/TestCases/workingset-memset.cpp index a0c36e3ae..9c972ec7a 100644 --- a/test/esan/TestCases/workingset-memset.cpp +++ b/test/esan/TestCases/workingset-memset.cpp @@ -16,6 +16,5 @@ int main(int argc, char **argv) { memset((char *)p + 63*i, i, 63*i); munmap(p, size); return 0; - // FIXME: once the memory scan and size report is in place add it here. - // CHECK: {{.*}}EfficiencySanitizer is not finished: nothing yet to report + // CHECK: {{.*}} EfficiencySanitizer: the total working set size: 77 KB (12{{[0-9]+}} cache lines) } diff --git a/test/esan/TestCases/workingset-signal-posix.cpp b/test/esan/TestCases/workingset-signal-posix.cpp index c0245760c..fe7ced0cc 100644 --- a/test/esan/TestCases/workingset-signal-posix.cpp +++ b/test/esan/TestCases/workingset-signal-posix.cpp @@ -57,3 +57,4 @@ int main(int argc, char **argv) { // CHECK-NEXT: Past longjmp for signal // CHECK-NEXT: Handling SIGSEGV for sigaction // CHECK-NEXT: Past longjmp for sigaction +// CHECK: {{.*}} EfficiencySanitizer: the total working set size: {{[0-9][0-9][0-9]}} Bytes ({{[0-9][0-9]}} cache lines) diff --git a/test/esan/TestCases/workingset-simple.cpp b/test/esan/TestCases/workingset-simple.cpp new file mode 100644 index 000000000..c8a2d52e7 --- /dev/null +++ b/test/esan/TestCases/workingset-simple.cpp @@ -0,0 +1,30 @@ +// RUN: %clang_esan_wset -O0 %s -o %t 2>&1 +// RUN: %run %t 2>&1 | FileCheck %s + +#include <stdlib.h> +#include <string.h> +#include <sys/mman.h> +#include <assert.h> + +const int size = 0x1 << 25; // 523288 cache lines +const int line_size = 64; + +int main(int argc, char **argv) { + char *bufA = (char *)malloc(sizeof(char) * line_size); + char bufB[64]; + char *bufC = (char *)mmap(0, size, PROT_READ | PROT_WRITE, + MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); + bufA[0] = 0; + // This additional access to the same line should not increase the line + // count: but it's difficult to make a non-flaky test that measures the + // lines down to the ones digit so right now we're not really testing that. + // If we add a heap-only mode we may be able to be more precise. + bufA[1] = 0; + bufB[33] = 1; + for (int i = 0; i < size; i += line_size) + bufC[i] = 0; + free(bufA); + munmap(bufC, 0x4000); + // CHECK: {{.*}} EfficiencySanitizer: the total working set size: 32 MB (524{{[0-9][0-9][0-9]}} cache lines) + return 0; +} |