Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(932)

Unified Diff: physmem_alloc_analysis/physmem_alloc_analyzer.py

Issue 1217243006: Analyze contiguous physical memory chunks that mmap system call gives (Closed) Base URL: https://github.com/acutebridge/rowhammer-test.git@phymem_alloc
Patch Set: More clean up Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « physmem_alloc_analysis/make.sh ('k') | physmem_alloc_analysis/physmem_alloc_profiler.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: physmem_alloc_analysis/physmem_alloc_analyzer.py
diff --git a/physmem_alloc_analysis/physmem_alloc_analyzer.py b/physmem_alloc_analysis/physmem_alloc_analyzer.py
new file mode 100644
index 0000000000000000000000000000000000000000..3e3bd2135bd5a72b1c50322b1ffa1ba381da2f10
--- /dev/null
+++ b/physmem_alloc_analysis/physmem_alloc_analyzer.py
@@ -0,0 +1,47 @@
+# Copyright 2015, Google, Inc.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+
+def GetResultPfns(log_filename):
+ for line in open(log_filename):
+ parts = line.strip('\n')[:-1].split(' ');
+ yield [int(part, 16) for part in parts]
+
+
+def Main():
+ cont_count = {}
+ for pfns in GetResultPfns('physmem_alloc_results'):
+ i1 = 0
+ i2 = 0
+ while i2 < len(pfns):
+ while i2 + 1 < len(pfns) and pfns[i2+1] - pfns[i2] == 1:
+ i2 += 1
+ size = i2 - i1 + 1
+ cont_count.setdefault(size, 0)
+ cont_count[size] += 1
+ i2 += 1
+ i1 = i2
+
+ total_pages = 0
+ for size, count in cont_count.iteritems():
+ total_pages += size * count
+
+ sorted_by_size = sorted(cont_count.iteritems())
+ for size, count in sorted_by_size:
+ size_total = size * count
+ fraction = 1.0 * size_total / total_pages
+ print '%10d %10d %10d %10.2f' % (size, count, size_total, fraction)
+
+if __name__ == '__main__':
+ Main()
« no previous file with comments | « physmem_alloc_analysis/make.sh ('k') | physmem_alloc_analysis/physmem_alloc_profiler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698