Operating System Support for Virtual Machines
description
Transcript of Operating System Support for Virtual Machines
![Page 1: Operating System Support for Virtual Machines](https://reader035.fdocuments.in/reader035/viewer/2022062323/5681681f550346895dddaedc/html5/thumbnails/1.jpg)
Operating System Support for Virtual Machines
Samuel King, George Dunlap, Peter Chen
Univ of Michigan
Ashish Gupta
![Page 2: Operating System Support for Virtual Machines](https://reader035.fdocuments.in/reader035/viewer/2022062323/5681681f550346895dddaedc/html5/thumbnails/2.jpg)
Two classifications for VM
Higher Level Interface
VM/370VMWare
DenaliUMLinuxSimOSXen
VMWare Guest toolsVAX VMM Security Kernel
u-kernels JVM
1
![Page 3: Operating System Support for Virtual Machines](https://reader035.fdocuments.in/reader035/viewer/2022062323/5681681f550346895dddaedc/html5/thumbnails/3.jpg)
Two classifications for VM
Underlying Platform
VM/370VMWare ESXDiscoDenaliXen
VMWare WorkstationVirtualPC
SimOSUMLinux
2
Type IIType I
ConveniencePerformance
![Page 4: Operating System Support for Virtual Machines](https://reader035.fdocuments.in/reader035/viewer/2022062323/5681681f550346895dddaedc/html5/thumbnails/4.jpg)
UMLinux• Higher level interface slightly different• Guest OS needs to be modified
– Simple device drivers added– Emulation of certain instructions (iret and in/out)– Kernel Re-linked to different address
• 17,000 lines of change• ptrace virtualization
– Intercepts guest system calls– Tracks transitions
![Page 5: Operating System Support for Virtual Machines](https://reader035.fdocuments.in/reader035/viewer/2022062323/5681681f550346895dddaedc/html5/thumbnails/5.jpg)
Advantage of Type II VM
Guest Machine Process
Virtual CPU
Host files anddevices
Virtual I/O Devices
Host SignalsVirtual
Interrupts
mmapmunmap
Virtual MMU
![Page 6: Operating System Support for Virtual Machines](https://reader035.fdocuments.in/reader035/viewer/2022062323/5681681f550346895dddaedc/html5/thumbnails/6.jpg)
The problem
![Page 7: Operating System Support for Virtual Machines](https://reader035.fdocuments.in/reader035/viewer/2022062323/5681681f550346895dddaedc/html5/thumbnails/7.jpg)
Compiling the Linux Kernel
+ 510 lines to Host OS
![Page 8: Operating System Support for Virtual Machines](https://reader035.fdocuments.in/reader035/viewer/2022062323/5681681f550346895dddaedc/html5/thumbnails/8.jpg)
Compiling the Linux Kernel
+ 510 lines to Host OS
![Page 9: Operating System Support for Virtual Machines](https://reader035.fdocuments.in/reader035/viewer/2022062323/5681681f550346895dddaedc/html5/thumbnails/9.jpg)
Optimization OneSystem calls
![Page 10: Operating System Support for Virtual Machines](https://reader035.fdocuments.in/reader035/viewer/2022062323/5681681f550346895dddaedc/html5/thumbnails/10.jpg)
![Page 11: Operating System Support for Virtual Machines](https://reader035.fdocuments.in/reader035/viewer/2022062323/5681681f550346895dddaedc/html5/thumbnails/11.jpg)
Lots of context switches betweenVMM < -- > Guest machine process
![Page 12: Operating System Support for Virtual Machines](https://reader035.fdocuments.in/reader035/viewer/2022062323/5681681f550346895dddaedc/html5/thumbnails/12.jpg)
Use VMM as a Kernel module
Modification to Host OS also…
![Page 13: Operating System Support for Virtual Machines](https://reader035.fdocuments.in/reader035/viewer/2022062323/5681681f550346895dddaedc/html5/thumbnails/13.jpg)
?
![Page 14: Operating System Support for Virtual Machines](https://reader035.fdocuments.in/reader035/viewer/2022062323/5681681f550346895dddaedc/html5/thumbnails/14.jpg)
0
2
4
6
8
10
12
14
16
18
POV-Ray SPECweb 99 Kernel Build
Nor
mal
ized
Run
time
VMware Workstation 3.1Original UMLinuxUMLinux + VMM in host
![Page 15: Operating System Support for Virtual Machines](https://reader035.fdocuments.in/reader035/viewer/2022062323/5681681f550346895dddaedc/html5/thumbnails/15.jpg)
Optimization TwoMemory protection
![Page 16: Operating System Support for Virtual Machines](https://reader035.fdocuments.in/reader035/viewer/2022062323/5681681f550346895dddaedc/html5/thumbnails/16.jpg)
Frequent switching between Guest Kernel and Guest application
![Page 17: Operating System Support for Virtual Machines](https://reader035.fdocuments.in/reader035/viewer/2022062323/5681681f550346895dddaedc/html5/thumbnails/17.jpg)
Guest Kernel to Guest User
![Page 18: Operating System Support for Virtual Machines](https://reader035.fdocuments.in/reader035/viewer/2022062323/5681681f550346895dddaedc/html5/thumbnails/18.jpg)
Guest User to Guest Kernel
Through mmap, munmap and mprotect
Very expensive…
![Page 19: Operating System Support for Virtual Machines](https://reader035.fdocuments.in/reader035/viewer/2022062323/5681681f550346895dddaedc/html5/thumbnails/19.jpg)
Host Linux Memory Management• x86 paging provides built-in protection to memory
pages• Linux uses page tables for translation and protection• Segments used only to switch between privilege
levels• Uses supervisor bit to disallow ring 3 to access
certain pages
The idea: segments bound features are relatively unused
![Page 20: Operating System Support for Virtual Machines](https://reader035.fdocuments.in/reader035/viewer/2022062323/5681681f550346895dddaedc/html5/thumbnails/20.jpg)
Solution:
Change Segment bounds for each mode
![Page 21: Operating System Support for Virtual Machines](https://reader035.fdocuments.in/reader035/viewer/2022062323/5681681f550346895dddaedc/html5/thumbnails/21.jpg)
![Page 22: Operating System Support for Virtual Machines](https://reader035.fdocuments.in/reader035/viewer/2022062323/5681681f550346895dddaedc/html5/thumbnails/22.jpg)
0
2
4
6
8
10
12
14
16
18
POV-Ray SPECweb 99 Kernel Build
Nor
mal
ized
Run
time VMware Workstation 3.1
Original UMLinux
UMLinux + VMM in host
UMLinux + VMM in host + seg.bounds prot.
![Page 23: Operating System Support for Virtual Machines](https://reader035.fdocuments.in/reader035/viewer/2022062323/5681681f550346895dddaedc/html5/thumbnails/23.jpg)
Optimization ThreeContext Switching
![Page 24: Operating System Support for Virtual Machines](https://reader035.fdocuments.in/reader035/viewer/2022062323/5681681f550346895dddaedc/html5/thumbnails/24.jpg)
• The problem with context switching:– Have to remap user process’s virtual memory to
the “virtual” physical memory– Generates large number of mmaps costly
• The solution:– Allow one process to maintain multiple address-
spaces– Each address space different set of page tables– New system call : switch guest, whenever context
switching
![Page 25: Operating System Support for Virtual Machines](https://reader035.fdocuments.in/reader035/viewer/2022062323/5681681f550346895dddaedc/html5/thumbnails/25.jpg)
Multiple Page Table Sets
Page Table Ptr
Host operating system
Guest OS
guest proc aguest proc b
switchguest syscall
![Page 26: Operating System Support for Virtual Machines](https://reader035.fdocuments.in/reader035/viewer/2022062323/5681681f550346895dddaedc/html5/thumbnails/26.jpg)
0
2
4
6
8
10
12
14
16
18
POV-Ray SPECweb 99 Kernel Build
Nor
mal
ized
Run
time
VMware Workstation 3.1
Original UMLinux
UMLinux + VMM in host
UMLinux + VMM in host + seg.bounds prot.Fully optimized UMLinux
![Page 27: Operating System Support for Virtual Machines](https://reader035.fdocuments.in/reader035/viewer/2022062323/5681681f550346895dddaedc/html5/thumbnails/27.jpg)
Conclusion• Type II VMM CAN be as fast as type I
by modifying the Host OS
• Is the title of paper justified ?
![Page 28: Operating System Support for Virtual Machines](https://reader035.fdocuments.in/reader035/viewer/2022062323/5681681f550346895dddaedc/html5/thumbnails/28.jpg)
Virtualizing I/O Devices on VMware Workstation’s
Hosted VMM
Jeremy Sugerman, Ganesh Venkitachalam and Beng-Hong LimVMware, Inc.
![Page 29: Operating System Support for Virtual Machines](https://reader035.fdocuments.in/reader035/viewer/2022062323/5681681f550346895dddaedc/html5/thumbnails/29.jpg)
Introduction• VM Definition from IBM:
– a “virtual machine” is a fully protected and isolated copy of the underlying physical machine’s hardware.
• The choice for hosted architecture– Relies upon host OS for device support
• Primary Advantage– Copes with diversity of hardware– Compatible with pre-existing PC software– Near native performance for CPU intensive
workloads
![Page 30: Operating System Support for Virtual Machines](https://reader035.fdocuments.in/reader035/viewer/2022062323/5681681f550346895dddaedc/html5/thumbnails/30.jpg)
![Page 31: Operating System Support for Virtual Machines](https://reader035.fdocuments.in/reader035/viewer/2022062323/5681681f550346895dddaedc/html5/thumbnails/31.jpg)
The major tradeoff• I/O performance degradation• I/O emulation done in host world
– Switching between the host world and the VMM world
![Page 32: Operating System Support for Virtual Machines](https://reader035.fdocuments.in/reader035/viewer/2022062323/5681681f550346895dddaedc/html5/thumbnails/32.jpg)
How I/O works
VM App VMMVM
Driver
ApplicationPortion
PrivilegedPortion
I/O RequestI/O VirtualizationCPU Virtualization
H/w interruptInterrupt reasserted
![Page 33: Operating System Support for Virtual Machines](https://reader035.fdocuments.in/reader035/viewer/2022062323/5681681f550346895dddaedc/html5/thumbnails/33.jpg)
I/O Virtualization• VMM intercepts all I/O operations
– Usually privileged IN , OUT operations
• Emulated either in VMM on in VMApp
• Host OS drivers understand the semantics of port I/O, VMM doesn’t
• Physical Hardware I/O must be handled in Host OS
• Lot of Overhead from world switching– Which devices get affected ?– CPU gets saturated before I/O…
![Page 34: Operating System Support for Virtual Machines](https://reader035.fdocuments.in/reader035/viewer/2022062323/5681681f550346895dddaedc/html5/thumbnails/34.jpg)
The Goal of this paper
I/O CPU I/O CPU
![Page 35: Operating System Support for Virtual Machines](https://reader035.fdocuments.in/reader035/viewer/2022062323/5681681f550346895dddaedc/html5/thumbnails/35.jpg)
The Network Card• Virtual NIC appears as a full fledged PCI Ethernet
Controller, with its own MAC address
• Connection implemented by a VMNet driver loaded in the Host OS
• Virtual NIC : a combination of code in the VMM and VMApp– Virtual I/O Ports and Virtual IRQs
![Page 36: Operating System Support for Virtual Machines](https://reader035.fdocuments.in/reader035/viewer/2022062323/5681681f550346895dddaedc/html5/thumbnails/36.jpg)
![Page 37: Operating System Support for Virtual Machines](https://reader035.fdocuments.in/reader035/viewer/2022062323/5681681f550346895dddaedc/html5/thumbnails/37.jpg)
HOST
VMM
Sending a Packet
![Page 38: Operating System Support for Virtual Machines](https://reader035.fdocuments.in/reader035/viewer/2022062323/5681681f550346895dddaedc/html5/thumbnails/38.jpg)
VMM
HOST
HOST
Receiving a Packet
![Page 39: Operating System Support for Virtual Machines](https://reader035.fdocuments.in/reader035/viewer/2022062323/5681681f550346895dddaedc/html5/thumbnails/39.jpg)
Experimental Setup
Nettest: throughput tests
![Page 40: Operating System Support for Virtual Machines](https://reader035.fdocuments.in/reader035/viewer/2022062323/5681681f550346895dddaedc/html5/thumbnails/40.jpg)
Time profilingExtra work:
• Switching worlds for every I/O instruction: most expensive
• I/O interrupt for every packet sent and received:– VMM, host and guest interrupt handlers are run !
• Packet trans: two device drivers• Packet copy on transmit
![Page 41: Operating System Support for Virtual Machines](https://reader035.fdocuments.in/reader035/viewer/2022062323/5681681f550346895dddaedc/html5/thumbnails/41.jpg)
Optimization One• Primary aim: Reduce world switches• Idea: Only a third of the I/O instructions trigger
packet trans.– Emulate the rest in VMM
• The Lance NIC address I/O has memory semantics– I/O MOV !– Strips away several layers of virtualization
![Page 42: Operating System Support for Virtual Machines](https://reader035.fdocuments.in/reader035/viewer/2022062323/5681681f550346895dddaedc/html5/thumbnails/42.jpg)
Optimization Two• Very high interrupt rate for data trans.• When does a world switch occur:
– A packet is to be transmitted– A real interrupt occurs e.g. timer interrupt
• The Idea: Piggyback the packet interrupts on the real interrupts– Queue the packets in a ring buffer– Transmit all buffered packets on next switch
• Works well for I/O intensive workloads
![Page 43: Operating System Support for Virtual Machines](https://reader035.fdocuments.in/reader035/viewer/2022062323/5681681f550346895dddaedc/html5/thumbnails/43.jpg)
Packet Transmit
Real Interrupt
![Page 44: Operating System Support for Virtual Machines](https://reader035.fdocuments.in/reader035/viewer/2022062323/5681681f550346895dddaedc/html5/thumbnails/44.jpg)
Optimization Three• Reduce host system calls for packet sends
and receives• Idea: Instead of select, use a shared bit-vector,
to indicate packet availability• Eliminates costly select() ?
![Page 45: Operating System Support for Virtual Machines](https://reader035.fdocuments.in/reader035/viewer/2022062323/5681681f550346895dddaedc/html5/thumbnails/45.jpg)
Summary of three optimizations
Native
VM/733 MHzVersion 2.0
VM/733 MHzOptimized
Guest OS idles
![Page 46: Operating System Support for Virtual Machines](https://reader035.fdocuments.in/reader035/viewer/2022062323/5681681f550346895dddaedc/html5/thumbnails/46.jpg)
Summary of three optimizations
Native
VM/350 MHzVersion 2.0
VM/350 MHzOptimized
![Page 47: Operating System Support for Virtual Machines](https://reader035.fdocuments.in/reader035/viewer/2022062323/5681681f550346895dddaedc/html5/thumbnails/47.jpg)
Most effective Optimization ?• Emulating IN and OUT to Lance I/O ports
directly in VMM• Why ?
– Eliminates lots of world switches– I/O changed to MOV instruction
![Page 48: Operating System Support for Virtual Machines](https://reader035.fdocuments.in/reader035/viewer/2022062323/5681681f550346895dddaedc/html5/thumbnails/48.jpg)
Further avenues for Optimization ?• Modify the Guest OS
– Substitute expensive-to-virtualize instructions e.g. MMU instructions . Example ??
– Import some OS functionality into VMM– Tradeoff: can use off-the-shelf Oses
• An idealized virtual NIC (Example ??)– Only one I/O for packet transmit instead of 12 !– Cost: custom device drivers for every OS– VMWare Server version
![Page 49: Operating System Support for Virtual Machines](https://reader035.fdocuments.in/reader035/viewer/2022062323/5681681f550346895dddaedc/html5/thumbnails/49.jpg)
Further avenues for Optimization ?• Modify the Host OS: Example ??
– Change the Linux networking stack• Poor buffer management
– Cost: requires co-operation from OS Vendors
• Direct Control of Hardware: VMWare ESX– Fundamental limitations of Hosted Architecture– Idea: Let VMM drive I/O directly, no switching– Cost ??