rt-tests: determine_maximum_mpps.sh: Introduce '-F' option to specify CPU frequency
PATCH 1/1 rt-tests: determine_maximum_mpps.sh: Introduce '-F' option to specify CPU frequency
From: Tan En De <[email protected]>
For platform that doesn't show cpu MHz in /proc/cpuinfo, introduce '-F' option for user to specify the CPU frequency in MHz.
This corrects previous commit that mistakenly used timer frequency (timebase-frequency) instead of CPU frequency.
--- src/queuelat/determine_maximum_mpps.8 | 3 +++ src/queuelat/determine_maximum_mpps.sh | 17 +++++++++-------- 2 files changed, 12 insertions(+), 8 deletions(-)
src/queuelat/determine_maximum_mpps.8 +3 -0
@@ -56,6 +56,9 @@ default priority = 1. Valid numbers are from 1 to 99 .TP .B \-h help +.TP +.B \-F cpu_mhz +CPU frequency in MHz. This is required for platform that does not show cpu MHz in /proc/cpuinfo. .LP .SH AUTHOR determine_maximum_mpps was written by
src/queuelat/determine_maximum_mpps.sh +9 -8
@@ -37,20 +37,20 @@ usage() echo "-h" echo " help" echo " print this help message and exit" + echo "-F cpu_mhz" + echo " CPU frequency in MHz. This is required for platform that does not show cpu MHz in /proc/cpuinfo" exit } get_cpuinfo_mhz() { - # Try to determine MHz from /proc/cpuinfo - FREQ_MHZ=$(grep "cpu MHz" /proc/cpuinfo | cut -f 3 -d " " | sort -rn | head -n1) - - # Try to determine MHz from /sys/firmware/devicetree/base/cpus/timebase-frequency - if [ -z $FREQ_MHZ ]; then - FREQ_MHZ=$(($((16#$(hexdump -e '1/1 "%02X"' /sys/firmware/devicetree/base/cpus/timebase-frequency)))/1000000)) + # If user does not specify -F CPU_MHZ + if [ -z $CPU_MHZ ]; then + # Try to determine MHz from /proc/cpuinfo + CPU_MHZ=$(grep "cpu MHz" /proc/cpuinfo | cut -f 3 -d " " | sort -rn | head -n1) fi - echo "$FREQ_MHZ" + echo "$CPU_MHZ" } # Check that the scheduling policy hasn't already been set
@@ -64,7 +64,7 @@ check_sched() } # Process command line options -while getopts ":a:frp:m:n:h" opt; do +while getopts ":a:frp:m:n:hF:" opt; do case ${opt} in a ) CPULIST="${OPTARG}" ;; m ) MAXLAT="${OPTARG}" ;;
@@ -73,6 +73,7 @@ while getopts ":a:frp:m:n:h" opt; do r ) check_sched; SCHED="-r" ;; p ) PRIO="${OPTARG}" ;; h ) usage ;; + F ) CPU_MHZ="${OPTARG}" ;; * ) echo "no such option"; usage ;; esac done
Signature · 1 line
2.34.1
Quoted 5 lines · On Thu, 12 Dec 2024, [email protected] wrote:
From: Tan En De <[email protected]>
For platform that doesn't show cpu MHz in
/proc/cpuinfo, introduce '-F' option for user to specify the CPU frequency in MHz.
Are there other places to get this information, for example /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_min_freq
Quoted 78 lines
This corrects previous commit that mistakenly used timer frequency (timebase-frequency) instead of CPU frequency.
Fixes fab7d9057887 ("rt-tests: determine_maximum_mpps.sh: Get frequency from timebase-frequency if cpuinfo fails")Signed-off-by Tan En De <[email protected]>--- src/queuelat/determine_maximum_mpps.8 | 3 +++ src/queuelat/determine_maximum_mpps.sh | 17 +++++++++-------- 2 files changed, 12 insertions(+), 8 deletions(-)src/queuelat/determine_maximum_mpps.8 +3
-0@@ -56,6 +56,9 @@ default priority = 1. Valid numbers are from 1 to 99 .TP .B \-h help +.TP +.B \-F cpu_mhz +CPU frequency in MHz. This is required for platform that does not show cpu MHz in /proc/cpuinfo. .LP .SH AUTHOR determine_maximum_mpps was written bysrc/queuelat/determine_maximum_mpps.sh +9
-8@@ -37,20 +37,20 @@ usage() echo "-h" echo " help" echo " print this help message and exit" + echo "-F cpu_mhz" + echo " CPU frequency in MHz. This is required for platform that does not show cpu MHz in /proc/cpuinfo" exit } get_cpuinfo_mhz() { - # Try to determine MHz from /proc/cpuinfo - FREQ_MHZ=$(grep "cpu MHz" /proc/cpuinfo | cut -f 3 -d " " | sort -rn | head -n1) - - # Try to determine MHz from /sys/firmware/devicetree/base/cpus/timebase-frequency - if [ -z $FREQ_MHZ ]; then - FREQ_MHZ=$(($((16#$(hexdump -e '1/1 "%02X"' /sys/firmware/devicetree/base/cpus/timebase-frequency)))/1000000)) + # If user does not specify -F CPU_MHZ + if [ -z $CPU_MHZ ]; then + # Try to determine MHz from /proc/cpuinfo + CPU_MHZ=$(grep "cpu MHz" /proc/cpuinfo | cut -f 3 -d " " | sort -rn | head -n1) fi - echo "$FREQ_MHZ" + echo "$CPU_MHZ" } # Check that the scheduling policy hasn't already been set@@ -64,7 +64,7 @@ check_sched() } # Process command line options -while getopts ":a:frp:m:n:h" opt; do +while getopts ":a:frp:m:n:hF:" opt; do case ${opt} in a ) CPULIST="${OPTARG}" ;; m ) MAXLAT="${OPTARG}" ;;@@ -73,6 +73,7 @@ while getopts ":a:frp:m:n:h" opt; do r ) check_sched; SCHED="-r" ;; p ) PRIO="${OPTARG}" ;; h ) usage ;; + F ) CPU_MHZ="${OPTARG}" ;; * ) echo "no such option"; usage ;; esac doneSignature · 1 line
2.34.1
Quoted 2 lines
Are there other places to get this information, for example
/sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_min_freq
It is possible to specify "clock-frequency" in CPU nodes in device tree, which corresponds to entry like this /sys/devices/system/cpu/cpu0/of_node/clock-frequency
However, it's not mandatory to specify "clock-frequency", so maybe adding a '-F' option is more useful.
Quoted 10 lines · EnDe Tan
Quoted 2 lines
Are there other places to get this information, for example
/sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_min_freqIt is possible to specify "clock-frequency" in CPU nodes in device tree, which corresponds to entry like this
/sys/devices/system/cpu/cpu0/of_node/clock-frequencyHowever, it's not mandatory to specify "clock-frequency", so maybe adding a '-F' option is more useful.
But why we would want to allow the user to specify a potentially arbitrary number, when we can get a more accurate one from the OS?
Do you have any comments Marcelo?
John