OLD | NEW |
1 # Copyright 2013 The Chromium Authors. All rights reserved. | 1 # Copyright 2013 The Chromium Authors. All rights reserved. |
2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
5 import atexit | 5 import atexit |
6 import logging | 6 import logging |
7 | 7 |
8 from pylib import android_commands | 8 from pylib import android_commands |
9 from pylib.device import device_utils | 9 from pylib.device import device_utils |
10 | 10 |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
70 def _SetScalingGovernorInternal(self, value): | 70 def _SetScalingGovernorInternal(self, value): |
71 cpu_cores = ' '.join([str(x) for x in range(self._num_cpu_cores)]) | 71 cpu_cores = ' '.join([str(x) for x in range(self._num_cpu_cores)]) |
72 script = ('for CPU in %s; do\n' | 72 script = ('for CPU in %s; do\n' |
73 ' FILE="/sys/devices/system/cpu/cpu$CPU/cpufreq/scaling_governor"\n' | 73 ' FILE="/sys/devices/system/cpu/cpu$CPU/cpufreq/scaling_governor"\n' |
74 ' test -e $FILE && echo %s > $FILE\n' | 74 ' test -e $FILE && echo %s > $FILE\n' |
75 'done\n') % (cpu_cores, value) | 75 'done\n') % (cpu_cores, value) |
76 logging.info('Setting scaling governor mode: %s', value) | 76 logging.info('Setting scaling governor mode: %s', value) |
77 self._device.RunShellCommand(script, as_root=True) | 77 self._device.RunShellCommand(script, as_root=True) |
78 | 78 |
79 def _AllCpusAreOnline(self): | 79 def _AllCpusAreOnline(self): |
80 for cpu in range(self._num_cpu_cores): | 80 for cpu in range(1, self._num_cpu_cores): |
81 online_path = PerfControl._CPU_ONLINE_FMT % cpu | 81 online_path = PerfControl._CPU_ONLINE_FMT % cpu |
82 # TODO(epenner): Investigate why file may be missing | 82 # TODO(epenner): Investigate why file may be missing |
83 # (http://crbug.com/397118) | 83 # (http://crbug.com/397118) |
84 if not self._device.FileExists(online_path) or \ | 84 if not self._device.FileExists(online_path) or \ |
85 self._device.ReadFile(online_path)[0] == '0': | 85 self._device.ReadFile(online_path)[0] == '0': |
86 return False | 86 return False |
87 return True | 87 return True |
88 | 88 |
89 def _ForceAllCpusOnline(self, force_online): | 89 def _ForceAllCpusOnline(self, force_online): |
90 """Enable all CPUs on a device. | 90 """Enable all CPUs on a device. |
(...skipping 15 matching lines...) Expand all Loading... |
106 | 106 |
107 if not self._have_mpdecision and not self._AllCpusAreOnline(): | 107 if not self._have_mpdecision and not self._AllCpusAreOnline(): |
108 logging.warning('Unexpected cpu hot plugging detected.') | 108 logging.warning('Unexpected cpu hot plugging detected.') |
109 | 109 |
110 if not force_online: | 110 if not force_online: |
111 return | 111 return |
112 | 112 |
113 for cpu in range(self._num_cpu_cores): | 113 for cpu in range(self._num_cpu_cores): |
114 online_path = PerfControl._CPU_ONLINE_FMT % cpu | 114 online_path = PerfControl._CPU_ONLINE_FMT % cpu |
115 self._device.WriteFile(online_path, '1', as_root=True) | 115 self._device.WriteFile(online_path, '1', as_root=True) |
OLD | NEW |