You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何确定QEMU模拟ARMv8 CPU的运行频率?

QEMU模拟ARMv8系统中获取CPU频率的问题

在QEMU模拟器运行的ARMv8(Linux-aarch64)架构Ubuntu系统中做基础测试,需要获取CPU当前运行频率(优先标称频率),但lscpu、cat /proc/cpuinfo都无法得到相关信息,同类问题的Stack Exchange解答也没有帮助。


1. 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?


2. 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:

3. dmidecode -t processor的输出

该命令显示CPU标称2GHz,但不确定其准确性:

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

4. 手动计算频率的结果

通过休眠若干秒并读取CPU循环计数器差值的方法计算频率,得到结果约为1GHz。


核心疑问

是否存在其他软件方法或硬件寄存器可以获取ARM CPU的频率?


补充:真实ARMv8硬件的测试结果

让同事在真实ARMv8硬件上执行perf stat sleep 1,得到如下输出(该硬件实际运行在1GHz,结果与perf stat显示一致):

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

对比QEMU模拟环境的结果,是否可以判定模拟CPU也运行在1GHz?


内容的提问来源于stack exchange,提问作者wangt13

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.23 03:45:43