Created
September 19, 2023 10:20
Print cpu opp details from OPP driver from /sys/kernel/debugfs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Needs kernel/debugsfs enabled | |
# | |
# Simple script, that creates an table based output of the opp values | |
# from every physical cpu. | |
# | |
# (c)2023 Matthias Strubel <matthias.strubel@aod-rpg.de> | |
# License GPL-2.0 | |
# | |
set -e | |
#set -x | |
cd /sys/kernel/debug/opp/ | |
find . -name cpu\* -a -type d | sort > /tmp/pyhsical_cpu.txt | |
supply_header="" | |
while read cpu_folder ; do | |
cpu_name=$( basename $cpu_folder ) | |
echo " $cpu_name" | |
echo " -----------------" | |
cd $cpu_folder | |
find . -name opp\:\* -a -type d | sort -t ':' -k2 -n > /tmp/frequency_list.txt | |
while read frequency_folder ; do | |
supply="" | |
frequency=$( echo "$frequency_folder" | cut -d ':' -f2 ) | |
out_freq="$frequency" | |
# echo " --> $frequency " | |
find $frequency_folder -name supply-\* -a -type d | sort > /tmp/supply.txt | |
while read supply_folder ; do | |
# echo " ---> $supply_folder " | |
find $supply_folder -type f > /tmp/supply_entities.txt | |
if test -z "$supply_header" ; then | |
tmp_header="" | |
while read filename ; do | |
tuple_name=$( basename $filename ) | |
printf -v out "%10s " $tuple_name | |
tmp_header="$tmp_header $out" | |
done < /tmp/supply_entities.txt | |
printf "%15s | %s\n" "Frequency" "$tmp_header" | |
echo " -------------------------------------------------------------------" | |
supply_header="1" | |
fi | |
tmp_output="" | |
while read filename ; do | |
tuple_name=$( basename $filename ) | |
printf -v out "%10s " $(cat $filename) | |
tmp_output="$tmp_output $out" | |
done < /tmp/supply_entities.txt | |
printf "%15s | %s\n" "$out_freq" "$tmp_output" | |
out_freq="" | |
done < /tmp/supply.txt | |
done < /tmp/frequency_list.txt | |
cd .. | |
supply_header="" | |
done < /tmp/pyhsical_cpu.txt | |
rm /tmp/pyhsical_cpu.txt /tmp/supply_entities.txt /tmp/supply.txt /tmp/frequency_list.txt |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment