os structures - xen. xen key points goal: extensibility akin to spin and exokernel goals main...

27
OS Structures - Xen

Upload: lucas-wiggins

Post on 18-Jan-2018

217 views

Category:

Documents


0 download

DESCRIPTION

Key points Goal: extensibility akin to SPIN and Exokernel goals Main difference: support running several commodity operating systems on the same hardware simultaneously without sacrificing performance or functionality Why? –Application mobility –Server consolidation –Co-located hosting facilities –Distributed web services –….

TRANSCRIPT

Page 1: OS Structures - Xen. Xen Key points Goal: extensibility akin to SPIN and Exokernel goals Main difference: support running several commodity operating

OS Structures - Xen

Page 2: OS Structures - Xen. Xen Key points Goal: extensibility akin to SPIN and Exokernel goals Main difference: support running several commodity operating

Xen

Page 3: OS Structures - Xen. Xen Key points Goal: extensibility akin to SPIN and Exokernel goals Main difference: support running several commodity operating

Key points• Goal: extensibility akin to SPIN and Exokernel

goals• Main difference: support running several

commodity operating systems on the same hardware simultaneously without sacrificing performance or functionality

• Why?– Application mobility– Server consolidation– Co-located hosting facilities– Distributed web services– ….

Page 4: OS Structures - Xen. Xen Key points Goal: extensibility akin to SPIN and Exokernel goals Main difference: support running several commodity operating

Old idea• VM 370

– Virtualization for binary support for legacy apps• Why resurgence today?

– Companies want a share of everybody’s pie• IBM zSeries “mainframes” support virtualization for server

consolidation– Enables billing and performance isolation while hosting several

customers• Microsoft has announced virtualization plans to allow easy

upgrades and hosting Linux!

• You can see the dots connecting up– From extensibility (a la SPIN) to virtualization

Page 5: OS Structures - Xen. Xen Key points Goal: extensibility akin to SPIN and Exokernel goals Main difference: support running several commodity operating

Possible virtualization approaches

• Standard OS (such as Linux, Windows)– Meta services (such as grid) for users to install files

and run processes– Administration, accountability, and performance

isolation become hard• Retrofit performance isolation into OSs

– Linux/RK, QLinux, SILK– Accounting resource usage correctly can be an issue

unless done at the lowest level (e.g. Exokernel)• Xen approach

– Multiplex physical resource at OS granularity

Page 6: OS Structures - Xen. Xen Key points Goal: extensibility akin to SPIN and Exokernel goals Main difference: support running several commodity operating

Full virtualization

• Virtual hardware identical to real one– Relies on hosted OS trapping to the VMM for

privileged instructions– Pros: run unmodified OS binary on top– Cons:

• supervisor instructions can fail silently in some hardware platforms (e.g. x86)

– Solution in VMware: Dynamically rewrite portions of the hosted OS to insert traps

• need for hosted OS to see real resources: real time, page coloring tricks for optimizing performance, etc…

Page 7: OS Structures - Xen. Xen Key points Goal: extensibility akin to SPIN and Exokernel goals Main difference: support running several commodity operating

Xen principles

• Support for unmodified application binaries• Support for multi-application OS

– Complex server configuration within a single OS instance

• Paravirtualization for strong resource isolation on uncooperative hardware (x86)

• Paravirtualization to enable optimizing guest OS performance and correctness

Page 8: OS Structures - Xen. Xen Key points Goal: extensibility akin to SPIN and Exokernel goals Main difference: support running several commodity operating

Xen: VM management

• What would make VM virtualization easy– Software TLB– Tagged TLB =>no TLB flush on context switchX86 does not have either

• Xen approach– Guest OS responsible for allocating and

managing hardware PT– Xen top 64MB of every address space. Why?

Page 9: OS Structures - Xen. Xen Key points Goal: extensibility akin to SPIN and Exokernel goals Main difference: support running several commodity operating

x86 Memory Management

• Segments– CS (code); SS (stack); DS, ES, FS, GS (all

data)– Base address and limit checking

• Segment base added to CPU address is the linear 32-bit virtual address

• 4KB pages– Top 10 bits of address: page table– Next 10 bits of address: page table entry

Page 10: OS Structures - Xen. Xen Key points Goal: extensibility akin to SPIN and Exokernel goals Main difference: support running several commodity operating

• Creating a new PT by Guest OS – allocate and initialize a page and registers it

with Xen to serve as the new PT– all subsequent updates to this page (i.e. PT)

via Xen– can batch updates to reduce the cost of

entering and exiting Xen• Segmentation by guest OS virtualized

similarly

Page 11: OS Structures - Xen. Xen Key points Goal: extensibility akin to SPIN and Exokernel goals Main difference: support running several commodity operating

Xen: CPU virtualization• Four privilege levels in x86

– Ring 0 (Xen)– Ring 1 (guest OS)– Ring 3 (apps of the guest OS)

• Privileged instructions– Validated and executed in Xen (e.g. installing a new PT)

• Exceptions– Registered with Xen once– Called directly without Xen intervention– All syscalls from apps to guest OS handled this way

• Page fault handlers are special– Faulting address can be read only in ring 0– Xen reads the faulting address and passes it via stack to the OS

handler in ring 1

Page 12: OS Structures - Xen. Xen Key points Goal: extensibility akin to SPIN and Exokernel goals Main difference: support running several commodity operating

Xen: Device I/O virtualization

• Set of clean and simple device abstractions

• Allows buffers to be passed directly to/from guest OS to I/O devices

• Event delivery mechanism for sending asynchronous notifications to the guest OS

Page 13: OS Structures - Xen. Xen Key points Goal: extensibility akin to SPIN and Exokernel goals Main difference: support running several commodity operating
Page 14: OS Structures - Xen. Xen Key points Goal: extensibility akin to SPIN and Exokernel goals Main difference: support running several commodity operating
Page 15: OS Structures - Xen. Xen Key points Goal: extensibility akin to SPIN and Exokernel goals Main difference: support running several commodity operating
Page 16: OS Structures - Xen. Xen Key points Goal: extensibility akin to SPIN and Exokernel goals Main difference: support running several commodity operating

Details of subsystem virtualization

• Control transfer• Data transfer

These are used in the virtualization of all the subsystems

Page 17: OS Structures - Xen. Xen Key points Goal: extensibility akin to SPIN and Exokernel goals Main difference: support running several commodity operating

Control transfer

• Hypercalls from guest OS to Xen– E.g. set of page table updates

• Events for notification from Xen to guest OS– E.g. data arrival on network; virtual disk

transfer complete• Events may be deferred by a guest OS

(similar to disabling interrupts)

Page 18: OS Structures - Xen. Xen Key points Goal: extensibility akin to SPIN and Exokernel goals Main difference: support running several commodity operating

Data transfer – I/O rings

• Resource management and accountability– CPU time

• Demultiplex data to the domains quickly upon interrupt

• Account computation time for managing buffers to the appropriate domain

– Memory buffers• relevant domains provide memory for I/O to Xen• Xen pins page frames during I/O transfer

Page 19: OS Structures - Xen. Xen Key points Goal: extensibility akin to SPIN and Exokernel goals Main difference: support running several commodity operating

I/O descriptors indirectly reference the actual memory buffers

Page 20: OS Structures - Xen. Xen Key points Goal: extensibility akin to SPIN and Exokernel goals Main difference: support running several commodity operating

• Each request: unique ID from guest OS• Response: use this unique ID• Network packets

– Represented by a set of requests– Responses to these signal packet reception

• Disk requests– May be reordered for flexibility

• Zero copy semantics via the descriptors• Domain my enqueue multiple entries before

invoking a hypercall requests• Ditto for responses from Xen

Page 21: OS Structures - Xen. Xen Key points Goal: extensibility akin to SPIN and Exokernel goals Main difference: support running several commodity operating

CPU scheduling

• Base Xen scheduler uses BVT algorithm [Duda & Cheriton, SOSP 99]– Work conserving for different domains

(ensuring accountability) with a low-latency wake up on event arrival using virtual time warping

Page 22: OS Structures - Xen. Xen Key points Goal: extensibility akin to SPIN and Exokernel goals Main difference: support running several commodity operating

Time and timers

• Guest OSs have access to Xen’s– Real time (cycle counter accuracy for real

time tasks in guest OSs)– Virtual time (enables time slicing within the

guest OS)– Wall clock time (real time + domain

changeable offset)• Guest OS maintain their own internal timer

queues and use a pair of Xen timers (real and virtual)

Page 23: OS Structures - Xen. Xen Key points Goal: extensibility akin to SPIN and Exokernel goals Main difference: support running several commodity operating

Virtual address translation• VMware solution

– Each domain with shadow page table– Hypervisor go between the VMM and MMU

• Xen solution (similar to Exokernel)– Register guest OS PT directly with MMU– Guest OS has read only access– All mods to the PT via Xen– Type associated with a page frame

• PD, PT, LDT, GDT, RW• All except RW: read-only access to the page for guest OS• Guest OS can retask a page only when ref count is 0

Page 24: OS Structures - Xen. Xen Key points Goal: extensibility akin to SPIN and Exokernel goals Main difference: support running several commodity operating

Physical memory

• At domain creation, hardware pages “reserved”

• Domain can increase/decrease its quota• Xen does not guarantee that the hardware

pages are contiguous• Guest OS can maintain “physical memory”

that is contiguous mapped to the “hardware pages”

Page 25: OS Structures - Xen. Xen Key points Goal: extensibility akin to SPIN and Exokernel goals Main difference: support running several commodity operating

Network• Each guest OS has two I/O rings

– Receive and transmit• Transmit

– Enqueue descriptor on the transmit ring• Points to the buffer in guest OS space• No copying into Xen• Page pinned till transmission complete

– Round robin packet scheduler across domains• Receive

– Exchange received page for a page of the guest OS in the receive ring

– No copying

Page 26: OS Structures - Xen. Xen Key points Goal: extensibility akin to SPIN and Exokernel goals Main difference: support running several commodity operating

Disk

• Batches of requests from competing domain taken and scheduled

• Since Xen has knowledge of disk layout, requests may be reordered

• No copying into Xen• “Reoder barrier” to prevent reordering

(may be necessary for higher level semantics such as write ahead log)

Page 27: OS Structures - Xen. Xen Key points Goal: extensibility akin to SPIN and Exokernel goals Main difference: support running several commodity operating

Performance