【发布时间】:2022-08-14 08:46:25
【问题描述】:
我正在 Ubuntu 中为 ARMv8 (Linux-aarch64) 运行一些基本测试QEMU 模拟器.
我想获取当前 CPU 的频率,但是从 lscpu 或 cat /proc/cpuinfo 的输出中,没有 CPU 频率信息。
类似question in stackexchange 的答案对我帮助不大。perf stat sleep 1 的输出如下,
Performance counter stats for \'sleep 1\':
36.845824 task-clock (msec) # 0.034 CPUs utilized
1 context-switches # 0.027 K/sec
0 cpu-migrations # 0.000 K/sec
49 page-faults # 0.001 M/sec
36,759,401 cycles # 0.998 GHz
<not supported> instructions
<not supported> branches
<not supported> branch-misses
1.068524527 seconds time elapsed
我可以说CPU是1GHz吗?
cpupower 的输出没有显示 CPU 频率,
t@ubuntu:~/test/kermod$ sudo cpupower monitor
No HW Cstate monitors found
t@ubuntu:~/test/kermod$ sudo cpupower frequency-info
analyzing CPU 0:
no or unknown cpufreq driver is active on this CPU
CPUs which run at the same hardware frequency: Not Available
CPUs which need to have their frequency coordinated by software: Not Available
maximum transition latency: Cannot determine or is not supported.
Not Available
available cpufreq governors: Not Available
Unable to determine current policy
current CPU frequency: Unable to call hardware
current CPU frequency: Unable to call to kernel
t@ubuntu:~/test/kermod$ sudo cpupower info
System does not support Intel\'s performance bias setting
analyzing CPU 0:
dmidecode -t processor 显示,
t@ubuntu:~/test/kermod$ sudo dmidecode -t processor
# dmidecode 3.1
Getting SMBIOS data from sysfs.
SMBIOS 3.0.0 present.
Handle 0x0400, DMI type 4, 42 bytes
Processor Information
Socket Designation: CPU 0
Type: Central Processor
Family: Other
Manufacturer: QEMU
ID: 00 00 00 00 00 00 00 00
Version: virt-4.2
Voltage: Unknown
External Clock: Unknown
Max Speed: 2000 MHz
Current Speed: 2000 MHz
Status: Populated, Enabled
Upgrade: Other
L1 Cache Handle: Not Provided
L2 Cache Handle: Not Provided
L3 Cache Handle: Not Provided
Serial Number: Not Specified
Asset Tag: Not Specified
Part Number: Not Specified
Core Count: 1
Core Enabled: 1
Thread Count: 1
Characteristics: None
它说 CPU 是 2GHz,但我不确定这是否正确。
我可以使用的另一种方法是休眠几秒钟并读取 CPU 中循环计数器的差异来计算频率。但是我得到的CPU频率大约是1GHz。
或者有什么软件或硬件寄存器可以告诉我ARM CPU的频率吗?
** 编辑 **
我让我的同事在他读取的 ARMv8 硬件中运行perf stat sleep 1,我们得到了,
Performance counter stats for \'sleep 1\':
1.89 msec task-clock # 0.002 CPUs utilized
1 context-switches # 0.530 K/sec
0 cpu-migrations # 0.000 K/sec
43 page-faults # 0.023 M/sec
1859822 cycles # 0.985 GHz
758842 instructions # 0.41 insn per cycle
91818 branches # 48.632 M/sec
12077 branch-misses # 13.15% of all branches
1.003838600 seconds time elapsed
0.004158000 seconds user
0.000000000 seconds sys
他的 ARMv8 以 1GHz 运行,与 perf stat 的输出相匹配。
与 QEMU 仿真相比,仿真的 CPU 也应该运行在 1GHz,对吗?
-
/sys/devices/system/cpu/cpu0/cpufreq/中有什么内容 -
我的 Ubuntu Aarch64 中没有这样的文件