diff options
author | Manoj Gupta <manojgupta@google.com> | 2017-01-13 16:05:45 -0800 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2017-01-24 11:22:44 -0800 |
commit | 4e25342bd03fc8f5df7e4e4fe33649de82526730 (patch) | |
tree | 8de6c65262e0fd3d451210ec613b9fc131d2441b | |
parent | 5775e7e3e85529f18220d5d6bc47df6c2fc79a6a (diff) | |
download | toolchain-utils-4e25342bd03fc8f5df7e4e4fe33649de82526730.tar.gz |
Fix frequency pinning on crosperf.
Crosperf was pinning frequency to maximum based on cpu0
information. This does not work as intended for arm
Big-Little cores. Instead do it for each cpu based on its
own information.
BUG=chromium:680742
TEST=Tested on elm, kevin, falco, samus, peach_pit and veyron_jaq.
Change-Id: I77fc76d8f1e94563fe12b3555bf08511fdbfdc32
Reviewed-on: https://chromium-review.googlesource.com/428186
Commit-Ready: Manoj Gupta <manojgupta@chromium.org>
Tested-by: Manoj Gupta <manojgupta@chromium.org>
Reviewed-by: Luis Lozano <llozano@chromium.org>
-rw-r--r-- | crosperf/suite_runner.py | 65 | ||||
-rwxr-xr-x | crosperf/suite_runner_unittest.py | 54 |
2 files changed, 46 insertions, 73 deletions
diff --git a/crosperf/suite_runner.py b/crosperf/suite_runner.py index 796c1e4d..678113a7 100644 --- a/crosperf/suite_runner.py +++ b/crosperf/suite_runner.py @@ -83,54 +83,35 @@ class SuiteRunner(object): break return ret_tup - def GetHighestStaticFrequency(self, machine_name, chromeos_root): - """Gets the highest static frequency for the specified machine.""" - get_avail_freqs = ('cd /sys/devices/system/cpu/cpu0/cpufreq/; ' - 'if [[ -e scaling_available_frequencies ]]; then ' - ' cat scaling_available_frequencies; ' - 'else ' - ' cat scaling_max_freq ; ' - 'fi') - ret, freqs_str, _ = self._ce.CrosRunCommandWOutput( - get_avail_freqs, machine=machine_name, chromeos_root=chromeos_root) - self.logger.LogFatalIf(ret, 'Could not get available frequencies ' - 'from machine: %s' % machine_name) - freqs = freqs_str.split() - # We need to make sure that the frequencies are sorted in decreasing - # order - freqs.sort(key=int, reverse=True) - - ## When there is no scaling_available_frequencies file, - ## we have only 1 choice. - if len(freqs) == 1: - return freqs[0] - # The dynamic frequency ends with a "1000". So, ignore it if found. - if freqs[0].endswith('1000'): - return freqs[1] - else: - return freqs[0] - def PinGovernorExecutionFrequencies(self, machine_name, chromeos_root): """Set min and max frequencies to max static frequency.""" - highest_freq = self.GetHighestStaticFrequency(machine_name, chromeos_root) - BASH_FOR = 'for f in {list}; do {body}; done' - CPUFREQ_DIRS = '/sys/devices/system/cpu/cpu*/cpufreq/' - change_max_freq = BASH_FOR.format( - list=CPUFREQ_DIRS + 'scaling_max_freq', - body='echo %s > $f' % highest_freq) - change_min_freq = BASH_FOR.format( - list=CPUFREQ_DIRS + 'scaling_min_freq', - body='echo %s > $f' % highest_freq) - change_perf_gov = BASH_FOR.format( - list=CPUFREQ_DIRS + 'scaling_governor', body='echo performance > $f') + # pyformat: disable + set_cpu_freq = ( + 'set -e && ' + 'for f in /sys/devices/system/cpu/cpu*/cpufreq; do ' + 'cd $f; ' + 'val=0; ' + 'if [[ -e scaling_available_frequencies ]]; then ' + # pylint: disable=line-too-long + ' val=`cat scaling_available_frequencies | tr " " "\\n" | sort -n -b -r`; ' + 'else ' + ' val=`cat scaling_max_freq | tr " " "\\n" | sort -n -b -r`; fi ; ' + 'set -- $val; ' + 'highest=$1; ' + 'if [[ $# -gt 1 ]]; then ' + ' case $highest in *1000) highest=$2;; esac; ' + 'fi ;' + 'echo $highest > scaling_max_freq; ' + 'echo $highest > scaling_min_freq; ' + 'echo performance > scaling_governor; ' + 'done' + ) + # pyformat: enable if self.log_level == 'average': self.logger.LogOutput('Pinning governor execution frequencies for %s' % machine_name) ret = self._ce.CrosRunCommand( - ' && '.join(('set -e ', change_max_freq, change_min_freq, - change_perf_gov)), - machine=machine_name, - chromeos_root=chromeos_root) + set_cpu_freq, machine=machine_name, chromeos_root=chromeos_root) self.logger.LogFatalIf(ret, 'Could not pin frequencies on machine: %s' % machine_name) diff --git a/crosperf/suite_runner_unittest.py b/crosperf/suite_runner_unittest.py index 15847b02..fd8de661 100755 --- a/crosperf/suite_runner_unittest.py +++ b/crosperf/suite_runner_unittest.py @@ -162,43 +162,35 @@ class SuiteRunnerTest(unittest.TestCase): 'fake_machine', self.mock_label, self.telemetry_crosperf_bench, '', '' ]) - @mock.patch.object(command_executer.CommandExecuter, 'CrosRunCommandWOutput') - def test_get_highest_static_frequency(self, mock_cros_runcmd): - - self.mock_cmd_exec.CrosRunCommandWOutput = mock_cros_runcmd - mock_cros_runcmd.return_value = [0, '1666000 1333000 1000000', ''] - freq = self.runner.GetHighestStaticFrequency('lumpy1.cros', '/tmp/chromeos') - self.assertEqual(freq, '1666000') - - mock_cros_runcmd.return_value = [0, '1333000', ''] - freq = self.runner.GetHighestStaticFrequency('lumpy1.cros', '/tmp/chromeos') - self.assertEqual(freq, '1333000') - - mock_cros_runcmd.return_value = [0, '1661000 1333000 1000000', ''] - freq = self.runner.GetHighestStaticFrequency('lumpy1.cros', '/tmp/chromeos') - self.assertEqual(freq, '1333000') - @mock.patch.object(command_executer.CommandExecuter, 'CrosRunCommand') def test_pin_governor_execution_frequencies(self, mock_cros_runcmd): - - def FakeGetHighestFreq(machine_name, chromeos_root): - if machine_name or chromeos_root: - pass - return '1666000' - self.mock_cmd_exec.CrosRunCommand = mock_cros_runcmd - self.runner.GetHighestStaticFrequency = FakeGetHighestFreq self.runner.PinGovernorExecutionFrequencies('lumpy1.cros', '/tmp/chromeos') self.assertEqual(mock_cros_runcmd.call_count, 1) cmd = mock_cros_runcmd.call_args_list[0][0] - self.assertEqual(cmd, ( - 'set -e && for f in ' - '/sys/devices/system/cpu/cpu*/cpufreq/scaling_max_freq; do echo ' - '1666000 > $f; done && for f in ' - '/sys/devices/system/cpu/cpu*/cpufreq/scaling_min_freq; do echo ' - '1666000 > $f; done && for f in ' - '/sys/devices/system/cpu/cpu*/cpufreq/scaling_governor; do echo ' - 'performance > $f; done',)) + # pyformat: disable + set_cpu_cmd = ( + 'set -e && ' + 'for f in /sys/devices/system/cpu/cpu*/cpufreq; do ' + 'cd $f; ' + 'val=0; ' + 'if [[ -e scaling_available_frequencies ]]; then ' + # pylint: disable=line-too-long + ' val=`cat scaling_available_frequencies | tr " " "\\n" | sort -n -b -r`; ' + 'else ' + ' val=`cat scaling_max_freq | tr " " "\\n" | sort -n -b -r`; fi ; ' + 'set -- $val; ' + 'highest=$1; ' + 'if [[ $# -gt 1 ]]; then ' + ' case $highest in *1000) highest=$2;; esac; ' + 'fi ;' + 'echo $highest > scaling_max_freq; ' + 'echo $highest > scaling_min_freq; ' + 'echo performance > scaling_governor; ' + 'done' + ) + # pyformat: enable + self.assertEqual(cmd, (set_cpu_cmd,)) @mock.patch.object(time, 'sleep') @mock.patch.object(command_executer.CommandExecuter, 'CrosRunCommand') |