diff options
author | Julien Duraj <julien.duraj@linaro.org> | 2016-07-14 17:12:54 +0100 |
---|---|---|
committer | Julien Duraj <julien.duraj@linaro.org> | 2016-07-14 17:17:39 +0100 |
commit | ee4aea45fa9f32ff4d49a0ea724f3df3cac3585e (patch) | |
tree | 7a93f3c146a0b1ea06552fe5bb58d782b493af0d | |
parent | 77338c586d5db7a18948f22280fa527861493638 (diff) | |
download | art-build-scripts-ee4aea45fa9f32ff4d49a0ea724f3df3cac3585e.tar.gz |
Revert "Update `set_cpu_freq.sh` to allow restoring CPUs to a default config."
This reverts commit 8225d1a76f2c678c3a00a1c5c8d33ce120384619.
Automation is failing
Change-Id: Ia7cd4c20522d323d19895f74d31a1cac858e36ff
-rwxr-xr-x | benchmarks/benchmarks_run_target.sh | 16 | ||||
-rw-r--r-- | devices/config/angler.sh | 14 | ||||
-rw-r--r-- | devices/config/bullhead.sh | 14 | ||||
-rw-r--r-- | devices/config/flounder.sh | 8 | ||||
-rw-r--r-- | devices/cpu_freq_utils.sh | 71 | ||||
-rwxr-xr-x | devices/set_cpu_freq.sh | 95 | ||||
-rwxr-xr-x | tests/test_art_target.sh | 6 |
7 files changed, 87 insertions, 137 deletions
diff --git a/benchmarks/benchmarks_run_target.sh b/benchmarks/benchmarks_run_target.sh index 30c2d2ef..bda1aab1 100755 --- a/benchmarks/benchmarks_run_target.sh +++ b/benchmarks/benchmarks_run_target.sh @@ -193,17 +193,14 @@ run_all_benchmarks() { get_device_settings "${target_device}" "${local_path}/../devices/config" || exit 1 if ${DEVICE_IS_BIG_LITTLE}; then - safe "${local_path}/../devices/set_cpu_freq.sh" --little --pin_freq + safe "${local_path}/../devices/set_cpu_freq.sh" --little run_benchmarks "$1" "${target_device}" "${LITTLE_CPUS_NAME}" - safe "${local_path}/../devices/set_cpu_freq.sh" --big --pin_freq + safe "${local_path}/../devices/set_cpu_freq.sh" --big run_benchmarks "$1" "${target_device}" "${BIG_CPUS_NAME}" else - safe "${local_path}/../devices/set_cpu_freq.sh" --all --pin_freq + safe "${local_path}/../devices/set_cpu_freq.sh" run_benchmarks "$1" "${target_device}" "${CPUS_NAME}" fi - - # Be a good citizen and restore the CPUs configuration to defaults. - safe "${local_path}/../devices/set_cpu_freq.sh" --default } main() { @@ -217,6 +214,12 @@ main() { start_timer "${target_timer_name}" + # We need to set up an android environment to have access to `adb` for the CPU + # config backup helpers. + setup_android_target "arm_krait-eng" + local -r backup_cpus_config_dir=$(mktemp -d) + backup_device_cpus_config "$backup_cpus_config_dir" + for bits in 32 64; do if ! ${options["${bits}bit"]}; then log I "Skipping ${bits}bit benchmarks." @@ -239,6 +242,7 @@ main() { run_all_benchmarks "${bits}" done + restore_device_cpus_config "$backup_cpus_config_dir" stop_timer "${target_timer_name}" log S "$0 Finished!" diff --git a/devices/config/angler.sh b/devices/config/angler.sh index 787407c8..f0f214f0 100644 --- a/devices/config/angler.sh +++ b/devices/config/angler.sh @@ -2,28 +2,14 @@ # Helper script used for setting the Nexus 6P frequency. # shellcheck disable=SC2034 -NUMBER_OF_CPUS=8 -# shellcheck disable=SC2034 DEVICE_IS_BIG_LITTLE=true # shellcheck disable=SC2034 LITTLE_CPUS=(0 1 2 3) # shellcheck disable=SC2034 BIG_CPUS=(4 5 6 7) # shellcheck disable=SC2034 -CPUS=(0 1 2 3 4 5 6 7) -# shellcheck disable=SC2034 TARGET_FREQ=1248000 # shellcheck disable=SC2034 LITTLE_CPUS_NAME=a53 # shellcheck disable=SC2034 BIG_CPUS_NAME=a57 - -# Default CPU config. -# shellcheck disable=SC2034 -LITTLE_CPUS_DEFAULT_MIN_FREQ=384000 -# shellcheck disable=SC2034 -LITTLE_CPUS_DEFAULT_MAX_FREQ=1555200 -# shellcheck disable=SC2034 -BIG_CPUS_DEFAULT_MIN_FREQ=633600 -# shellcheck disable=SC2034 -BIG_CPUS_DEFAULT_MAX_FREQ=1958400 diff --git a/devices/config/bullhead.sh b/devices/config/bullhead.sh index 85ceeb43..48f43efe 100644 --- a/devices/config/bullhead.sh +++ b/devices/config/bullhead.sh @@ -2,28 +2,14 @@ # Helper script used for setting the Nexus 5X frequency. # shellcheck disable=SC2034 -NUMBER_OF_CPUS=6 -# shellcheck disable=SC2034 DEVICE_IS_BIG_LITTLE=true # shellcheck disable=SC2034 LITTLE_CPUS=(0 1 2 3) # shellcheck disable=SC2034 BIG_CPUS=(4 5) # shellcheck disable=SC2034 -CPUS=(0 1 2 3 4 5) -# shellcheck disable=SC2034 TARGET_FREQ=1248000 # shellcheck disable=SC2034 LITTLE_CPUS_NAME=a53 # shellcheck disable=SC2034 BIG_CPUS_NAME=a57 - -# Default CPU config. -# shellcheck disable=SC2034 -LITTLE_CPUS_DEFAULT_MIN_FREQ=384000 -# shellcheck disable=SC2034 -LITTLE_CPUS_DEFAULT_MAX_FREQ=1440000 -# shellcheck disable=SC2034 -BIG_CPUS_DEFAULT_MIN_FREQ=633600 -# shellcheck disable=SC2034 -BIG_CPUS_DEFAULT_MAX_FREQ=1824000 diff --git a/devices/config/flounder.sh b/devices/config/flounder.sh index 5442fe6e..5610ca13 100644 --- a/devices/config/flounder.sh +++ b/devices/config/flounder.sh @@ -2,8 +2,6 @@ # Helper script used for setting the Nexus 9 frequency. # shellcheck disable=SC2034 -NUMBER_OF_CPUS=2 -# shellcheck disable=SC2034 DEVICE_IS_BIG_LITTLE=false # shellcheck disable=SC2034 CPUS=(0 1) @@ -11,9 +9,3 @@ CPUS=(0 1) TARGET_FREQ=1224000 # shellcheck disable=SC2034 CPUS_NAME=denver - -# Default CPU config. -# shellcheck disable=SC2034 -CPUS_DEFAULT_MIN_FREQ=510000 -# shellcheck disable=SC2034 -CPUS_DEFAULT_MAX_FREQ=2460750 diff --git a/devices/cpu_freq_utils.sh b/devices/cpu_freq_utils.sh index e5479296..d5ed5c39 100644 --- a/devices/cpu_freq_utils.sh +++ b/devices/cpu_freq_utils.sh @@ -130,47 +130,40 @@ get_device_settings() { safe source "${cpu_freq_script}" } -# ${1} - max frequency -# ${2} - min frequency -# ${1-#} - CPU indexes -configure_cpus_to_interactive() { - local -r max_freq=$1 - local -r min_freq=$2 - shift 2 - - local output= - for cpu; do - output+=$(safe adb_shell_strip "echo interactive > \ - ${sys_cpu_path}/cpu${cpu}/cpufreq/scaling_governor") - # `scaling_max_freq` must be set before `scaling_min_freq`. See - # https://www.kernel.org/doc/Documentation/cpu-freq/user-guide.txt. - output+=$(safe adb_shell_strip "echo $max_freq > \ - ${sys_cpu_path}/cpu${cpu}/cpufreq/scaling_max_freq") - output+=$(safe adb_shell_strip "echo $min_freq > \ - ${sys_cpu_path}/cpu${cpu}/cpufreq/scaling_min_freq") +# Arguments: +# ${1} - backup directory +backup_device_cpus_config() { + local -r backup_dir="${1}" + for remote_cpu_path in $(adb_shell_strip echo "$sys_cpu_path/cpu*"); do + if [[ $remote_cpu_path =~ .*cpu([0-9]+)$ ]]; then + local cpu_index=${BASH_REMATCH[1]} + local local_cpu_path="$backup_dir/cpu$cpu_index" + safe mkdir -p "$local_cpu_path/cpufreq" + adb pull "$remote_cpu_path/online" "$local_cpu_path" + adb pull "$remote_cpu_path/cpufreq/scaling_governor" "$local_cpu_path/cpufreq/" + adb pull "$remote_cpu_path/cpufreq/scaling_setspeed" "$local_cpu_path/cpufreq/" + fi done - - if [[ ${output} ]]; then - log E "${output}" - return 1 - else - return 0 - fi } -set_default_cpu_config() { - validate_cpus "$@" || return 1 - if ${DEVICE_IS_BIG_LITTLE}; then - safe enable_cpus "${BIG_CPUS[@]}" - safe enable_cpus "${LITTLE_CPUS[@]}" - safe configure_cpus_to_interactive \ - "$BIG_CPUS_DEFAULT_MAX_FREQ" "$BIG_CPUS_DEFAULT_MIN_FREQ" "${BIG_CPUS[@]}" - safe configure_cpus_to_interactive \ - "$LITTLE_CPUS_DEFAULT_MAX_FREQ" "$LITTLE_CPUS_DEFAULT_MIN_FREQ" "${LITTLE_CPUS[@]}" - else - safe enable_cpus "${CPUS[@]}" - safe configure_cpus_to_interactive \ - "$CPUS_DEFAULT_MAX_FREQ" "$CPUS_DEFAULT_MIN_FREQ" "${CPUS[@]}" - fi +# Arguments: +# $1 - backup directory +restore_device_cpus_config() { + local -r backup_dir="${1}" + for local_cpu_path in "$backup_dir"/*; do + local cpu_index=${local_cpu_path#${backup_dir}/cpu} + local remote_cpu_path="$sys_cpu_path/cpu$cpu_index" + # Note that we do not use `safe` for `online` and `scaling_setspeed`, + # because attempting to set those to their current value raises an error. + adb shell "echo \"$(cat "$local_cpu_path/online")\" > $remote_cpu_path/online" + if [[ -f "$local_cpu_path/cpufreq/scaling_governor" ]]; then + safe adb shell "echo \"$(cat "$local_cpu_path/cpufreq/scaling_governor")\" > $remote_cpu_path/cpufreq/scaling_governor" + fi + local freq=$(cat "$local_cpu_path/cpufreq/scaling_setspeed") + if [[ "$freq" =~ ^[0-9]+$ ]]; then + adb shell "echo \"$freq\" > $remote_cpu_path/cpufreq/scaling_setspeed" + fi + done + rm -rf "$backup_dir" } diff --git a/devices/set_cpu_freq.sh b/devices/set_cpu_freq.sh index 7edf595b..97abc580 100755 --- a/devices/set_cpu_freq.sh +++ b/devices/set_cpu_freq.sh @@ -11,14 +11,13 @@ declare -A options target_device= init_options() { - options["cpus"]="all" - options["pin_freq"]="false" - options["default"]="false" + options["big"]="false" + options["little"]="false" } validate_options() { - if ${options["default"]} && ( ${options["pin_freq"]} || [[ "${options["cpus"]}" != "all" ]] ); then - log E "The option \`--default\` is incompatible with \`--pin_freq\`, \`--big\`, and \`--little\` options." + if ${options["big"]} && ${options["little"]}; then + log E "Both --big and --little set. You need to only use one of these clusters at a time." exit 1 fi } @@ -26,19 +25,31 @@ validate_options() { usage() { log I "$0" log I "This script should be used for frequency scaling your device." + log I "The script expects a 64bit flounder (Nexus 9) or bullhead (Nexus 5X) connected." log I " -h|--help - help" log I " -v|--verbose - verbose" log I "-------------------------------------------" - log I " --all - Enable all CPUs (default)." - log I " --big - Enable only the big cluster in a big.LITTLE SoC." - log I " --little - Enable only the little cluster in a big.LITTLE SoC." - log I "" - log I " --pin_freq - Pin the frequency of enabled cores." - log I " --default - Restore the CPUs to the default configuration." + log I "CPU clusters to be turned on and scaled:" + log I " --big - Big cluster in a big.LITTLE SoC." + log I " --little - Little cluster in a big.LITTLE SoC." log I "" + log I "Note: For SoCs with a single cluster none of the options above need to be specified." log I "-------------------------------------------" } +set_option() { + local current_option=${1#"--"} + # shellcheck disable=SC2144 + # shellcheck disable=SC2102 + if [[ -v options[${current_option}] ]]; then + options[${current_option}]="true" + else + # There might be something wrong with the option parser since this option + # does not have a default. + abort + fi +} + arguments_parser() { init_options while [[ $# -gt 0 ]]; do @@ -50,14 +61,8 @@ arguments_parser() { usage exit 0 ;; - --all|--big|--little) - options["cpus"]=${1#--} - ;; - --pin_freq) - options["pin_freq"]="true" - ;; - --default) - options["default"]="true" + --big|--little) + set_option "$1" ;; *) log E "Invalid option: $1" @@ -75,37 +80,27 @@ print_freq() { } set_device_freq() { - if ! ${DEVICE_IS_BIG_LITTLE} && [[ ${options["cpus"]} != "all" ]]; then - log E "Device ${target_device} is single-cluster, do not use \`--big\` or \`little\` options." - fi - - if ${options["default"]}; then - log I "Restoring CPUs configuration to defaults." - set_default_cpu_config - exit 0 - fi - - local -a cpus_to_configure - - if [[ ${options["cpus"]} == "all" ]]; then - log I "Enabling all CPUs." - CPUS_TO_CONFIGURE=("${CPUS[@]}") - safe enable_cpus "${CPUS_TO_CONFIGURE[@]}" - elif [[ ${options["cpus"]} == "big" ]]; then - log I "Enabling only the big cluster." - safe enable_cpus "${BIG_CPUS[@]}" - safe disable_cpus "${LITTLE_CPUS[@]}" - CPUS_TO_CONFIGURE=("${BIG_CPUS[@]}") - elif [[ ${options["cpus"]} == "little" ]]; then - log I "Enabling only the little cluster." - safe enable_cpus "${LITTLE_CPUS[@]}" - safe disable_cpus "${BIG_CPUS[@]}" - CPUS_TO_CONFIGURE=("${LITTLE_CPUS[@]}") - fi - - if ${options["pin_freq"]}; then - log I "Pinning the frequency." - safe set_freq_cpus "${TARGET_FREQ}" "${CPUS_TO_CONFIGURE[@]}" + if ${DEVICE_IS_BIG_LITTLE}; then + if ${options["little"]}; then + log I "Setting cpu freq for the little cluster (freq = $(print_freq))." + safe enable_cpus "${LITTLE_CPUS[@]}" + safe disable_cpus "${BIG_CPUS[@]}" + safe set_freq_cpus "${TARGET_FREQ}" "${LITTLE_CPUS[@]}" + elif ${options["big"]}; then + log I "Setting cpu freq for the big cluster (freq = $(print_freq))." + safe enable_cpus "${BIG_CPUS[@]}" + safe disable_cpus "${LITTLE_CPUS[@]}" + safe set_freq_cpus "${TARGET_FREQ}" "${BIG_CPUS[@]}" + else + log E "Device ${target_device} is big.LITTLE, please specify a cluster." + fi + else + if ! ${options["big"]} && ! ${options["little"]}; then + log I "Setting cpu freq for the single cluster (freq = $(print_freq))." + safe set_freq_cpus "${TARGET_FREQ}" "${CPUS[@]}" + else + log E "Device ${target_device} is single-cluster, do not specify a cluster." + fi fi } diff --git a/tests/test_art_target.sh b/tests/test_art_target.sh index 49bd65ef..5733e7f6 100755 --- a/tests/test_art_target.sh +++ b/tests/test_art_target.sh @@ -275,10 +275,6 @@ build_target() { end_section "build_target_$1" "$?" } -configure_cpus() { - safe "${local_path}/../devices/set_cpu_freq.sh" --default -} - device_setup() { start_section "device_setup_$1" # Get adb root - needed otherwise device_cleanup() would fail. @@ -411,8 +407,6 @@ main() { # Build target. build_target "${bits}" - configure_cpus - # Setup & sync device. device_setup "${bits}" device_cleanup "${bits}" |