linux-rt-users.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [1/1] rt-tests: determine_maximum_mpps.sh: Introduce '-F' option to specify CPU frequency
@ 2024-12-11 17:11 ende.tan
  2024-12-11 19:25 ` John Kacur
  0 siblings, 1 reply; 4+ messages in thread
From: ende.tan @ 2024-12-11 17:11 UTC (permalink / raw)
  To: linux-rt-users, mtosatti
  Cc: williams, jkacur, leyfoon.tan, endeneer, Tan En De

From: Tan En De <ende.tan@starfivetech.com>

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.

Fixes: fab7d9057887 ("rt-tests: determine_maximum_mpps.sh: Get frequency from timebase-frequency if cpuinfo fails")
Signed-off-by: Tan En De <ende.tan@starfivetech.com>
---
 src/queuelat/determine_maximum_mpps.8  |  3 +++
 src/queuelat/determine_maximum_mpps.sh | 17 +++++++++--------
 2 files changed, 12 insertions(+), 8 deletions(-)

diff --git a/src/queuelat/determine_maximum_mpps.8 b/src/queuelat/determine_maximum_mpps.8
index ba2cc2a..bcd3078 100644
--- a/src/queuelat/determine_maximum_mpps.8
+++ b/src/queuelat/determine_maximum_mpps.8
@@ -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
diff --git a/src/queuelat/determine_maximum_mpps.sh b/src/queuelat/determine_maximum_mpps.sh
index adfd809..6a90ca0 100755
--- a/src/queuelat/determine_maximum_mpps.sh
+++ b/src/queuelat/determine_maximum_mpps.sh
@@ -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
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2024-12-12 15:48 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-12-11 17:11 [1/1] rt-tests: determine_maximum_mpps.sh: Introduce '-F' option to specify CPU frequency ende.tan
2024-12-11 19:25 ` John Kacur
2024-12-12  5:43   ` EnDe Tan
2024-12-12 15:48     ` John Kacur

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).