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

Unified Diff: build/android/pylib/perf/perf_control.py

Issue 316143002: telemetry: Improve perf profiler (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Poll quicker. Created 6 years, 6 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 | « build/android/chrome_profiler/perf_controller.py ('k') | build/android/pylib/perf/perf_control_unittest.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: build/android/pylib/perf/perf_control.py
diff --git a/build/android/pylib/perf/perf_control.py b/build/android/pylib/perf/perf_control.py
index 92aaa2433012499b4b78ab5682b557fc69eae604..cde12ec9612b7933d88544124965364239b821df 100644
--- a/build/android/pylib/perf/perf_control.py
+++ b/build/android/pylib/perf/perf_control.py
@@ -2,8 +2,9 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
-
import logging
+import time
+
from pylib import android_commands
from pylib.device import device_utils
@@ -58,3 +59,38 @@ class PerfControl(object):
self._device.old_interface.SetProtectedFileContents(
scaling_governor_file, value)
+ def ForceAllCpusOnline(self, force_online):
+ """Force all CPUs on a device to be online.
+
+ Force every CPU core on an Android device to remain online, or return the
+ cores under system power management control. This is needed to work around
+ a bug in perf which makes it unable to record samples from CPUs that become
+ online when recording is already underway.
+
+ Args:
+ force_online: True to set all CPUs online, False to return them under
+ system power management control.
+ """
+ def ForceCpuOnline(online_path):
+ script = 'chmod 644 {0}; echo 1 > {0}; chmod 444 {0}'.format(online_path)
+ self._device.old_interface.RunShellCommandWithSU(script)
+ return self._device.old_interface.GetFileContents(online_path)[0] == '1'
+
+ def ResetCpu(online_path):
+ self._device.old_interface.RunShellCommandWithSU(
+ 'chmod 644 %s' % online_path)
+
+ def WaitFor(condition):
+ for _ in range(100):
+ if condition():
+ return
+ time.sleep(0.1)
+ raise RuntimeError('Timed out')
+
+ cpu_online_files = self._device.old_interface.RunShellCommand(
+ 'ls -d /sys/devices/system/cpu/cpu[0-9]*/online')
+ for online_path in cpu_online_files:
+ if force_online:
+ WaitFor(lambda: ForceCpuOnline(online_path))
+ else:
+ ResetCpu(online_path)
« no previous file with comments | « build/android/chrome_profiler/perf_controller.py ('k') | build/android/pylib/perf/perf_control_unittest.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698