From eb306fa89c054c1d78eafdbd0d6d4f2be493afe9 Mon Sep 17 00:00:00 2001 From: Denis Nikitin Date: Tue, 2 Jul 2019 09:59:17 -0700 Subject: crosperf: Recover intel_pstate performance setup Revert back performance governor intel_pstate setup. Change the order of no_turbo setup which should follow the intel_pstate governor setup. BUG=chromium:966514 TEST=verified on samus, eve, rammus, kefka. Change-Id: I40e6930bc62151cafe1a95f7f9d05c138e6d7663 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/toolchain-utils/+/1687384 Tested-by: Denis Nikitin Reviewed-by: Manoj Gupta Legacy-Commit-Queue: Commit Bot --- crosperf/suite_runner.py | 49 ++++++++++++++++++++++++--------------- crosperf/suite_runner_unittest.py | 9 +++++++ 2 files changed, 39 insertions(+), 19 deletions(-) (limited to 'crosperf') diff --git a/crosperf/suite_runner.py b/crosperf/suite_runner.py index b195d2cc..ba1c3fa7 100644 --- a/crosperf/suite_runner.py +++ b/crosperf/suite_runner.py @@ -103,26 +103,32 @@ class SuiteRunner(object): disable_aslr, machine=machine_name, chromeos_root=chromeos_root) def PinGovernorExecutionFrequencies(self, machine_name, chromeos_root): - """Manages the cpu governor and other performance settings. - Includes support for setting cpu frequency to a static value. + """Setup Intel CPU frequency. + + Manages the cpu governor and other performance settings. + Includes support for setting cpu frequency to a static value. """ # pyformat: disable set_cpu_freq = ( - # Disable Turbo in Intel pstate driver - 'if [[ -e /sys/devices/system/cpu/intel_pstate/no_turbo ]]; then ' - ' if grep -q 0 /sys/devices/system/cpu/intel_pstate/no_turbo; then ' - ' echo -n 1 > /sys/devices/system/cpu/intel_pstate/no_turbo; ' - ' fi; ' - 'fi; ' - # Uncomment the following lines to set governor to powersave for each - # cpu. Also uncomment the 'done' at end. - # 'for f in /sys/devices/system/cpu/cpu*/cpufreq; do ' + # Disable Intel Opportunistic Processor + # Commented out because wrmsr requires kernel change + # to enable white-listed write access to msr 0x199. + # See Intel 64 and IA-32 Archtectures + # Software Developer's Manual, 14.3.2.2. + #'awk \'$1 ~ /^processor/ { print $NF }\' /proc/cpuinfo ' + #' | while read c; do ' + # 'iotools wrmsr $c 0x199 $(printf "0x%x\n" $(( (1 << 32) ' + # ' | $(iotools rdmsr $c 0x199) )));' + #'done;' + # Set up intel_pstate governor to performance if enabled. + 'for f in `ls -d /sys/devices/system/cpu/cpu*/cpufreq 2>/dev/null`; do ' # Skip writing scaling_governor if cpu is not online. - # '[[ -e ${f/cpufreq/online} ]] && grep -q 0 ${f/cpufreq/online} ' - # '&& continue; ' + ' [[ -e ${f/cpufreq/online} ]] && grep -q 0 ${f/cpufreq/online} ' + ' && continue; ' # The cpu is online, can update. - # 'cd $f; ' - # 'echo powersave > scaling_governor; ' + ' cd $f; ' + ' if [[ -e scaling_governor ]]; then ' + ' echo performance > scaling_governor; fi; ' # # Uncomment rest of lines to enable setting frequency by crosperf. # It sets the cpu to the second highest supported frequency. @@ -139,10 +145,15 @@ class SuiteRunner(object): #'fi ;' #'echo $highest > scaling_max_freq; ' #'echo $highest > scaling_min_freq; ' - # - # Uncomment to enable the loop for CPU governor settings. - # 'done' - ) + 'done; ' + # Disable Turbo in Intel pstate driver + # no_turbo should follow governor setup. + # Otherwise it can be overwritten. + 'if [[ -e /sys/devices/system/cpu/intel_pstate/no_turbo ]]; then ' + ' if grep -q 0 /sys/devices/system/cpu/intel_pstate/no_turbo; then ' + ' echo -n 1 > /sys/devices/system/cpu/intel_pstate/no_turbo; ' + ' fi; ' + 'fi; ') # pyformat: enable if self.log_level == 'average': self.logger.LogOutput( diff --git a/crosperf/suite_runner_unittest.py b/crosperf/suite_runner_unittest.py index 783a2934..6c92e54d 100755 --- a/crosperf/suite_runner_unittest.py +++ b/crosperf/suite_runner_unittest.py @@ -197,6 +197,15 @@ class SuiteRunnerTest(unittest.TestCase): cmd = mock_cros_runcmd.call_args_list[0][0] # pyformat: disable set_cpu_cmd = ( + 'for f in `ls -d /sys/devices/system/cpu/cpu*/cpufreq 2>/dev/null`; do ' + # Skip writing scaling_governor if cpu is not online. + ' [[ -e ${f/cpufreq/online} ]] && grep -q 0 ${f/cpufreq/online} ' + ' && continue; ' + # The cpu is online, can update. + ' cd $f; ' + ' if [[ -e scaling_governor ]]; then ' + ' echo performance > scaling_governor; fi; ' + 'done; ' # Disable Turbo in Intel pstate driver 'if [[ -e /sys/devices/system/cpu/intel_pstate/no_turbo ]]; then ' ' if grep -q 0 /sys/devices/system/cpu/intel_pstate/no_turbo; then ' -- cgit v1.2.3