作者:张华 发表于:2020-12-18
版权声明:可以任意转载,转载时请务必以超链接形式标明文章原始出处和作者信息及本版权声明
要想在KVM Guest中使用TSC, 须做两件事:
1, 添加invtsc flag
<cpu mode="host-model" check="partial">
<feature policy="require" name="invtsc"/>
</cpu>
juju中这样设置:
juju config nova-compute-kvm cpu-model-extra-flags="invtsc"
2, grub中添加:clocksource=tsc tsc=reliable
如果kernel有这个patch (https://github.com/torvalds/linux/commit/7539b174aef405d9d57db48c58390ba360c91312) 可以省掉clocksource=tsc, It was merged in 5.1, and would need to be backported to the 4.4 and 4.15
kernels if we want to use it.
如果kernel有这个patch (https://github.com/torvalds/linux/commit/36374583f9084cdab4b5dcf5521a3ce55bebb9fa)可以省掉rsc=reliable
3, QEMU中需有这个patch - https://git.qemu.org/?p=qemu.git;a=commitdiff;h=303752a
4, 验证:
$ cat /sys/devices/system/clocksource/clocksource0/current_clocksource
tsc
5, 早期的QEMU版本在支持TSC后却不支持live-migration, 但Ussuri是支持both TSC和live-migration的,要同时支持的话,须也定义下列的 frequency=‘3203150000’
<clock offset='utc'>
...
<timer name='tsc' frequency='3203150000'/>
</clock>