mirror of
https://github.com/ARM-software/devlib.git
synced 2025-01-31 02:00:45 +00:00
cpufreq: add functions to get frequencies and governors for all online CPUs
This patch adds a couple of shutils functions to efficiently read all the frequencies/governors and returne them into a dictionary indexed by CPU id. The shutils functions are returning a line per each CPU that can be easily converted into a dictionary in the host side. Signed-off-by: Patrick Bellasi <patrick.bellasi@arm.com>
This commit is contained in:
parent
cf761317bd
commit
51b7f01d36
@ -18,6 +18,11 @@ cpufreq_set_all_frequencies() {
|
|||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cpufreq_get_all_frequencies() {
|
||||||
|
$GREP '' /sys/devices/system/cpu/cpu*/cpufreq/scaling_cur_freq | \
|
||||||
|
$SED -e 's|/sys/devices/system/cpu/cpu||' -e 's|/cpufreq/scaling_cur_freq:| |'
|
||||||
|
}
|
||||||
|
|
||||||
cpufreq_set_all_governors() {
|
cpufreq_set_all_governors() {
|
||||||
GOV=$1
|
GOV=$1
|
||||||
for CPU in /sys/devices/system/cpu/cpu[0-9]*; do
|
for CPU in /sys/devices/system/cpu/cpu[0-9]*; do
|
||||||
@ -25,6 +30,11 @@ cpufreq_set_all_governors() {
|
|||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cpufreq_get_all_governors() {
|
||||||
|
$GREP '' /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor | \
|
||||||
|
$SED -e 's|/sys/devices/system/cpu/cpu||' -e 's|/cpufreq/scaling_governor:| |'
|
||||||
|
}
|
||||||
|
|
||||||
cpufreq_trace_all_frequencies() {
|
cpufreq_trace_all_frequencies() {
|
||||||
FREQS=$(cat /sys/devices/system/cpu/cpu*/cpufreq/scaling_cur_freq)
|
FREQS=$(cat /sys/devices/system/cpu/cpu*/cpufreq/scaling_cur_freq)
|
||||||
CPU=0; for F in $FREQS; do
|
CPU=0; for F in $FREQS; do
|
||||||
@ -41,9 +51,15 @@ case $CMD in
|
|||||||
cpufreq_set_all_frequencies)
|
cpufreq_set_all_frequencies)
|
||||||
cpufreq_set_all_frequencies $*
|
cpufreq_set_all_frequencies $*
|
||||||
;;
|
;;
|
||||||
|
cpufreq_get_all_frequencies)
|
||||||
|
cpufreq_get_all_frequencies
|
||||||
|
;;
|
||||||
cpufreq_set_all_governors)
|
cpufreq_set_all_governors)
|
||||||
cpufreq_set_all_governors $*
|
cpufreq_set_all_governors $*
|
||||||
;;
|
;;
|
||||||
|
cpufreq_get_all_governors)
|
||||||
|
cpufreq_get_all_governors
|
||||||
|
;;
|
||||||
cpufreq_trace_all_frequencies)
|
cpufreq_trace_all_frequencies)
|
||||||
cpufreq_trace_all_frequencies $*
|
cpufreq_trace_all_frequencies $*
|
||||||
;;
|
;;
|
||||||
|
@ -357,6 +357,19 @@ class CpufreqModule(Module):
|
|||||||
'cpufreq_set_all_frequencies {}'.format(freq),
|
'cpufreq_set_all_frequencies {}'.format(freq),
|
||||||
as_root=True)
|
as_root=True)
|
||||||
|
|
||||||
|
def get_all_frequencies(self):
|
||||||
|
"""
|
||||||
|
Get the current frequency for all the (online) CPUs
|
||||||
|
"""
|
||||||
|
output = self.target._execute_util(
|
||||||
|
'cpufreq_get_all_frequencies', as_root=True)
|
||||||
|
frequencies = {}
|
||||||
|
for x in output.splitlines():
|
||||||
|
kv = x.split(' ')
|
||||||
|
if kv[0] == '':
|
||||||
|
break
|
||||||
|
frequencies[kv[0]] = kv[1]
|
||||||
|
return frequencies
|
||||||
|
|
||||||
def set_all_governors(self, governor):
|
def set_all_governors(self, governor):
|
||||||
"""
|
"""
|
||||||
@ -366,6 +379,19 @@ class CpufreqModule(Module):
|
|||||||
'cpufreq_set_all_governors {}'.format(governor),
|
'cpufreq_set_all_governors {}'.format(governor),
|
||||||
as_root=True)
|
as_root=True)
|
||||||
|
|
||||||
|
def get_all_governors(self):
|
||||||
|
"""
|
||||||
|
Get the current governor for all the (online) CPUs
|
||||||
|
"""
|
||||||
|
output = self.target._execute_util(
|
||||||
|
'cpufreq_get_all_governors', as_root=True)
|
||||||
|
governors = {}
|
||||||
|
for x in output.splitlines():
|
||||||
|
kv = x.split(' ')
|
||||||
|
if kv[0] == '':
|
||||||
|
break
|
||||||
|
governors[kv[0]] = kv[1]
|
||||||
|
return governors
|
||||||
|
|
||||||
def trace_frequencies(self):
|
def trace_frequencies(self):
|
||||||
"""
|
"""
|
||||||
|
Loading…
x
Reference in New Issue
Block a user