| 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 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 61 'GT-I9300': 'pegasusq', | 61 'GT-I9300': 'pegasusq', |
| 62 'Galaxy Nexus': 'interactive', | 62 'Galaxy Nexus': 'interactive', |
| 63 'Nexus 4': 'ondemand', | 63 'Nexus 4': 'ondemand', |
| 64 'Nexus 7': 'interactive', | 64 'Nexus 7': 'interactive', |
| 65 'Nexus 10': 'interactive' | 65 'Nexus 10': 'interactive' |
| 66 }.get(product_model, 'ondemand') | 66 }.get(product_model, 'ondemand') |
| 67 self._SetScalingGovernorInternal(governor_mode) | 67 self._SetScalingGovernorInternal(governor_mode) |
| 68 self._ForceAllCpusOnline(False) | 68 self._ForceAllCpusOnline(False) |
| 69 | 69 |
| 70 def _SetScalingGovernorInternal(self, value): | 70 def _SetScalingGovernorInternal(self, value): |
| 71 for cpu in range(self._num_cpu_cores): | 71 cpu_cores = ' '.join([str(x) for x in range(self._num_cpu_cores)]) |
| 72 scaling_governor_file = PerfControl._SCALING_GOVERNOR_FMT % cpu | 72 script = ('for CPU in %s; do\n' |
| 73 if self._device.FileExists(scaling_governor_file): | 73 ' FILE="/sys/devices/system/cpu/cpu$CPU/cpufreq/scaling_governor"\n' |
| 74 logging.info('Writing scaling governor mode \'%s\' -> %s', | 74 ' test -e $FILE && echo %s > $FILE\n' |
| 75 value, scaling_governor_file) | 75 'done\n') % (cpu_cores, value) |
| 76 self._device.WriteFile(scaling_governor_file, value, as_root=True) | 76 logging.info('Setting scaling governor mode: %s', value) |
| 77 self._device.RunShellCommand(script, as_root=True) |
| 77 | 78 |
| 78 def _AllCpusAreOnline(self): | 79 def _AllCpusAreOnline(self): |
| 79 for cpu in range(self._num_cpu_cores): | 80 for cpu in range(self._num_cpu_cores): |
| 80 online_path = PerfControl._CPU_ONLINE_FMT % cpu | 81 online_path = PerfControl._CPU_ONLINE_FMT % cpu |
| 81 # TODO(epenner): Investigate why file may be missing | 82 # TODO(epenner): Investigate why file may be missing |
| 82 # (http://crbug.com/397118) | 83 # (http://crbug.com/397118) |
| 83 if not self._device.FileExists(online_path) or \ | 84 if not self._device.FileExists(online_path) or \ |
| 84 self._device.ReadFile(online_path)[0] == '0': | 85 self._device.ReadFile(online_path)[0] == '0': |
| 85 return False | 86 return False |
| 86 return True | 87 return True |
| (...skipping 18 matching lines...) Expand all Loading... |
| 105 | 106 |
| 106 if not self._have_mpdecision and not self._AllCpusAreOnline(): | 107 if not self._have_mpdecision and not self._AllCpusAreOnline(): |
| 107 logging.warning('Unexpected cpu hot plugging detected.') | 108 logging.warning('Unexpected cpu hot plugging detected.') |
| 108 | 109 |
| 109 if not force_online: | 110 if not force_online: |
| 110 return | 111 return |
| 111 | 112 |
| 112 for cpu in range(self._num_cpu_cores): | 113 for cpu in range(self._num_cpu_cores): |
| 113 online_path = PerfControl._CPU_ONLINE_FMT % cpu | 114 online_path = PerfControl._CPU_ONLINE_FMT % cpu |
| 114 self._device.WriteFile(online_path, '1', as_root=True) | 115 self._device.WriteFile(online_path, '1', as_root=True) |
| OLD | NEW |