cachepc-linux

Fork of AMDESE/linux with modifications for CachePC side-channel attack
git clone https://git.sinitax.com/sinitax/cachepc-linux
Log | Files | Refs | README | LICENSE | sfeed.txt

cpufreq-bench_script.sh (3453B)


      1#!/bin/bash
      2# SPDX-License-Identifier: GPL-2.0-or-later
      3
      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-bench
      8# mircobenchmark.
      9# Modify the general variables at the top or extend or copy out parts
     10# if you want to test other things
     11#
     12
     13# Default with latest kernels is 95, before micro account patches
     14# it was 80, cmp. with git commit 808009131046b62ac434dbc796
     15UP_THRESHOLD="60 80 95"
     16# Depending on the kernel and the HW sampling rate could be restricted
     17# and cannot be set that low...
     18# E.g. before git commit cef9615a853ebc4972084f7 one could only set
     19# min sampling rate of 80000 if CONFIG_HZ=250
     20SAMPLING_RATE="20000 80000"
     21
     22function measure()
     23{
     24    local -i up_threshold_set
     25    local -i sampling_rate_set
     26
     27    for up_threshold in $UP_THRESHOLD;do
     28	for sampling_rate in $SAMPLING_RATE;do
     29	    # Set values in sysfs
     30	    echo $up_threshold >/sys/devices/system/cpu/cpu0/cpufreq/ondemand/up_threshold
     31	    echo $sampling_rate >/sys/devices/system/cpu/cpu0/cpufreq/ondemand/sampling_rate
     32	    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 sysfs
     36	    if [ ${up_threshold_set} -eq ${up_threshold} ];then
     37		echo "up_threshold: $up_threshold, set in sysfs: ${up_threshold_set}"
     38	    else
     39		echo "WARNING: Tried to set up_threshold: $up_threshold, set in sysfs: ${up_threshold_set}"
     40	    fi
     41	    if [ ${sampling_rate_set} -eq ${sampling_rate} ];then
     42		echo "sampling_rate: $sampling_rate, set in sysfs: ${sampling_rate_set}"
     43	    else
     44		echo "WARNING: Tried to set sampling_rate: $sampling_rate, set in sysfs: ${sampling_rate_set}"
     45	    fi
     46
     47	    # Benchmark
     48	    cpufreq-bench -o /var/log/cpufreq-bench/up_threshold_${up_threshold}_sampling_rate_${sampling_rate}
     49	done
     50    done
     51}
     52
     53function create_plots()
     54{
     55    local command
     56
     57    for up_threshold in $UP_THRESHOLD;do
     58	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;do
     60	    command="${command} /var/log/cpufreq-bench/up_threshold_${up_threshold}_sampling_rate_${sampling_rate}/* \"sampling_rate = $sampling_rate\""
     61	done
     62	echo $command
     63	eval "$command"
     64	echo
     65    done
     66
     67    for sampling_rate in $SAMPLING_RATE;do
     68	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;do
     70	    command="${command} /var/log/cpufreq-bench/up_threshold_${up_threshold}_sampling_rate_${sampling_rate}/* \"up_threshold = $up_threshold\""
     71	done
     72	echo $command
     73	eval "$command"
     74	echo
     75    done
     76
     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;do
     79	for up_threshold in $UP_THRESHOLD;do
     80	    command="${command} /var/log/cpufreq-bench/up_threshold_${up_threshold}_sampling_rate_${sampling_rate}/* \"up_threshold = $up_threshold - sampling_rate = $sampling_rate\""
     81	done
     82    done
     83    echo "$command"
     84    eval "$command"
     85}
     86
     87measure
     88create_plots