765f41219e416884192700830e272563cba1d446
[kvmfornfv.git] / docs / design / kvmfornfv_design.rst
1 .. This work is licensed under a Creative Commons Attribution 4.0 International License.
2 .. http://creativecommons.org/licenses/by/4.0
3
4 ==========================
5 KVM4NFV design description
6 ==========================
7
8 This design focuses on the enhancement of following area for KVM Hypervisor
9
10 * Minimal Interrupt latency variation for data plane VNFs:
11    * Minimal Timing Variation for Timing correctness of real-time VNFs
12    * Minimal packet latency variation for data-plane VNFs
13 * Fast live migration
14
15 **Minimal Interrupt latency variation for data plane VNFs**
16
17 Processing performance and latency depend on a number of factors, including
18 the CPUs (frequency, power management features, etc.), micro-architectural
19 resources, the cache hierarchy and sizes, memory (and hierarchy, such as NUMA)
20 and speed, inter-connects, I/O and I/O NUMA, devices, etc.
21
22 There are two separate types of latencies to minimize:
23
24    1. Minimal Timing Variation for Timing correctness of real-time
25       VNFs – timing correctness for scheduling operations(such as Radio scheduling)
26    2. Minimal packet latency variation for data-plane VNFs – packet delay
27       variation, which applies to packet processing.
28
29 For a VM, interrupt latency (time between arrival of H/W interrupt and
30 invocation of the interrupt handler in the VM), for example, can be either of
31 the above or both, depending on the type of the device. Interrupt latency with
32 a (virtual) timer can cause timing correctness issues with real-time VNFs even
33 if they only use polling for packet processing.
34
35 We assume that the VNFs are implemented properly to minimize interrupt latency
36 variation within the VMs, but we have additional causes of latency variation
37 on KVM:
38
39     - Asynchronous (e.g. external interrupts) and synchronous(e.g. instructions)
40       VM exits and handling in KVM (and kernel routines called), which may have
41       loops and spin locks
42     - Interrupt handling in the host Linux and KVM, scheduling and virtual
43       interrupt delivery to VNFs
44     - Potential VM exit (e.g. EOI) in the interrupt service routines in VNFs
45     - Exit to the user-level (e.g. QEMU)
46
47 .. Figure:: kvm1.png
48
49
50 Design Considerations
51 ---------------------
52
53 The latency variation and jitters can be minimized with the below
54 steps (with some in parallel):
55
56     1. Statically and exclusively assign hardware resources
57        (CPUs, memory, caches,) to the VNFs.
58
59     2. Pre-allocate huge pages (e.g. 1 GB/2MB pages) and guest-to-host mapping,
60        e.g. EPT (Extended Page Table) page tables, to minimize or mitigate
61        latency from misses in caches,
62
63     3. Use the host Linux configured for hard real-time and packet latency,
64        Check the set of virtual devices used by the VMs to optimize or
65        eliminate virtualization overhead if applicable
66
67     4. Use advanced hardware virtualization features that can reduce or
68        eliminate VM exits, if present, and
69
70     5. Inspect the code paths in KVM and associated kernel services to
71        eliminate code that can cause latencies (e.g. loops and spin locks).
72
73     6. Measure latencies intensively. We leverage the existing testing methods.
74        OSADL, for example, defines industry tests for timing correctness.
75
76
77 Goals and Guidelines
78 --------------------
79
80 The output of this project will provide :
81
82     1. A list of the performance goals, which will be obtained by the
83        OPNFV members (as described above)
84
85     2. A set of comprehensive instructions for the system configurations
86        (hardware features, BIOS setup, kernel parameters, VM configuration,
87        options to QEMU/KVM, etc.)
88
89     3. The above features to the upstream of Linux, the real-time patch
90        set, KVM, QEMU, libvirt, and
91
92     4. Performance and interrupt latency measurement tools
93
94
95 Test plan
96 ---------
97
98 The tests that need to be conducted to make sure that all components from OPNFV
99 meet the requirement are mentioned below:
100
101 **Timer test**:This test utilize the cyclictest
102 (https://rt.wiki.kernel.org/index.php/Cyclictest) to test the guest timer
103 latency (the latency from the time that the guest timer should be triggered
104 to the time the guest timer is really triggered).
105
106 .. Figure:: TimerTest.png
107
108 **Device Interrupt Test**:A device on the hardware platform trigger interrupt
109 every one ms and the device interrupt will be delivered to the VNF. This test
110 cover the latency from the interrupt happened on the hardware to the time the
111 interrupt handled in the VNF.
112
113 .. Figure:: DeviceInterruptTest.png
114
115 **Packet forwarding (DPDK OVS)**:A packet is sent from TG (Traffic Generator)
116 to a VNF.  The VNF, after processing the packet, forwards the packet to another
117 NIC and in the end the packet is received by the traffic generator. The test
118 check the latency from the packet is sent out by the TC to the time the packet
119 is received by the TC.
120
121 .. Figure:: PacketforwardingDPDK_OVS.png
122
123 **Packet Forwarding (SR-IOV)**:This test is similar to Packet Forwarding
124 (DPDK OVS). However, instead of using virtio NIC devices on the guest,
125 a PCI NIC or a PCI VF NIC is assigned to the guest for network acess.
126
127 **Bare-metal Packet Forwarding**:This is used to compare with the above
128 packet forwarding scenario.
129
130 .. Figure:: Bare-metalPacketForwarding.png
131
132 ----------
133 Reference
134 ----------
135
136 https://wiki.opnfv.org/display/kvm/