89 lines · bash
1#!/bin/bash2# SPDX-License-Identifier: GPL-2.0-or-later3 4 5# Author/Copyright(c): 2009, Thomas Renninger <trenn@suse.de>, Novell Inc.6 7# Ondemand up_threshold and sampling rate test script for cpufreq-bench8# mircobenchmark.9# Modify the general variables at the top or extend or copy out parts10# if you want to test other things11#12 13# Default with latest kernels is 95, before micro account patches14# it was 80, cmp. with git commit 808009131046b62ac434dbc79615UP_THRESHOLD="60 80 95"16# Depending on the kernel and the HW sampling rate could be restricted17# and cannot be set that low...18# E.g. before git commit cef9615a853ebc4972084f7 one could only set19# min sampling rate of 80000 if CONFIG_HZ=25020SAMPLING_RATE="20000 80000"21 22function measure()23{24 local -i up_threshold_set25 local -i sampling_rate_set26 27 for up_threshold in $UP_THRESHOLD;do28 for sampling_rate in $SAMPLING_RATE;do29 # Set values in sysfs30 echo $up_threshold >/sys/devices/system/cpu/cpu0/cpufreq/ondemand/up_threshold31 echo $sampling_rate >/sys/devices/system/cpu/cpu0/cpufreq/ondemand/sampling_rate32 up_threshold_set=$(cat /sys/devices/system/cpu/cpu0/cpufreq/ondemand/up_threshold)33 sampling_rate_set=$(cat /sys/devices/system/cpu/cpu0/cpufreq/ondemand/sampling_rate)34 35 # Verify set values in sysfs36 if [ ${up_threshold_set} -eq ${up_threshold} ];then37 echo "up_threshold: $up_threshold, set in sysfs: ${up_threshold_set}"38 else39 echo "WARNING: Tried to set up_threshold: $up_threshold, set in sysfs: ${up_threshold_set}"40 fi41 if [ ${sampling_rate_set} -eq ${sampling_rate} ];then42 echo "sampling_rate: $sampling_rate, set in sysfs: ${sampling_rate_set}"43 else44 echo "WARNING: Tried to set sampling_rate: $sampling_rate, set in sysfs: ${sampling_rate_set}"45 fi46 47 # Benchmark48 cpufreq-bench -o /var/log/cpufreq-bench/up_threshold_${up_threshold}_sampling_rate_${sampling_rate}49 done50 done51}52 53function create_plots()54{55 local command56 57 for up_threshold in $UP_THRESHOLD;do58 command="cpufreq-bench_plot.sh -o \"sampling_rate_${SAMPLING_RATE}_up_threshold_${up_threshold}\" -t \"Ondemand sampling_rate: ${SAMPLING_RATE} comparison - Up_threshold: $up_threshold %\""59 for sampling_rate in $SAMPLING_RATE;do60 command="${command} /var/log/cpufreq-bench/up_threshold_${up_threshold}_sampling_rate_${sampling_rate}/* \"sampling_rate = $sampling_rate\""61 done62 echo $command63 eval "$command"64 echo65 done66 67 for sampling_rate in $SAMPLING_RATE;do68 command="cpufreq-bench_plot.sh -o \"up_threshold_${UP_THRESHOLD}_sampling_rate_${sampling_rate}\" -t \"Ondemand up_threshold: ${UP_THRESHOLD} % comparison - sampling_rate: $sampling_rate\""69 for up_threshold in $UP_THRESHOLD;do70 command="${command} /var/log/cpufreq-bench/up_threshold_${up_threshold}_sampling_rate_${sampling_rate}/* \"up_threshold = $up_threshold\""71 done72 echo $command73 eval "$command"74 echo75 done76 77 command="cpufreq-bench_plot.sh -o \"up_threshold_${UP_THRESHOLD}_sampling_rate_${SAMPLING_RATE}\" -t \"Ondemand up_threshold: ${UP_THRESHOLD} and sampling_rate ${SAMPLING_RATE} comparison\""78 for sampling_rate in $SAMPLING_RATE;do79 for up_threshold in $UP_THRESHOLD;do80 command="${command} /var/log/cpufreq-bench/up_threshold_${up_threshold}_sampling_rate_${sampling_rate}/* \"up_threshold = $up_threshold - sampling_rate = $sampling_rate\""81 done82 done83 echo "$command"84 eval "$command"85}86 87measure88create_plots89