summaryrefslogtreecommitdiffstats
path: root/compiler-rt/lib/esan/esan.cpp
diff options
context:
space:
mode:
authorDerek Bruening <bruening@google.com>2016-05-31 13:41:07 +0000
committerDerek Bruening <bruening@google.com>2016-05-31 13:41:07 +0000
commit8ef3f0fa5b12b0903b4f331ee477efeb5df125d2 (patch)
treebc07f947397bf55a8028ef334bd1af2057531339 /compiler-rt/lib/esan/esan.cpp
parent659afd55fa09a1ce668a2483c23acdaf200cc6b9 (diff)
downloadbcm5719-llvm-8ef3f0fa5b12b0903b4f331ee477efeb5df125d2.tar.gz
bcm5719-llvm-8ef3f0fa5b12b0903b4f331ee477efeb5df125d2.zip
[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 llvm-svn: 271277
Diffstat (limited to 'compiler-rt/lib/esan/esan.cpp')
-rw-r--r--compiler-rt/lib/esan/esan.cpp12
1 files changed, 10 insertions, 2 deletions
diff --git a/compiler-rt/lib/esan/esan.cpp b/compiler-rt/lib/esan/esan.cpp
index c9629d65cd8..f0a4965184c 100644
--- a/compiler-rt/lib/esan/esan.cpp
+++ b/compiler-rt/lib/esan/esan.cpp
@@ -149,8 +149,16 @@ static void initializeShadow() {
VPrintf(1, "Shadow #%d: [%zx-%zx) (%zuGB)\n", i, ShadowStart, ShadowEnd,
(ShadowEnd - ShadowStart) >> 30);
- uptr Map = (uptr)MmapFixedNoReserve(ShadowStart, ShadowEnd - ShadowStart,
- "shadow");
+ uptr Map;
+ if (WhichTool == ESAN_WorkingSet) {
+ // We want to identify all shadow pages that are touched so we start
+ // out inaccessible.
+ Map = (uptr)MmapFixedNoAccess(ShadowStart, ShadowEnd- ShadowStart,
+ "shadow");
+ } else {
+ Map = (uptr)MmapFixedNoReserve(ShadowStart, ShadowEnd - ShadowStart,
+ "shadow");
+ }
if (Map != ShadowStart) {
Printf("FATAL: EfficiencySanitizer failed to map its shadow memory.\n");
Die();
OpenPOWER on IntegriCloud