QEMU 中的启动时间是什么意思?

What does the boot time means in the QEMU?

当我在qemu上启动linux时,启动日志中的时间戳如下,

[    0.000000] Initializing cgroup subsys cpuset
[    0.000000] Initializing cgroup subsys cpu
[    0.000000] Initializing cgroup subsys cpuacct
[    0.000000] Linux version 3.10.0 (zlp@lab302i-ES) (gcc version 4.9.3 20150626 (Red Hat 4.9.3-2) (GCC) ) #33 PREEMPT Mon Dec 2 14:39:51 CST 2019
[    0.000000] Config serial console: console=ttyS0,38400n8r
[    0.000000] bootconsole [early0] enabled
[    0.000000] CPU revision is: 00018900 (MIPS 5KE)
[    0.000000] FPU revision is: 00738900
[    0.000000] Software DMA cache coherency enabled
[    0.000000] Determined physical RAM map:
[    0.000000]  memory: 0000000000001000 @ 0000000000000000 (reserved)
[    0.000000]  memory: 00000000000ef000 @ 0000000000001000 (ROM data)
[    0.000000]  memory: 000000000071c000 @ 00000000000f0000 (reserved)
[    0.000000]  memory: 000000000f7f4000 @ 000000000080c000 (usable)
[    0.000000] Wasting 28840 bytes for tracking 515 unused pages
[    0.000000] Reserving 0MB of memory at 0MB for crashkernel
[    0.000000] Kernel command line: rd_start=0xffffffff80810000 rd_size=16642887 root=/dev/ram0 nokaslr console=ttyS0,38400n8r
[    0.000000] PID hash table entries: 1024 (order: -1, 8192 bytes)
[    0.000000] Dentry cache hash table entries: 32768 (order: 4, 262144 bytes)
[    0.000000] Inode-cache hash table entries: 16384 (order: 3, 131072 bytes)
[    0.000000] Cache parity protection disabled
[    0.000000] allocated 262128 bytes of page_cgroup
[    0.000000] please try 'cgroup_disable=memory' option if you don't want memory cgroups
[    0.000000] Memory: 252272k/253904k available (4743k kernel code, 1632k reserved, 1899k data, 320k init, 0k highmem)
[    0.000000] SLUB: HWalign=64, Order=0-3, MinObjects=0, CPUs=1, Nodes=1
[    0.000000] Preemptible hierarchical RCU implementation.
[    0.000000] NR_IRQS:256
[    0.000000] Console: colour dummy device 80x25
[    0.000000] Calibrating delay loop... 1145.06 BogoMIPS (lpj=2236416)
[    0.074218] pid_max: default: 32768 minimum: 301
[    0.074218] Security Framework initialized
[    0.074218] AppArmor: AppArmor disabled by boot time parameter
[    0.074218] Mount-cache hash table entries: 1024
[    0.078125] Initializing cgroup subsys memory
[    0.078125] Initializing cgroup subsys devices
[    0.078125] Initializing cgroup subsys freezer
[    0.078125] Initializing cgroup subsys blkio
[    0.078125] Initializing cgroup subsys perf_event
[    0.089843] devtmpfs: initialized
[    0.093750] NET: Registered protocol family 16
...

在真板中,时间戳就是开机时间。现在在QEMU中,是什么意思?

QEMU 运行 linux 启动代码是实时消耗的时间吗?准确吗?

这个时间戳好像比真板要短。是因为QEMU没有真正的I/O操作吗?

能否通过QEMU boot log来评估真实板卡内核启动各部分的实时耗时或时间占比?

在 QEMU 中,它表示 linux 感知的访客时间。它与主机时间的关系取决于用于时间测量的仿真时钟设备。

Guest linux 内核通常会读取该模拟时钟设备的某些寄存器,并使用在某处配置或由内核测量的时钟频率将其转换为系统时间。

仿真时钟设备可以公开基于 QEMU internal clock types 之一的时钟,通常是 QEMU_CLOCK_VIRTUAL,但不限于此。

当使用 QEMU_CLOCK_VIRTUAL 时,它的滴答方式取决于 QEMU 是否使用 -icount 开关启动。当 -icount 未使用时,当客户机 CPU 为 运行ning 时,QEMU_CLOCK_VIRTUAL 与主机时钟同步。当使用 -icount 时,它指定每个执行的客户指令花费多少纳秒的 QEMU_CLOCK_VIRTUAL 时间。 QEMU_CLOCK_VIRTUAL 然后根据来宾执行的来宾指令数 CPU 按比例计时。当 guest CPU 不执行 guest 指令时它也会打勾(例如暂停等待中断)但我不知道细节。

Is it the real time consumed by the QEMU to run the linux boot code? Is it accurate?

它与 QEMU 到 运行 linux 引导代码所用的时间有一定关系,但并不完全是它,它取决于来宾内核配置、模拟硬件和方式QEMU 已启动。