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

Side by Side Diff: build/android/pylib/perf/perf_control.py

Issue 652343002: Telemetry: Pin Nexus 5 cores online. Limit CPU & GPU frequency. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix nits. Created 6 years, 2 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 10 matching lines...) Expand all
21 device = device_utils.DeviceUtils(device) 21 device = device_utils.DeviceUtils(device)
22 self._device = device 22 self._device = device
23 cpu_files = self._device.RunShellCommand( 23 cpu_files = self._device.RunShellCommand(
24 'ls -d /sys/devices/system/cpu/cpu[0-9]*') 24 'ls -d /sys/devices/system/cpu/cpu[0-9]*')
25 self._num_cpu_cores = len(cpu_files) 25 self._num_cpu_cores = len(cpu_files)
26 assert self._num_cpu_cores > 0, 'Failed to detect CPUs.' 26 assert self._num_cpu_cores > 0, 'Failed to detect CPUs.'
27 logging.info('Number of CPUs: %d', self._num_cpu_cores) 27 logging.info('Number of CPUs: %d', self._num_cpu_cores)
28 self._have_mpdecision = self._device.FileExists('/system/bin/mpdecision') 28 self._have_mpdecision = self._device.FileExists('/system/bin/mpdecision')
29 29
30 def SetHighPerfMode(self): 30 def SetHighPerfMode(self):
31 """Sets the highest possible performance mode for the device.""" 31 """Sets the highest stable performance mode for the device."""
32 if not self._device.old_interface.IsRootEnabled(): 32 if not self._device.old_interface.IsRootEnabled():
33 message = 'Need root for performance mode. Results may be NOISY!!' 33 message = 'Need root for performance mode. Results may be NOISY!!'
34 logging.warning(message) 34 logging.warning(message)
35 # Add an additional warning at exit, such that it's clear that any results 35 # Add an additional warning at exit, such that it's clear that any results
36 # may be different/noisy (due to the lack of intended performance mode). 36 # may be different/noisy (due to the lack of intended performance mode).
37 atexit.register(logging.warning, message) 37 atexit.register(logging.warning, message)
38 return 38 return
39
40 product_model = self._device.old_interface.GetProductModel()
39 # TODO(epenner): Enable on all devices (http://crbug.com/383566) 41 # TODO(epenner): Enable on all devices (http://crbug.com/383566)
40 if 'Nexus 4' == self._device.old_interface.GetProductModel(): 42 if 'Nexus 4' == product_model:
41 self._ForceAllCpusOnline(True) 43 self._ForceAllCpusOnline(True)
42 if not self._AllCpusAreOnline(): 44 if not self._AllCpusAreOnline():
43 logging.warning('Failed to force CPUs online. Results may be NOISY!') 45 logging.warning('Failed to force CPUs online. Results may be NOISY!')
44 self._SetScalingGovernorInternal('performance') 46 self._SetScalingGovernorInternal('performance')
47 elif 'Nexus 5' == product_model:
48 self._ForceAllCpusOnline(True)
49 if not self._AllCpusAreOnline():
50 logging.warning('Failed to force CPUs online. Results may be NOISY!')
51 self._SetScalingGovernorInternal('performance')
52 self._SetScalingMaxFreq(1190400)
53 self._SetMaxGpuClock(200000000)
54 else:
55 self._SetScalingGovernorInternal('performance')
45 56
46 def SetPerfProfilingMode(self): 57 def SetPerfProfilingMode(self):
47 """Enables all cores for reliable perf profiling.""" 58 """Enables all cores for reliable perf profiling."""
48 self._ForceAllCpusOnline(True) 59 self._ForceAllCpusOnline(True)
49 self._SetScalingGovernorInternal('performance') 60 self._SetScalingGovernorInternal('performance')
50 if not self._AllCpusAreOnline(): 61 if not self._AllCpusAreOnline():
51 if not self._device.old_interface.IsRootEnabled(): 62 if not self._device.old_interface.IsRootEnabled():
52 raise RuntimeError('Need root to force CPUs online.') 63 raise RuntimeError('Need root to force CPUs online.')
53 raise RuntimeError('Failed to force CPUs online.') 64 raise RuntimeError('Failed to force CPUs online.')
54 65
55 def SetDefaultPerfMode(self): 66 def SetDefaultPerfMode(self):
56 """Sets the performance mode for the device to its default mode.""" 67 """Sets the performance mode for the device to its default mode."""
57 if not self._device.old_interface.IsRootEnabled(): 68 if not self._device.old_interface.IsRootEnabled():
58 return 69 return
59 product_model = self._device.GetProp('ro.product.model') 70 product_model = self._device.old_interface.GetProductModel()
71 if 'Nexus 5' == product_model:
72 if self._AllCpusAreOnline():
73 self._SetScalingMaxFreq(2265600)
74 self._SetMaxGpuClock(450000000)
75
60 governor_mode = { 76 governor_mode = {
61 'GT-I9300': 'pegasusq', 77 'GT-I9300': 'pegasusq',
62 'Galaxy Nexus': 'interactive', 78 'Galaxy Nexus': 'interactive',
63 'Nexus 4': 'ondemand', 79 'Nexus 4': 'ondemand',
80 'Nexus 5': 'ondemand',
64 'Nexus 7': 'interactive', 81 'Nexus 7': 'interactive',
65 'Nexus 10': 'interactive' 82 'Nexus 10': 'interactive'
66 }.get(product_model, 'ondemand') 83 }.get(product_model, 'ondemand')
67 self._SetScalingGovernorInternal(governor_mode) 84 self._SetScalingGovernorInternal(governor_mode)
68 self._ForceAllCpusOnline(False) 85 self._ForceAllCpusOnline(False)
69 86
70 def _SetScalingGovernorInternal(self, value): 87 def _SetScalingGovernorInternal(self, value):
71 cpu_cores = ' '.join([str(x) for x in range(self._num_cpu_cores)]) 88 cpu_cores = ' '.join([str(x) for x in range(self._num_cpu_cores)])
72 script = ('for CPU in %s; do\n' 89 script = ('for CPU in %s; do\n'
73 ' FILE="/sys/devices/system/cpu/cpu$CPU/cpufreq/scaling_governor"\n' 90 ' FILE="/sys/devices/system/cpu/cpu$CPU/cpufreq/scaling_governor"\n'
74 ' test -e $FILE && echo %s > $FILE\n' 91 ' test -e $FILE && echo %s > $FILE\n'
75 'done\n') % (cpu_cores, value) 92 'done\n') % (cpu_cores, value)
76 logging.info('Setting scaling governor mode: %s', value) 93 logging.info('Setting scaling governor mode: %s', value)
77 self._device.RunShellCommand(script, as_root=True) 94 self._device.RunShellCommand(script, as_root=True)
78 95
96 def _SetScalingMaxFreq(self, value):
97 cpu_cores = ' '.join([str(x) for x in range(self._num_cpu_cores)])
98 script = ('for CPU in %s; do\n'
99 ' FILE="/sys/devices/system/cpu/cpu$CPU/cpufreq/scaling_max_freq"\n'
100 ' test -e $FILE && echo %d > $FILE\n'
101 'done\n') % (cpu_cores, value)
102 self._device.RunShellCommand(script, as_root=True)
103
104 def _SetMaxGpuClock(self, value):
105 self._device.WriteFile('/sys/class/kgsl/kgsl-3d0/max_gpuclk',
106 str(value),
107 as_root=True)
108
79 def _AllCpusAreOnline(self): 109 def _AllCpusAreOnline(self):
80 for cpu in range(1, self._num_cpu_cores): 110 for cpu in range(1, self._num_cpu_cores):
81 online_path = PerfControl._CPU_ONLINE_FMT % cpu 111 online_path = PerfControl._CPU_ONLINE_FMT % cpu
82 # TODO(epenner): Investigate why file may be missing 112 # TODO(epenner): Investigate why file may be missing
83 # (http://crbug.com/397118) 113 # (http://crbug.com/397118)
84 if not self._device.FileExists(online_path) or \ 114 if not self._device.FileExists(online_path) or \
85 self._device.ReadFile(online_path)[0] == '0': 115 self._device.ReadFile(online_path)[0] == '0':
86 return False 116 return False
87 return True 117 return True
88 118
(...skipping 17 matching lines...) Expand all
106 136
107 if not self._have_mpdecision and not self._AllCpusAreOnline(): 137 if not self._have_mpdecision and not self._AllCpusAreOnline():
108 logging.warning('Unexpected cpu hot plugging detected.') 138 logging.warning('Unexpected cpu hot plugging detected.')
109 139
110 if not force_online: 140 if not force_online:
111 return 141 return
112 142
113 for cpu in range(self._num_cpu_cores): 143 for cpu in range(self._num_cpu_cores):
114 online_path = PerfControl._CPU_ONLINE_FMT % cpu 144 online_path = PerfControl._CPU_ONLINE_FMT % cpu
115 self._device.WriteFile(online_path, '1', as_root=True) 145 self._device.WriteFile(online_path, '1', as_root=True)
146
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698