Faster Virtualization Technique-Virtualization Support / Extension

When using a virtual machine, people may dream to have a virtual machine running as fast as the real machine so that playing games on MAC or Linux can be true. While dreaming that, there is a very important concept you need to know, virtualization overhead.

Virtualization overhead comes from the resource sharing because we want to run our guest machine without stopping host machine. What happen if we run two discrete OS together on the same computer while there is only one hardware resource? The result will be a disaster. For example, you order a dinner and your mother order a dinner too. Because you don’t know what each other has done, you will have two dinners to your home!! The worst case is, you put your putting in a refrigerator, and your sisters take it since she thought the putting belongs to no one. In the world of the computer, this is a very common problem in multi-tasking. People solve this by adopting OS to control all the resources and make sure every process can only access its own memory, CPU, etc. I called this OS-level virtualization.
The solution of running discrete OS without knowing each other’s existence is like OS level virtualization. However, after multi-tasking era, people start to run multiple virtual machines on a single computer. The very first solution is from Java virtual machine. By using an interpreter, JVM can translate and run codes simultaneously as well as manage the memory space. By some technique, the first emulator comes out, the common one is called QEMU. You can see QEMU’s homepage or wiki understand more.
After having some emulators like QEMU, Virtualbox, VMware and Parallel Desktop, people started to realize that it’s still slow!!! The bottleneck of running virtual machines is on OS! Because OS manage the host process-virtual machine while virtual machine adopts many functions and system calls to manage (virtualize) the virtual resource of the upper guest OS’s functionality(interrupt, scheduling, preemption, access hardware, etc.). It’s TWO levels overhead of running a process in guest OS. Besides, the processes in host OS are still running and taking away the CPU resource. Thus, we need the hardware support to help to do this process!!
Nowadays, virtual machines use the CPU virtualization extension instructions to do the jobs, many of them use KVM as the core library of doing so. In short, CPU virtualization extension instruction is the instruction to do some context switch, register swapping, multiple primitive modes(rings in x86 CPU). These are jobs used to be done by software with a high penalty.


Now, here is the question, what if we want to play games in virtual machine, is there any solution to make it faster?

The solution of that is pretty easy since GPU is not a necessary resource for running host OS, we can easily dedicate the GPU resource to a VM. But this solution causes black screen for host OS because the VM is now in charge of GPU. We can definitely use the old software way to share GPU resource with host OS, but it’s slow. To solve that, we still use the same trick-hardware virtualization support. If the GPU can remember what resource belongs to which VM, VM can use the GPU directly without copying data in-and-out. Basically, the solution of device virtualization support is to have multiple resources for different VMs. Each VM can access their data without knowing resources are currently used or not. However, it’s a pity that no current discrete GPU support this function excepts intel’s Iris-pro. From Wiki:

Graphics Virtualization Technology was introduced with Intel Iris Pro. Intel’s integrated GPU can be either dedicatedly assigned to a virtual machine (GVT-d), shared between multiple virtual machines on a time-sharing basis while using native graphics driver (GVT-g), or shared between multiple virtual machines by using a virtual graphics driver (GVT-s).[41]

Now, what if we want to share Ethernet resource? The solution of that is the same as GPU-hardware virtualization support!!! To make it easy to understand (I know you might feel the explanation above is not detailed and easy enough), I prepare a video to let you know the whole bunch ideas of what a hardware virtualization support is. The idea is the same in CPU, GPU, etc. Let me introduce you the SR-IOV(Single Root IO Virtualization)!!!

All in all, virtualization support is necessary for modern system to make VMs faster. The idea would soon be as common as OS manages processes. OS also has some instruction support to save/restore registers in a single instruction. The result of doing SR-IOV on Ethernet is amazing as mentioned in this paper. The throughput in VM is almost identical as in host while having a small increase in latency. Here is what this paper mentioned:

Recently SR-IOV support for InfiniBand has been added by Mellanox in the ConnectX series adapters. Initial evaluation of SRIOV InfiniBand within KVM VMs has proven has found point-topoint bandwidth to be near-native, but up to 30% latency overhead for very small messages [18, 29]. However, even with the noted overhead, this still signifies up to an order of magnitude difference in latency between InfiniBand and Ethernet with VMs. Furthermore, advanced configuration of SR-IOV enabled InfiniBand fabric is taking shape, with recent research showing up to a 30% reduction in the latency overhead [24]. However, real application performance has not yet been well understood until now.


[1] x86 Virtualization

[2] Intel Virtualization technology

[3] Supporting High Performance Molecular Dynamics in Virtualized Clusters using IOMMU, SR-IOV, and GPUDirect

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s