HyperBench is a set of micro-benchmarks for analyzing how much hardware mechanisms and hypervisor designs support virtualization. HyperBench is implemented as a a custom Linux kernel driver, which runs in a VM. Currently, it can run on both x86 and ARM platforms. There are 8 micro-benchmarks currently covering CPU, memory system, and I/O. These benchmarks cause various hypervisor-level events, such as transitions between VMs and the hypervisor, two-dimensional page walk, and notification from front-end to back-end driver. HyperBench aimed at quantifying these costs.
git clone https://github.com/Second222None/HyperBench-V2.0.git -b dev
cd Hyperbench-V2.0
sudo ./loop.sh
If the kernel is installed from source code. The compile command looks like so (our kernel version linux-5.0):
make BASEINCLUDE=~/linux-5.0
Prerequisite
+---------+ +---------+
| Host | | VM |
+----+----+ +----+----+
| |
| |
|<---------hyperbench--------+
| |
+------------start---------->|
| |
|<------------ack------------+
| |
|<----------finish-----------+
| |
|------------stop----------->|
| |
|<-----------ack-------------+
| |
|<----------finish-----------+
| |
|<------------scp------------+
| |
Host:
python server.py
VM: This command executes automatically after the vm boots.
python client.py 10.10.27.18 hyperbench
Start the above command automatically after the VM has booted.
[Unit]
Description=HyperBench
After=network.target auditd.service
ConditionPathExists=/home/ubuntu/HyperBench-V2.0/hyperbench.sh
ConditionUser=root
[Service]
ExecStart=/home/ubuntu/HyperBench-V2.0/hyperbench.sh
[Install]
WantedBy=multi-user.target
Alias=hyperbench.service
sudo systemctl enable /home/ubuntu/HyperBench-V2.0/hyperbench.service
sudo systemctl status hyperbench.service
E7-4820v2
Idle benchmark performs two consecutive reads of the time counter. It is used to check the stability of the measurement results. Ideally, the result is zero.
Nearly all CPU virtualization techniques are developed to handle sensitive instructions correctly. Therefore, sensitive instructions are necessary for comparing different CPU virtualization techniques.
for(i = 0 ; i < ITERATION ; i++) {
addr = (char *)vmalloc(1 << 12);
get_cycles();
benchmark();
get_cycles();
add_delta_to_sum() ;
vfree(addr);
}
<cputune>
<vcpupin vcpu="0" cpuset="4"/>
<vcpupin vcpu="1" cpuset="5"/>
<vcpupin vcpu="2" cpuset="6"/>
<vcpupin vcpu="3" cpuset="7"/>
</cputune>
service irqbalance stop
isolcpus=4,5,6,7
check
ps -eLo psr,args|awk '{if ($1==4) print $0}'
echo 30 > /proc/sys/kernel/watchdog_thresh
Notes:
禁用intel_pstate的方法,grub命令行中添加intel_pstate=disable。禁用后将使用driver: acpi-cpufreq驱动。
在非虚拟化环境中,自定义的内核模块使能PMCCNTR在EL0的读权限,可以正常工作。然而,当开启虚拟机之后,虚拟机中的计时程序可以正常工作,宿主机的计时程序会提示”Illegal Instruction”。原因是自定义的内核模块和perf_event驱动模块都会对PMU进行操作,从而造成冲突。 依据. It takes trap-and-emulate approach. When guest wants to monitor one event, it will be trapped by KVM and KVM will call perf_event API to create a perf event and call relevant perf_event APIs to get the count value of event. The gap between guest and host is very small. One reason for this I think is that it doesn’t count the cycles in EL2 and host since we add exclude_hv = 1(/* don’t count hypervisor */). So the cycles spent to store/restore registers which happens at EL2 are not included.