Published on

  • Be the first to comment

  • Be the first to like this

No Downloads
Total Views
On Slideshare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide


  1. 1. OS Structures - Xen
  2. 2. Xen
  3. 3. Key points <ul><li>Goal: extensibility akin to SPIN and Exokernel goals </li></ul><ul><li>Main difference: support running several commodity operating systems on the same hardware simultaneously without sacrificing performance or functionality </li></ul><ul><li>Why? </li></ul><ul><ul><li>Application mobility </li></ul></ul><ul><ul><li>Server consolidation </li></ul></ul><ul><ul><li>Co-located hosting facilities </li></ul></ul><ul><ul><li>Distributed web services </li></ul></ul><ul><ul><li>… . </li></ul></ul>
  4. 4. Old idea <ul><li>VM 370 </li></ul><ul><ul><li>Virtualization for binary support for legacy apps </li></ul></ul><ul><li>Why resurgence today? </li></ul><ul><ul><li>Companies want a share of everybody’s pie </li></ul></ul><ul><ul><ul><li>IBM zSeries “mainframes” support virtualization for server consolidation </li></ul></ul></ul><ul><ul><ul><ul><li>Enables billing and performance isolation while hosting several customers </li></ul></ul></ul></ul><ul><ul><ul><li>Microsoft has announced virtualization plans to allow easy upgrades and hosting Linux! </li></ul></ul></ul><ul><li>You can see the dots connecting up </li></ul><ul><ul><li>From extensibility (a la SPIN) to virtualization </li></ul></ul>
  5. 5. Possible virtualization approaches <ul><li>Standard OS (such as Linux, Windows) </li></ul><ul><ul><li>Meta services (such as grid) for users to install files and run processes </li></ul></ul><ul><ul><li>Administration, accountability, and performance isolation become hard </li></ul></ul><ul><li>Retrofit performance isolation into OSs </li></ul><ul><ul><li>Linux/RK, QLinux, SILK </li></ul></ul><ul><ul><li>Accounting resource usage correctly can be an issue unless done at the lowest level (e.g. Exokernel) </li></ul></ul><ul><li>Xen approach </li></ul><ul><ul><li>Multiplex physical resource at OS granularity </li></ul></ul>
  6. 6. Full virtualization <ul><li>Virtual hardware identical to real one </li></ul><ul><ul><li>Relies on hosted OS trapping to the VMM for privileged instructions </li></ul></ul><ul><ul><li>Pros: run unmodified OS binary on top </li></ul></ul><ul><ul><li>Cons: </li></ul></ul><ul><ul><ul><li>supervisor instructions can fail silently in some hardware platforms (e.g. x86) </li></ul></ul></ul><ul><ul><ul><ul><li>Solution in VMware: Dynamically rewrite portions of the hosted OS to insert traps </li></ul></ul></ul></ul><ul><ul><ul><li>need for hosted OS to see real resources: real time, page coloring tricks for optimizing performance, etc… </li></ul></ul></ul>
  7. 7. Xen principles <ul><li>Support for unmodified application binaries </li></ul><ul><li>Support for multi-application OS </li></ul><ul><ul><li>Complex server configuration within a single OS instance </li></ul></ul><ul><li>Paravirtualization for strong resource isolation on uncooperative hardware (x86) </li></ul><ul><li>Paravirtualization to enable optimizing guest OS performance and correctness </li></ul>
  8. 8. Xen: VM management <ul><li>What would make VM virtualization easy </li></ul><ul><ul><li>Software TLB </li></ul></ul><ul><ul><li>Tagged TLB =>no TLB flush on context switch </li></ul></ul><ul><ul><li>X86 does not have either </li></ul></ul><ul><li>Xen approach </li></ul><ul><ul><li>Guest OS responsible for allocating and managing hardware PT </li></ul></ul><ul><ul><li>Xen top 64MB of every address space. Why? </li></ul></ul>
  9. 9. x86 Memory Management <ul><li>Segments </li></ul><ul><ul><li>CS (code); SS (stack); DS, ES, FS, GS (all data) </li></ul></ul><ul><ul><li>Base address and limit checking </li></ul></ul><ul><li>Segment base concatenated with CPU address is the linear 32-bit virtual address </li></ul><ul><li>4KB pages </li></ul><ul><ul><li>Top 10 bits of address: page table </li></ul></ul><ul><ul><li>Next 10 bits of address: page table entry </li></ul></ul>
  10. 10. <ul><li>Creating a new PT by Guest OS </li></ul><ul><ul><li>allocate and initialize a page and registers it with Xen to serve as the new PT </li></ul></ul><ul><ul><li>all subsequent updates to this page (i.e. PT) via Xen </li></ul></ul><ul><ul><li>can batch updates to reduce the cost of entering and exiting Xen </li></ul></ul><ul><li>Segmentation by guest OS virtualized similarly </li></ul>
  11. 11. Xen: CPU virtualization <ul><li>Four privilege levels in x86 </li></ul><ul><ul><li>Ring 0 (Xen) </li></ul></ul><ul><ul><li>Ring 1 (guest OS) </li></ul></ul><ul><ul><li>Ring 3 (apps of the guest OS) </li></ul></ul><ul><li>Privileged instructions </li></ul><ul><ul><li>Validated and executed in Xen (e.g. installing a new PT) </li></ul></ul><ul><li>Exceptions </li></ul><ul><ul><li>Registered with Xen once </li></ul></ul><ul><ul><li>Called directly without Xen intervention </li></ul></ul><ul><ul><li>All syscalls from apps to guest OS handled this way </li></ul></ul><ul><li>Page fault handlers are special </li></ul><ul><ul><li>Faulting address can be read only in ring 0 </li></ul></ul><ul><ul><li>Xen reads the faulting address and passes it via stack to the OS handler in ring 1 </li></ul></ul>
  12. 12. Xen: Device I/O virtualization <ul><li>Set of clean and simple device abstractions </li></ul><ul><li>Allows buffers to be passed directly to/from guest OS to I/O devices </li></ul><ul><li>Event delivery mechanism for sending asynchronous notifications to the guest OS </li></ul>
  13. 16. Details of subsystem virtualization <ul><li>Control transfer </li></ul><ul><li>Data transfer </li></ul><ul><li>These are used in the virtualization of all the subsystems </li></ul>
  14. 17. Control transfer <ul><li>Hypercalls from guest OS to Xen </li></ul><ul><ul><li>E.g. set of page table updates </li></ul></ul><ul><li>Events for notification from Xen to guest OS </li></ul><ul><ul><li>E.g. data arrival on network; virtual disk transfer complete </li></ul></ul><ul><li>Events may be deferred by a guest OS (similar to disabling interrupts) </li></ul>
  15. 18. Data transfer – I/O rings <ul><li>Resource management and accountability </li></ul><ul><ul><li>CPU time </li></ul></ul><ul><ul><ul><li>Demultiplex data to the domains quickly upon interrupt </li></ul></ul></ul><ul><ul><ul><li>Account computation time for managing buffers to the appropriate domain </li></ul></ul></ul><ul><ul><li>Memory buffers </li></ul></ul><ul><ul><ul><li>relevant domains provide memory for I/O to Xen </li></ul></ul></ul><ul><ul><ul><li>Xen pins page frames during I/O transfer </li></ul></ul></ul>
  16. 19. I/O descriptors indirectly reference the actual memory buffers
  17. 20. <ul><li>Each request: unique ID from guest OS </li></ul><ul><li>Response: use this unique ID </li></ul><ul><li>Network packets </li></ul><ul><ul><li>Represented by a set of requests </li></ul></ul><ul><ul><li>Responses to these signal packet reception </li></ul></ul><ul><li>Disk requests </li></ul><ul><ul><li>May be reordered for flexibility </li></ul></ul><ul><li>Zero copy semantics via the descriptors </li></ul><ul><li>Domain my enqueue multiple entries before invoking a hypercall requests </li></ul><ul><li>Ditto for responses from Xen </li></ul>
  18. 21. CPU scheduling <ul><li>Base Xen scheduler uses BVT algorithm [Duda & Cheriton, SOSP 99] </li></ul><ul><ul><li>Work conserving for different domains (ensuring accountability) with a low-latency wake up on event arrival using virtual time warping </li></ul></ul>
  19. 22. Time and timers <ul><li>Guest OSs have access to Xen’s </li></ul><ul><ul><li>Real time (cycle counter accuracy for real time tasks in guest OSs) </li></ul></ul><ul><ul><li>Virtual time (enables time slicing within the guest OS) </li></ul></ul><ul><ul><li>Wall clock time (real time + domain changeable offset) </li></ul></ul><ul><li>Guest OS maintain their own internal timer queues and use a pair of Xen timers (real and virtual) </li></ul>
  20. 23. Virtual address translation <ul><li>VMware solution </li></ul><ul><ul><li>Each domain with shadow page table </li></ul></ul><ul><ul><li>Hypervisor go between the VMM and MMU </li></ul></ul><ul><li>Xen solution (similar to Exokernel) </li></ul><ul><ul><li>Register guest OS PT directly with MMU </li></ul></ul><ul><ul><li>Guest OS has read only access </li></ul></ul><ul><ul><li>All mods to the PT via Xen </li></ul></ul><ul><ul><li>Type associated with a page frame </li></ul></ul><ul><ul><ul><li>PD, PT, LDT, GDT, RW </li></ul></ul></ul><ul><ul><ul><li>All except RW: read-only access to the page for guest OS </li></ul></ul></ul><ul><ul><ul><li>Guest OS can retask a page only when ref count is 0 </li></ul></ul></ul>
  21. 24. Physical memory <ul><li>At domain creation, hardware pages “reserved” </li></ul><ul><li>Domain can increase/decrease its quota </li></ul><ul><li>Xen does not guarantee that the hardware pages are contiguous </li></ul><ul><li>Guest OS can maintain “physical memory” that is contiguous mapped to the “hardware pages” </li></ul>
  22. 25. Network <ul><li>Each guest OS has two I/O rings </li></ul><ul><ul><li>Receive and transmit </li></ul></ul><ul><li>Transmit </li></ul><ul><ul><li>Enqueue descriptor on the transmit ring </li></ul></ul><ul><ul><ul><li>Points to the buffer in guest OS space </li></ul></ul></ul><ul><ul><ul><li>No copying into Xen </li></ul></ul></ul><ul><ul><ul><li>Page pinned till transmission complete </li></ul></ul></ul><ul><ul><li>Round robin packet scheduler across domains </li></ul></ul><ul><li>Receive </li></ul><ul><ul><li>Exchange received page for a page of the guest OS in the receive ring </li></ul></ul><ul><ul><li>No copying </li></ul></ul>
  23. 26. Disk <ul><li>Batches of requests from competing domain taken and scheduled </li></ul><ul><li>Since Xen has knowledge of disk layout, requests may be reordered </li></ul><ul><li>No copying into Xen </li></ul><ul><li>“ Reoder barrier” to prevent reordering (may be necessary for higher level semantics such as write ahead log) </li></ul>
  24. 27. Performance
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.